# Generated by Django 6.0.2 on 2026-02-27 10:47

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=120, unique=True)),
                ('slug', models.SlugField(max_length=140, unique=True)),
                ('is_active', models.BooleanField(default=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='GameSession',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=8, unique=True)),
                ('status', models.CharField(choices=[('lobby', 'Lobby'), ('lie', 'Løgnfase'), ('guess', 'Gættefase'), ('reveal', 'Reveal'), ('finished', 'Afsluttet')], default='lobby', max_length=16)),
                ('current_round', models.PositiveIntegerField(default=1)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('host', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='hosted_sessions', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Player',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('nickname', models.CharField(max_length=40)),
                ('score', models.IntegerField(default=0)),
                ('is_connected', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='players', to='fupogfakta.gamesession')),
            ],
            options={
                'ordering': ['-score', 'nickname'],
                'unique_together': {('session', 'nickname')},
            },
        ),
        migrations.CreateModel(
            name='Question',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('prompt', models.TextField()),
                ('correct_answer', models.CharField(max_length=255)),
                ('is_active', models.BooleanField(default=True)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='questions', to='fupogfakta.category')),
            ],
        ),
        migrations.CreateModel(
            name='RoundConfig',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('number', models.PositiveIntegerField()),
                ('questions_count', models.PositiveIntegerField(default=3)),
                ('points_correct', models.IntegerField(default=5)),
                ('points_bluff', models.IntegerField(default=2)),
                ('lie_seconds', models.PositiveIntegerField(default=45)),
                ('guess_seconds', models.PositiveIntegerField(default=30)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fupogfakta.category')),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rounds', to='fupogfakta.gamesession')),
            ],
            options={
                'ordering': ['number'],
            },
        ),
        migrations.CreateModel(
            name='RoundQuestion',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('round_number', models.PositiveIntegerField()),
                ('correct_answer', models.CharField(max_length=255)),
                ('question', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='fupogfakta.question')),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='round_questions', to='fupogfakta.gamesession')),
            ],
        ),
        migrations.CreateModel(
            name='LieAnswer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.CharField(max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fupogfakta.player')),
                ('round_question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='lies', to='fupogfakta.roundquestion')),
            ],
        ),
        migrations.CreateModel(
            name='Guess',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('selected_text', models.CharField(max_length=255)),
                ('is_correct', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('fooled_player', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fooled_guesses', to='fupogfakta.player')),
                ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='fupogfakta.player')),
                ('round_question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='guesses', to='fupogfakta.roundquestion')),
            ],
        ),
        migrations.CreateModel(
            name='ScoreEvent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('delta', models.IntegerField()),
                ('reason', models.CharField(max_length=80)),
                ('meta', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='score_events', to='fupogfakta.player')),
                ('session', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='score_events', to='fupogfakta.gamesession')),
            ],
        ),
        migrations.AddIndex(
            model_name='question',
            index=models.Index(fields=['category', 'is_active'], name='fupogfakta__categor_358d00_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='roundconfig',
            unique_together={('session', 'number')},
        ),
        migrations.AlterUniqueTogether(
            name='lieanswer',
            unique_together={('round_question', 'player')},
        ),
        migrations.AlterUniqueTogether(
            name='guess',
            unique_together={('round_question', 'player')},
        ),
    ]
