"""Cards 16-18 (Realms — Disco Inferno / Torre Terrestre / Fantasia Celestia)
have a reversal NAME swap (`reversal_qualifier` field carrying "Shame" /
"Guilt" / "Anxiety") but per user-spec 2026-05-23 the reversal face renders
the name ALONE, with NO polarity qualifier appended. Set
`reversal_drops_qualifier=True` so `TarotCard.applet_face()` knows to drop
the polarity qualifier on the reversal face. See [[feedback-reversal-
qualifier-dual-role]] for the broader Pattern B vs Pattern B' distinction.
"""
from django.db import migrations


REVERSAL_DROPS_QUALIFIER_NUMBERS = [16, 17, 18]


def set_flag(apps, schema_editor):
    TarotCard = apps.get_model("epic", "TarotCard")
    TarotCard.objects.filter(
        arcana="MAJOR", number__in=REVERSAL_DROPS_QUALIFIER_NUMBERS,
    ).update(reversal_drops_qualifier=True)


def clear_flag(apps, schema_editor):
    TarotCard = apps.get_model("epic", "TarotCard")
    TarotCard.objects.filter(
        arcana="MAJOR", number__in=REVERSAL_DROPS_QUALIFIER_NUMBERS,
    ).update(reversal_drops_qualifier=False)


class Migration(migrations.Migration):

    dependencies = [
        ("epic", "0009_reversal_drops_qualifier"),
    ]

    operations = [
        migrations.RunPython(set_flag, reverse_code=clear_flag),
    ]
