# Generated by Django 4.2.16 on 2026-10-29 01:21

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('store', '0009_flexible_coupons'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('articles', '0011_magazines_and_homepage_blocks'),
    ]

    operations = [
        migrations.CreateModel(
            name='Game',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('kind', models.CharField(choices=[('timeline', 'Timeline (put events in order)'), ('whoami', 'Who am I? (clues)'), ('factmyth', 'Fact or myth (true / false)')], max_length=10, unique=True)),
                ('title', models.CharField(max_length=120)),
                ('title_en', models.CharField(blank=True, max_length=120, verbose_name='English title')),
                ('slug', models.SlugField(unique=True)),
                ('tagline', models.CharField(blank=True, max_length=200)),
                ('description', models.TextField(help_text='What the game is and how to play (shown on the game page).')),
                ('how_to_play', models.TextField(blank=True, help_text='One rule per line.')),
                ('physical_note', models.TextField(blank=True, help_text='How this game works as a physical card game (shown on the page).', verbose_name='Printed version')),
                ('image', models.ImageField(blank=True, upload_to='games/')),
                ('rounds', models.PositiveSmallIntegerField(default=10, help_text='Questions/cards per play.')),
                ('is_active', models.BooleanField(default=True)),
                ('order', models.PositiveSmallIntegerField(default=0)),
                ('meta_description', models.CharField(blank=True, max_length=160)),
                ('reward_enabled', models.BooleanField(default=True, verbose_name='Give a discount for good scores')),
                ('reward_min_score', models.PositiveSmallIntegerField(default=40, help_text='Players below this score get no coupon.', verbose_name='Minimum score (%)')),
                ('reward_max_percent', models.PositiveSmallIntegerField(default=20, help_text='Discount grows with the score. 70% score → 70% of this.', verbose_name='Discount at 100% score (%)')),
                ('reward_max_taka', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True, verbose_name='Maximum discount (৳)')),
                ('reward_min_order', models.DecimalField(blank=True, decimal_places=2, max_digits=8, null=True, verbose_name='Minimum order (৳)')),
                ('reward_applies_to', models.CharField(choices=[('all', 'Everything (shop + digital magazines)'), ('magazines', 'Magazines — printed and digital'), ('magazine_digital', 'Digital magazines only'), ('magazine_print', 'Printed magazines only'), ('merch', 'Wearable history (merch) only'), ('nostalgic', 'Nostalgic items only'), ('selected', 'Only the products picked below')], default='magazines', max_length=20, verbose_name='Discount works on')),
                ('reward_valid_days', models.PositiveSmallIntegerField(default=7, verbose_name='Coupon valid for (days)')),
                ('reward_cooldown_days', models.PositiveSmallIntegerField(default=7, help_text='A player can earn one coupon from this game per this many days.', verbose_name='One reward every (days)')),
                ('reward_products', models.ManyToManyField(blank=True, help_text="Used when 'Discount works on' is 'Only the products picked below'.", related_name='game_rewards', to='store.product')),
            ],
            options={
                'ordering': ['order', 'id'],
            },
        ),
        migrations.CreateModel(
            name='Play',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('token', models.CharField(default=apps.games.models._token, editable=False, max_length=32, unique=True)),
                ('session_key', models.CharField(blank=True, max_length=40)),
                ('cards', models.JSONField(default=list)),
                ('state', models.JSONField(default=dict)),
                ('step', models.PositiveSmallIntegerField(default=0)),
                ('score', models.PositiveIntegerField(default=0)),
                ('max_score', models.PositiveIntegerField(default=0)),
                ('correct', models.PositiveSmallIntegerField(default=0)),
                ('mistakes', models.PositiveSmallIntegerField(default=0)),
                ('finished', models.BooleanField(db_index=True, default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('finished_at', models.DateTimeField(blank=True, null=True)),
                ('coupon', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='game_plays', to='store.coupon')),
                ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='plays', to='games.game')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='game_plays', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='GameCard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(help_text='Timeline: the event · Who am I: the answer · Fact/myth: the statement', max_length=300)),
                ('year', models.IntegerField(blank=True, help_text='Timeline only: the year (negative for BCE).', null=True)),
                ('year_label', models.CharField(blank=True, help_text="Optional display, e.g. '১২০৪ খ্রি.' or 'আনু. ৩০০ খ্রিস্টপূর্ব'.", max_length=40)),
                ('clues', models.TextField(blank=True, help_text='Who am I only: one clue per line, hardest first.')),
                ('wrong_options', models.TextField(blank=True, help_text='Who am I only: three wrong answers, one per line.')),
                ('is_true', models.BooleanField(blank=True, help_text='Fact/myth only: is the statement true?', null=True)),
                ('explanation', models.TextField(blank=True, help_text='Shown after answering — the real story in 1–3 sentences.')),
                ('image', models.ImageField(blank=True, upload_to='games/cards/')),
                ('source', models.CharField(blank=True, help_text='Where this fact comes from (for editors).', max_length=300)),
                ('is_active', models.BooleanField(default=True)),
                ('article', models.ForeignKey(blank=True, help_text='Optional: an article to read more.', null=True, on_delete=django.db.models.deletion.SET_NULL, to='articles.article')),
                ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cards', to='games.game')),
            ],
            options={
                'ordering': ['game', 'year', 'id'],
            },
        ),
    ]
