新增游戏管理系统:①game_configs表+模型(forGame/isEnabled/param静态方法) ②GameConfigSeeder初始化5款游戏参数 ③后台卡片式管理页(开关+参数表单) ④侧边栏菜单「游戏管理」

This commit is contained in:
2026-03-01 20:17:18 +08:00
parent 8c99e1fad7
commit 8a74bfd639
7 changed files with 585 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
<?php
/**
* 文件功能:游戏配置表迁移
*
* 集中管理聊天室所有娱乐游戏的开关状态和核心参数。
* 每个游戏对应一行记录params 字段存储各游戏的 JSON 参数。
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* 创建 game_configs 表。
*/
public function up(): void
{
Schema::create('game_configs', function (Blueprint $table) {
$table->id();
$table->string('game_key', 50)->unique()->comment('游戏唯一标识(如 baccarat、slot_machine');
$table->string('name', 100)->comment('游戏中文名');
$table->string('icon', 10)->default('🎮')->comment('游戏图标 Emoji');
$table->text('description')->nullable()->comment('游戏简介');
$table->boolean('enabled')->default(false)->comment('是否开启');
$table->json('params')->nullable()->comment('游戏核心参数JSON');
$table->timestamps();
});
}
/**
* 回滚迁移。
*/
public function down(): void
{
Schema::dropIfExists('game_configs');
}
};

View File

@@ -0,0 +1,128 @@
<?php
/**
* 文件功能:游戏默认配置数据填充器
*
* 初始化所有娱乐游戏的默认参数,管理员可在后台修改。
* 所有游戏默认关闭,需要管理员手动开启。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace Database\Seeders;
use App\Models\GameConfig;
use Illuminate\Database\Seeder;
class GameConfigSeeder extends Seeder
{
/**
* 填充所有游戏默认配置。
*/
public function run(): void
{
$games = [
// ─── 百家乐(大小押注)────────────────────────────────────
[
'game_key' => 'baccarat',
'name' => '百家乐',
'icon' => '🎲',
'description' => '系统每隔一段时间自动开一局,玩家在倒计时内押注大/小/豹子,骰子结果决定胜负。',
'enabled' => false,
'params' => [
'interval_minutes' => 2, // 多少分钟开一局
'bet_window_seconds' => 60, // 每局押注窗口(秒)
'min_bet' => 100, // 最低押注金币
'max_bet' => 50000, // 最高押注金币
'payout_big' => 1, // 大1:1 赔率
'payout_small' => 1, // 小1:1 赔率
'payout_triple' => 24, // 豹子1:24 赔率
'kill_points' => [3, 18], // 庄家收割点数(全灭)
],
],
// ─── 老虎机 ──────────────────────────────────────────────
[
'game_key' => 'slot_machine',
'name' => '老虎机',
'icon' => '🎰',
'description' => '消耗金币转动老虎机三列图案匹配可获得不同倍率奖励三个7大奖全服广播。',
'enabled' => false,
'params' => [
'cost_per_spin' => 100, // 每次旋转消耗
'house_edge_percent' => 15, // 庄家边际(%
'daily_limit' => 100, // 每日最多转动次数0=不限)
'jackpot_payout' => 100, // 三个7 赔率
'triple_payout' => 50, // 三个💎 赔率
'same_payout' => 10, // 其他三同 赔率
'pair_payout' => 2, // 两同 赔率
'curse_enabled' => true, // 是否开启诅咒(三💀扣双倍)
],
],
// ─── 神秘箱子 ────────────────────────────────────────────
[
'game_key' => 'mystery_box',
'name' => '神秘箱子',
'icon' => '📦',
'description' => '管理员随时投放或系统定时自动投放神秘箱,最快发送暗号的用户开箱获得奖励。',
'enabled' => false,
'params' => [
'auto_drop_enabled' => false, // 是否自动定时投放
'auto_interval_hours' => 2, // 自动投放间隔(小时)
'claim_window_seconds' => 60, // 领取窗口(秒)
'min_reward' => 500, // 普通箱最低奖励
'max_reward' => 2000, // 普通箱最高奖励
'rare_min_reward' => 5000, // 稀有箱最低奖励
'rare_max_reward' => 20000, // 稀有箱最高奖励
'trap_chance_percent' => 10, // 黑化箱触发概率(%
],
],
// ─── 赛马竞猜 ────────────────────────────────────────────
[
'game_key' => 'horse_racing',
'name' => '赛马竞猜',
'icon' => '🐎',
'description' => '系统定期举办赛马,用户在倒计时内下注,按注池赔率结算,跑马过程 WebSocket 实时播报。',
'enabled' => false,
'params' => [
'interval_minutes' => 30, // 多少分钟一场
'bet_window_seconds' => 90, // 押注窗口(秒)
'race_duration' => 30, // 跑马动画时长(秒)
'horse_count' => 4, // 参赛马匹数量
'min_bet' => 100, // 最低押注
'max_bet' => 100000, // 最高押注
'house_take_percent' => 5, // 庄家抽水(%
],
],
// ─── 神秘占卜 ────────────────────────────────────────────
[
'game_key' => 'fortune_telling',
'name' => '神秘占卜',
'icon' => '🔮',
'description' => '每日一次免费占卜,系统生成玄学签文并赋予当日加成效果(幸运/倒霉)。额外占卜消耗金币。',
'enabled' => false,
'params' => [
'free_count_per_day' => 1, // 每日免费次数
'extra_cost' => 500, // 额外次数消耗金币
'buff_duration_hours' => 24, // 加成效果持续时间
'jackpot_chance' => 5, // 上上签概率(%
'good_chance' => 20, // 上签概率(%
'bad_chance' => 20, // 下签概率(%
'curse_chance' => 5, // 大凶签概率(%
],
],
];
foreach ($games as $game) {
GameConfig::updateOrCreate(
['game_key' => $game['game_key']],
$game,
);
}
}
}