# Generated by Django 5.2.5 on 2025-08-28 05:18

import card.storage
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="Food",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=100, verbose_name="食物名称")),
                (
                    "food_type",
                    models.CharField(
                        choices=[
                            ("fruit", "水果"),
                            ("vegetable", "蔬菜"),
                            ("meat", "肉类"),
                            ("seafood", "海鲜"),
                            ("dairy", "乳制品"),
                            ("grain", "谷物"),
                            ("snack", "零食"),
                            ("drink", "饮品"),
                            ("dessert", "甜品"),
                            ("spice", "调料"),
                            ("other", "其他"),
                        ],
                        max_length=20,
                        verbose_name="食物类型",
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="食物描述"),
                ),
                (
                    "rarity",
                    models.CharField(
                        choices=[
                            ("common", "普通"),
                            ("uncommon", "不常见"),
                            ("rare", "稀有"),
                            ("epic", "史诗"),
                            ("legendary", "传说"),
                            ("mythic", "神话"),
                        ],
                        default="common",
                        max_length=20,
                        verbose_name="稀有程度",
                    ),
                ),
                (
                    "image",
                    models.ImageField(
                        blank=True,
                        help_text="食物的展示图片",
                        null=True,
                        storage=card.storage.OSSStorage(base_dir="foods"),
                        upload_to="images/",
                        verbose_name="食物图片",
                    ),
                ),
                (
                    "animation_file",
                    models.FileField(
                        blank=True,
                        help_text="食物的动画文件，支持gif/mp4等格式",
                        null=True,
                        storage=card.storage.OSSStorage(base_dir="foods"),
                        upload_to="animations/",
                        verbose_name="动画文件",
                    ),
                ),
                (
                    "sound_effect",
                    models.FileField(
                        blank=True,
                        help_text="食物相关的音效文件，如咀嚼声、烹饪声等",
                        null=True,
                        storage=card.storage.OSSStorage(base_dir="foods"),
                        upload_to="sounds/",
                        verbose_name="音效文件",
                    ),
                ),
                (
                    "calories",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="每100g的卡路里",
                        null=True,
                        verbose_name="卡路里",
                    ),
                ),
                (
                    "taste_tags",
                    models.CharField(
                        blank=True,
                        help_text="用逗号分隔，如：甜,酸,脆",
                        max_length=200,
                        null=True,
                        verbose_name="口味标签",
                    ),
                ),
                (
                    "cooking_methods",
                    models.TextField(blank=True, null=True, verbose_name="烹饪方法"),
                ),
                (
                    "nutritional_value",
                    models.TextField(blank=True, null=True, verbose_name="营养价值"),
                ),
                (
                    "effect_description",
                    models.TextField(
                        blank=True,
                        help_text="在游戏中的特殊效果",
                        null=True,
                        verbose_name="效果描述",
                    ),
                ),
                (
                    "boost_attributes",
                    models.JSONField(
                        blank=True,
                        help_text="JSON格式的属性加成数据",
                        null=True,
                        verbose_name="属性加成",
                    ),
                ),
                (
                    "unlock_condition",
                    models.TextField(blank=True, null=True, verbose_name="解锁条件"),
                ),
                (
                    "usage_limit",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="0表示无限制",
                        null=True,
                        verbose_name="使用次数限制",
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("draft", "草稿"),
                            ("published", "已发布"),
                            ("archived", "已归档"),
                        ],
                        default="draft",
                        max_length=20,
                        verbose_name="状态",
                    ),
                ),
                (
                    "is_limited",
                    models.BooleanField(default=False, verbose_name="限时食物"),
                ),
                (
                    "available_from",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="开始时间"
                    ),
                ),
                (
                    "available_until",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="结束时间"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="创建时间"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="更新时间"),
                ),
                (
                    "published_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="发布时间"
                    ),
                ),
            ],
            options={
                "verbose_name": "食物",
                "verbose_name_plural": "食物",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(fields=["name"], name="food_app_fo_name_28ef64_idx"),
                    models.Index(
                        fields=["food_type"], name="food_app_fo_food_ty_97e8ea_idx"
                    ),
                    models.Index(
                        fields=["rarity"], name="food_app_fo_rarity_d9a2f0_idx"
                    ),
                    models.Index(
                        fields=["status"], name="food_app_fo_status_be68b4_idx"
                    ),
                    models.Index(
                        fields=["created_at"], name="food_app_fo_created_e9bf8b_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="FoodUsageLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "used_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="使用时间"),
                ),
                (
                    "effect_applied",
                    models.JSONField(
                        blank=True,
                        help_text="JSON格式的效果数据",
                        null=True,
                        verbose_name="应用效果",
                    ),
                ),
                ("notes", models.TextField(blank=True, null=True, verbose_name="备注")),
                (
                    "usage_context",
                    models.CharField(
                        blank=True,
                        help_text="如：战斗中、休息时、特殊活动等",
                        max_length=100,
                        null=True,
                        verbose_name="使用场景",
                    ),
                ),
                (
                    "food",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="usage_logs",
                        to="food_app.food",
                        verbose_name="食物",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="food_usage_logs",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "食物使用记录",
                "verbose_name_plural": "食物使用记录",
                "ordering": ["-used_at"],
                "indexes": [
                    models.Index(
                        fields=["user"], name="food_app_fo_user_id_979fc1_idx"
                    ),
                    models.Index(
                        fields=["food"], name="food_app_fo_food_id_210b62_idx"
                    ),
                    models.Index(
                        fields=["used_at"], name="food_app_fo_used_at_c7731d_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="UserFood",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "quantity",
                    models.PositiveIntegerField(default=1, verbose_name="拥有数量"),
                ),
                (
                    "used_count",
                    models.PositiveIntegerField(default=0, verbose_name="已使用次数"),
                ),
                (
                    "obtained_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="获得时间"),
                ),
                (
                    "obtained_method",
                    models.CharField(
                        blank=True,
                        help_text="如：购买、奖励、活动等",
                        max_length=50,
                        null=True,
                        verbose_name="获得方式",
                    ),
                ),
                (
                    "last_used_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="最后使用时间"
                    ),
                ),
                (
                    "food",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="users",
                        to="food_app.food",
                        verbose_name="食物",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="foods",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="用户",
                    ),
                ),
            ],
            options={
                "verbose_name": "用户食物",
                "verbose_name_plural": "用户食物",
                "ordering": ["-obtained_at"],
                "indexes": [
                    models.Index(
                        fields=["user"], name="food_app_us_user_id_a2075b_idx"
                    ),
                    models.Index(
                        fields=["food"], name="food_app_us_food_id_ea7000_idx"
                    ),
                    models.Index(
                        fields=["obtained_at"], name="food_app_us_obtaine_13d155_idx"
                    ),
                ],
                "unique_together": {("user", "food")},
            },
        ),
    ]
