<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;

class GomokuConfigSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $params = [
            // PvP 配置
            'pvp_reward' => 80,
            'pvp_invite_timeout' => 60,
            'pvp_move_timeout' => 60,
            'pvp_ready_timeout' => 30,

            // PvE AI 难度入口费
            'pve_fee_level_1' => 0,
            'pve_fee_level_2' => 10,
            'pve_fee_level_3' => 30,
            'pve_fee_level_4' => 80,

            // PvE AI 难度胜利奖励
            'pve_reward_level_1' => 20,
            'pve_reward_level_2' => 50,
            'pve_reward_level_3' => 120,
            'pve_reward_level_4' => 300,
        ];

        $config = \App\Models\GameConfig::firstOrNew(['game_key' => 'gomoku']);
        $config->name = '五子棋';
        $config->icon = '♟️';
        $config->description = '支持 PvP 玩家对战与 PvE 多难度人机对战，支持断线重连。';
        $config->enabled = true;

        // 合并已有配置，避免覆盖管理员在后台修改过的其他选项
        $existingParams = $config->params ?? [];
        $config->params = array_merge($existingParams, $params);

        $config->save();
    }
}
