feat: 猜成语游戏 - 完整题库、管理后台、答题弹窗

- 创建 idioms 表(102条谜语式成语题库)和 idiom_game_rounds 表
- 后台成语管理页面:增删改题目 + 游戏参数(金币/经验/间隔)内联设置 + 出题按钮
- IdiomQuizController:出题/答题/当前回合查询,Redis 防并发抢答
- IdiomGameStarted / IdiomGameAnswered 广播事件
- 前端答题弹窗模块:聊天消息带【答题】按钮,点击弹出输入框
- GameConfig 注册 idiom 游戏,由 admin.game-configs 统一管理开关
This commit is contained in:
pllx
2026-04-28 23:42:48 +08:00
parent 461c6a6f56
commit 4ff62e29bd
20 changed files with 1497 additions and 1 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* 文件功能:猜成语题目模型
*
* 对应 idioms 表,每条记录是一道成语题目 + 谜语提示。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Idiom extends Model
{
protected $fillable = [
'answer',
'hint',
'is_active',
'sort',
];
protected function casts(): array
{
return [
'is_active' => 'boolean',
'sort' => 'integer',
];
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
/**
* 文件功能:猜成语游戏回合模型
*
* 每次出题对应一个回合,记录题目、状态、奖励和获胜者。
*
* @author ChatRoom Laravel
*
* @version 1.0.0
*/
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class IdiomGameRound extends Model
{
protected $fillable = [
'room_id',
'idiom_id',
'status',
'reward_gold',
'reward_exp',
'winner_id',
'winner_username',
'started_at',
'ended_at',
];
protected function casts(): array
{
return [
'reward_gold' => 'integer',
'reward_exp' => 'integer',
'started_at' => 'datetime',
'ended_at' => 'datetime',
];
}
public function idiom(): BelongsTo
{
return $this->belongsTo(Idiom::class);
}
}