<?php

/**
 * 文件功能：钓鱼事件初始数据填充
 *
 * 将原硬编码的 7 个钓鱼事件迁移至数据库，
 * 调整奖励：经验减少，金币提升，游戏更加休闲娱乐。
 *
 * 执行方式：php artisan db:seed --class=FishingEventSeeder
 *
 * @author   ChatRoom Laravel
 *
 * @version  1.0.0
 */

namespace Database\Seeders;

use App\Models\FishingEvent;
use Illuminate\Database\Seeder;

class FishingEventSeeder extends Seeder
{
    /**
     * 填充钓鱼事件数据
     *
     * weight 权重说明（总权重 100）：
     *   15 → 大鲨鱼（幸运）
     *   15 → 娃娃鱼（卖鱼）
     *   20 → 大草鱼（经验）
     *   20 → 小鲤鱼（双收）
     *   15 → 掉河（惩罚）
     *   10 → 被打（惩罚）
     *    5 → 超级大奖
     */
    public function run(): void
    {
        // 避免重复 Seed
        if (FishingEvent::count() > 0) {
            $this->command->info('钓鱼事件已存在，跳过填充。');

            return;
        }

        $events = [
            [
                'sort' => 1,
                'emoji' => '🦈',
                'name' => '大鲨鱼',
                'message' => '钓到一条大鲨鱼！获得经验30、金币50',
                'exp' => 30,
                'jjb' => 50,
                'weight' => 15,
                'is_active' => true,
            ],
            [
                'sort' => 2,
                'emoji' => '🐟',
                'name' => '娃娃鱼',
                'message' => '钓到一条娃娃鱼，到集市卖得80个金币',
                'exp' => 0,
                'jjb' => 80,
                'weight' => 15,
                'is_active' => true,
            ],
            [
                'sort' => 3,
                'emoji' => '🐠',
                'name' => '大草鱼',
                'message' => '钓到一只大草鱼，吃下增加经验20、金币30',
                'exp' => 20,
                'jjb' => 30,
                'weight' => 20,
                'is_active' => true,
            ],
            [
                'sort' => 4,
                'emoji' => '🐡',
                'name' => '小鲤鱼',
                'message' => '钓到一条小鲤鱼，增加经验10、金币20',
                'exp' => 10,
                'jjb' => 20,
                'weight' => 20,
                'is_active' => true,
            ],
            [
                'sort' => 5,
                'emoji' => '💧',
                'name' => '落水惨败',
                'message' => '鱼没钓到，摔到河里损失金币30',
                'exp' => 0,
                'jjb' => -30,
                'weight' => 15,
                'is_active' => true,
            ],
            [
                'sort' => 6,
                'emoji' => '👊',
                'name' => '被抓殴打',
                'message' => '偷钓鱼塘被主人发现，一阵殴打！金币减少10',
                'exp' => 0,
                'jjb' => -10,
                'weight' => 10,
                'is_active' => true,
            ],
            [
                'sort' => 7,
                'emoji' => '🎉',
                'name' => '超级大奖',
                'message' => '运气爆棚！钓到大鲨鱼、大草鱼、小鲤鱼各一条！经验+50，金币+200！',
                'exp' => 50,
                'jjb' => 200,
                'weight' => 5,
                'is_active' => true,
            ],
        ];

        foreach ($events as $event) {
            FishingEvent::create($event);
        }

        $this->command->info('✅ 钓鱼事件已填充（7 条）');
    }
}
