feat: 猜成语游戏 - 完整题库、管理后台、答题弹窗
- 创建 idioms 表(102条谜语式成语题库)和 idiom_game_rounds 表 - 后台成语管理页面:增删改题目 + 游戏参数(金币/经验/间隔)内联设置 + 出题按钮 - IdiomQuizController:出题/答题/当前回合查询,Redis 防并发抢答 - IdiomGameStarted / IdiomGameAnswered 广播事件 - 前端答题弹窗模块:聊天消息带【答题】按钮,点击弹出输入框 - GameConfig 注册 idiom 游戏,由 admin.game-configs 统一管理开关
This commit is contained in:
@@ -158,6 +158,9 @@ enum CurrencySource: string
|
||||
/** 购买头像框消耗(扣除金币) */
|
||||
case AVATAR_FRAME_BUY = 'avatar_frame_buy';
|
||||
|
||||
/** 猜成语游戏奖励 */
|
||||
case GAME_REWARD = 'game_reward';
|
||||
|
||||
/**
|
||||
* 返回该来源的中文名称,用于后台统计展示。
|
||||
*/
|
||||
@@ -210,6 +213,7 @@ enum CurrencySource: string
|
||||
self::MSG_TEXT_COLOR_BUY => '文字颜色购买',
|
||||
self::MSG_DECORATION_BUY => '消息装扮购买(旧)',
|
||||
self::AVATAR_FRAME_BUY => '头像框购买',
|
||||
self::GAME_REWARD => '猜成语奖励',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:猜成语答题结果广播事件
|
||||
*
|
||||
* 用户答对成语时广播,通知房间内所有用户结果。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class IdiomGameAnswered implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @param int $roomId 房间 ID
|
||||
* @param int $roundId 游戏回合 ID
|
||||
* @param string $answer 正确答案
|
||||
* @param string $winnerUsername 答对的用户名
|
||||
* @param int $rewardGold 获得的金币
|
||||
* @param int $rewardExp 获得的经验
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $roomId,
|
||||
public readonly int $roundId,
|
||||
public readonly string $answer,
|
||||
public readonly string $winnerUsername,
|
||||
public readonly int $rewardGold = 0,
|
||||
public readonly int $rewardExp = 0,
|
||||
) {}
|
||||
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PresenceChannel('room.'.$this->roomId),
|
||||
];
|
||||
}
|
||||
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'round_id' => $this->roundId,
|
||||
'answer' => $this->answer,
|
||||
'winner_username' => $this->winnerUsername,
|
||||
'reward_gold' => $this->rewardGold,
|
||||
'reward_exp' => $this->rewardExp,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:猜成语游戏开始广播事件
|
||||
*
|
||||
* 管理员手动出题时触发,广播成语提示到聊天室,前端显示提示+答题按钮。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PresenceChannel;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class IdiomGameStarted implements ShouldBroadcastNow
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* @param int $roomId 房间 ID
|
||||
* @param string $hint 谜语提示
|
||||
* @param int $roundId 游戏回合 ID(前端提交答案时带上)
|
||||
* @param int $rewardGold 答对奖励金币
|
||||
* @param int $rewardExp 答对奖励经验
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $roomId,
|
||||
public readonly string $hint,
|
||||
public readonly int $roundId,
|
||||
public readonly int $rewardGold = 0,
|
||||
public readonly int $rewardExp = 0,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 广播频道
|
||||
*/
|
||||
public function broadcastOn(): array
|
||||
{
|
||||
return [
|
||||
new PresenceChannel('room.'.$this->roomId),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 广播数据
|
||||
*/
|
||||
public function broadcastWith(): array
|
||||
{
|
||||
return [
|
||||
'round_id' => $this->roundId,
|
||||
'hint' => $this->hint,
|
||||
'reward_gold' => $this->rewardGold,
|
||||
'reward_exp' => $this->rewardExp,
|
||||
'message' => "🧩 猜成语时间!{$this->hint}",
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:猜成语题库后台管理控制器
|
||||
* 提供成语题目的列表展示、创建、编辑、删除、启用/禁用功能
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Idiom;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class IdiomController extends Controller
|
||||
{
|
||||
/**
|
||||
* 显示所有成语题目列表
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
$idioms = Idiom::orderBy('sort')->orderBy('id')->get();
|
||||
|
||||
return view('admin.idioms.index', compact('idioms'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新题目
|
||||
*/
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'answer' => 'required|string|max:50',
|
||||
'hint' => 'required|string|max:255',
|
||||
'sort' => 'required|integer|min:0',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$data['is_active'] = $request->boolean('is_active', true);
|
||||
Idiom::create($data);
|
||||
|
||||
return redirect()->route('admin.idioms.index')->with('success', '成语题目已添加!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新题目
|
||||
*/
|
||||
public function update(Request $request, Idiom $idiom): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'answer' => 'required|string|max:50',
|
||||
'hint' => 'required|string|max:255',
|
||||
'sort' => 'required|integer|min:0',
|
||||
'is_active' => 'boolean',
|
||||
]);
|
||||
|
||||
$data['is_active'] = $request->boolean('is_active');
|
||||
$idiom->update($data);
|
||||
|
||||
return redirect()->route('admin.idioms.index')->with('success', "题目「{$idiom->answer}」已更新!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换启用/禁用(AJAX)
|
||||
*/
|
||||
public function toggle(Idiom $idiom): JsonResponse
|
||||
{
|
||||
$idiom->update(['is_active' => ! $idiom->is_active]);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'is_active' => $idiom->is_active,
|
||||
'message' => $idiom->is_active ? "「{$idiom->answer}」已启用" : "「{$idiom->answer}」已禁用",
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除题目
|
||||
*/
|
||||
public function destroy(Idiom $idiom): RedirectResponse
|
||||
{
|
||||
$answer = $idiom->answer;
|
||||
$idiom->delete();
|
||||
|
||||
return redirect()->route('admin.idioms.index')->with('success', "题目「{$answer}」已删除!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存猜成语游戏参数(仅更新 GameConfig params,不影响其他字段)
|
||||
*/
|
||||
public function saveSettings(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'reward_gold' => 'required|integer|min:0',
|
||||
'reward_exp' => 'required|integer|min:0',
|
||||
'auto_start_interval' => 'required|integer|min:0',
|
||||
]);
|
||||
|
||||
$config = \App\Models\GameConfig::firstOrCreate(
|
||||
['game_key' => 'idiom'],
|
||||
['name' => '猜成语', 'icon' => '🧩', 'enabled' => false],
|
||||
);
|
||||
|
||||
// 合并现有 params,只覆盖提交的字段,不影响其他已有参数
|
||||
$existingParams = $config->params ?? [];
|
||||
$config->params = array_merge($existingParams, [
|
||||
'reward_gold' => (int) $data['reward_gold'],
|
||||
'reward_exp' => (int) $data['reward_exp'],
|
||||
'auto_start_interval' => (int) $data['auto_start_interval'],
|
||||
]);
|
||||
$config->save();
|
||||
$config->clearCache();
|
||||
|
||||
return redirect()->route('admin.idioms.index')->with('success', '游戏参数已保存!');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:猜成语游戏控制器
|
||||
*
|
||||
* 负责出题、答题、查询当前回合状态等游戏核心逻辑。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Events\IdiomGameAnswered;
|
||||
use App\Events\IdiomGameStarted;
|
||||
use App\Models\GameConfig;
|
||||
use App\Models\Idiom;
|
||||
use App\Models\IdiomGameRound;
|
||||
use App\Services\ChatStateService;
|
||||
use App\Services\UserCurrencyService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class IdiomQuizController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly ChatStateService $chatState,
|
||||
private readonly UserCurrencyService $currencyService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 管理员手动出题(POST)
|
||||
*/
|
||||
public function start(Request $request): JsonResponse
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
// 权限校验:仅站长或 superlevel
|
||||
if (! $user || ($user->id !== 1 && ! $request->user()?->activePosition)) {
|
||||
return response()->json(['status' => 'error', 'message' => '无权限'], 403);
|
||||
}
|
||||
|
||||
$roomId = (int) $request->input('room_id', 0);
|
||||
if ($roomId <= 0) {
|
||||
return response()->json(['status' => 'error', 'message' => '缺少房间 ID'], 422);
|
||||
}
|
||||
|
||||
// 检查是否有进行中的回合
|
||||
$activeRound = IdiomGameRound::where('room_id', $roomId)
|
||||
->whereIn('status', ['pending', 'active'])
|
||||
->first();
|
||||
if ($activeRound) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => '当前房间已有进行中的猜成语题目,请先结束当前回合。',
|
||||
], 400);
|
||||
}
|
||||
|
||||
// 随机选一道启用的题目
|
||||
$idiom = Idiom::where('is_active', true)->inRandomOrder()->first();
|
||||
if (! $idiom) {
|
||||
return response()->json(['status' => 'error', 'message' => '题库中没有可用的题目,请先在后台添加。'], 400);
|
||||
}
|
||||
|
||||
// 读取游戏配置
|
||||
$config = GameConfig::forGame('idiom');
|
||||
$params = $config?->params ?? [];
|
||||
$rewardGold = (int) ($params['reward_gold'] ?? 50);
|
||||
$rewardExp = (int) ($params['reward_exp'] ?? 30);
|
||||
|
||||
// 创建新回合
|
||||
$round = IdiomGameRound::create([
|
||||
'room_id' => $roomId,
|
||||
'idiom_id' => $idiom->id,
|
||||
'status' => 'active',
|
||||
'reward_gold' => $rewardGold,
|
||||
'reward_exp' => $rewardExp,
|
||||
'started_at' => now(),
|
||||
]);
|
||||
|
||||
// 广播到聊天室
|
||||
broadcast(new IdiomGameStarted(
|
||||
roomId: $roomId,
|
||||
hint: $idiom->hint,
|
||||
roundId: $round->id,
|
||||
rewardGold: $rewardGold,
|
||||
rewardExp: $rewardExp,
|
||||
));
|
||||
|
||||
// 同时也推一条 MessageSent 消息(显示在聊天窗口)
|
||||
$msg = [
|
||||
'id' => $this->chatState->nextMessageId($roomId),
|
||||
'room_id' => $roomId,
|
||||
'from_user' => '星海小博士',
|
||||
'to_user' => '大家',
|
||||
'content' => "🧩 猜成语时间!{$idiom->hint}",
|
||||
'is_secret' => false,
|
||||
'font_color' => '#7c3aed',
|
||||
'action' => '',
|
||||
'idiom_game_round_id' => $round->id,
|
||||
'idiom_reward_gold' => $rewardGold,
|
||||
'idiom_reward_exp' => $rewardExp,
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
$this->chatState->pushMessage($roomId, $msg);
|
||||
broadcast(new \App\Events\MessageSent($roomId, $msg));
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'round_id' => $round->id,
|
||||
'hint' => $idiom->hint,
|
||||
'reward_gold' => $rewardGold,
|
||||
'reward_exp' => $rewardExp,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交答案(POST)
|
||||
*
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function answer(Request $request): JsonResponse
|
||||
{
|
||||
$user = Auth::user();
|
||||
if (! $user) {
|
||||
return response()->json(['status' => 'error', 'message' => '请先登录'], 401);
|
||||
}
|
||||
|
||||
$roundId = (int) $request->input('round_id');
|
||||
$userAnswer = trim((string) $request->input('answer', ''));
|
||||
$roomId = (int) $request->input('room_id');
|
||||
|
||||
if ($roundId <= 0 || $userAnswer === '' || $roomId <= 0) {
|
||||
return response()->json(['status' => 'error', 'message' => '参数不完整'], 422);
|
||||
}
|
||||
|
||||
// 查找回合
|
||||
$round = IdiomGameRound::with('idiom')->find($roundId);
|
||||
if (! $round || $round->room_id !== $roomId) {
|
||||
return response()->json(['status' => 'error', 'message' => '回合不存在'], 404);
|
||||
}
|
||||
|
||||
if ($round->status !== 'active') {
|
||||
if ($round->status === 'answered') {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => "这道题已被「{$round->winner_username}」抢先答对了!",
|
||||
], 400);
|
||||
}
|
||||
return response()->json(['status' => 'error', 'message' => '该回合已结束'], 400);
|
||||
}
|
||||
|
||||
// 校验答案(忽略空格和全半角)
|
||||
$normalizedAnswer = str_replace(' ', '', $userAnswer);
|
||||
$normalizedCorrect = str_replace(' ', '', $round->idiom->answer);
|
||||
if (mb_strtolower($normalizedAnswer) !== mb_strtolower($normalizedCorrect)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => '答案不正确,再想想!',
|
||||
], 200);
|
||||
}
|
||||
|
||||
// 答对了!加锁防并发(Redis)
|
||||
$lockKey = "idiom:answer_lock:{$roundId}";
|
||||
if (! \Illuminate\Support\Facades\Redis::setnx($lockKey, 1)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
'message' => "这道题已被「{$round->winner_username}」抢先答对了!",
|
||||
], 400);
|
||||
}
|
||||
\Illuminate\Support\Facades\Redis::expire($lockKey, 10);
|
||||
|
||||
// 更新回合状态
|
||||
$round->update([
|
||||
'status' => 'answered',
|
||||
'winner_id' => $user->id,
|
||||
'winner_username' => $user->username,
|
||||
'ended_at' => now(),
|
||||
]);
|
||||
|
||||
// 发放奖励
|
||||
if ($round->reward_gold > 0) {
|
||||
$this->currencyService->change(
|
||||
$user, 'gold', $round->reward_gold,
|
||||
\App\Enums\CurrencySource::GAME_REWARD,
|
||||
"猜成语答对「{$round->idiom->answer}」奖励",
|
||||
$roomId,
|
||||
);
|
||||
}
|
||||
if ($round->reward_exp > 0) {
|
||||
$user->exp_num = ($user->exp_num ?? 0) + $round->reward_exp;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
// 广播结果
|
||||
broadcast(new IdiomGameAnswered(
|
||||
roomId: $roomId,
|
||||
roundId: $round->id,
|
||||
answer: $round->idiom->answer,
|
||||
winnerUsername: $user->username,
|
||||
rewardGold: $round->reward_gold,
|
||||
rewardExp: $round->reward_exp,
|
||||
));
|
||||
|
||||
// 推 MessageSent 系统通知
|
||||
$resultMsg = [
|
||||
'id' => $this->chatState->nextMessageId($roomId),
|
||||
'room_id' => $roomId,
|
||||
'from_user' => '星海小博士',
|
||||
'to_user' => '大家',
|
||||
'content' => "🎉 恭喜 {$user->username} 率先答对成语「{$round->idiom->answer}」,获得 {$round->reward_gold} 金币、{$round->reward_exp} 经验!",
|
||||
'is_secret' => false,
|
||||
'font_color' => '#16a34a',
|
||||
'action' => '',
|
||||
'sent_at' => now()->toDateTimeString(),
|
||||
];
|
||||
$this->chatState->pushMessage($roomId, $resultMsg);
|
||||
broadcast(new \App\Events\MessageSent($roomId, $resultMsg));
|
||||
|
||||
\Illuminate\Support\Facades\Redis::del($lockKey);
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'message' => "🎉 回答正确!获得 {$round->reward_gold} 金币、{$round->reward_exp} 经验!",
|
||||
'data' => [
|
||||
'answer' => $round->idiom->answer,
|
||||
'reward_gold' => $round->reward_gold,
|
||||
'reward_exp' => $round->reward_exp,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前进行中的回合
|
||||
*/
|
||||
public function current(Request $request): JsonResponse
|
||||
{
|
||||
$roomId = (int) $request->input('room_id', 0);
|
||||
if ($roomId <= 0) {
|
||||
return response()->json(['status' => 'error', 'message' => '缺少房间 ID'], 422);
|
||||
}
|
||||
|
||||
$round = IdiomGameRound::with('idiom')
|
||||
->where('room_id', $roomId)
|
||||
->whereIn('status', ['pending', 'active'])
|
||||
->first();
|
||||
|
||||
if (! $round) {
|
||||
return response()->json(['status' => 'success', 'data' => null]);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'round_id' => $round->id,
|
||||
'hint' => $round->idiom?->hint ?? '',
|
||||
'reward_gold' => $round->reward_gold,
|
||||
'reward_exp' => $round->reward_exp,
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建猜成语题库表
|
||||
*
|
||||
* 存储成语题目及答案,管理员可在后台增删改。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 idioms 表。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('idioms', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('answer', 50)->comment('成语答案');
|
||||
$table->string('hint', 255)->comment('谜语线索提示');
|
||||
$table->boolean('is_active')->default(true)->comment('是否启用');
|
||||
$table->unsignedSmallInteger('sort')->default(0)->comment('排序');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('idioms');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 文件功能:创建猜成语游戏回合表
|
||||
*
|
||||
* 每次出题对应一个回合,记录答题状态、奖励和获胜者。
|
||||
*
|
||||
* @author ChatRoom Laravel
|
||||
*
|
||||
* @version 1.0.0
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* 创建 idiom_game_rounds 表。
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('idiom_game_rounds', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedBigInteger('room_id')->comment('游戏所在房间 ID');
|
||||
$table->unsignedBigInteger('idiom_id')->comment('当前题目 ID');
|
||||
$table->string('status', 20)->default('pending')->comment('状态:pending/active/answered/ended');
|
||||
$table->integer('reward_gold')->default(0)->comment('答对奖励金币');
|
||||
$table->integer('reward_exp')->default(0)->comment('答对奖励经验');
|
||||
$table->unsignedBigInteger('winner_id')->nullable()->comment('答对用户 ID');
|
||||
$table->string('winner_username', 50)->nullable()->comment('答对用户名');
|
||||
$table->timestamp('started_at')->nullable()->comment('开始答题时间');
|
||||
$table->timestamp('ended_at')->nullable()->comment('结束答题时间');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('idiom_id')->references('id')->on('idioms')->onDelete('cascade');
|
||||
$table->index('status');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 回滚迁移。
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('idiom_game_rounds');
|
||||
}
|
||||
};
|
||||
@@ -169,6 +169,20 @@ class GameConfigSeeder extends Seeder
|
||||
'super_issue_inject' => 20000, // 超级期系统注入金额上限
|
||||
],
|
||||
],
|
||||
|
||||
// ─── 猜成语 ───────────────────────────────────────────────
|
||||
[
|
||||
'game_key' => 'idiom',
|
||||
'name' => '猜成语',
|
||||
'icon' => '🧩',
|
||||
'description' => '管理员手动出题或系统定时自动出题,用户抢答成语,第一个答对的获得金币和经验奖励。',
|
||||
'enabled' => false,
|
||||
'params' => [
|
||||
'reward_gold' => 50, // 答对奖励金币
|
||||
'reward_exp' => 30, // 答对奖励经验
|
||||
'auto_start_interval' => 0, // 自动出题间隔(分钟,0=手动)
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($games as $game) {
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 猜成语题库导入脚本
|
||||
* 从 storage/data/idioms.php 导入初始数据
|
||||
*/
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Idiom;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class IdiomSeeder extends Seeder
|
||||
{
|
||||
public function run(): void
|
||||
{
|
||||
$idioms = require storage_path('data/idioms.php');
|
||||
|
||||
foreach ($idioms as $i => $item) {
|
||||
Idiom::create([
|
||||
'answer' => $item['answer'],
|
||||
'hint' => $item['hint'],
|
||||
'is_active' => true,
|
||||
'sort' => $i,
|
||||
]);
|
||||
}
|
||||
|
||||
$this->command->info('已导入 '.count($idioms).' 条成语题目。');
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,10 @@ import { bindChatInitialStateControls } from "./chat-room/initial-state.js";
|
||||
// 拍一拍模块
|
||||
import "./chat-room/pat.js";
|
||||
|
||||
// 猜成语游戏模块
|
||||
import "./chat-room/idiom-quiz.js";
|
||||
import { bindIdiomQuizControls } from "./chat-room/idiom-quiz.js";
|
||||
|
||||
// 斜杠命令菜单
|
||||
import { bindSlashCommands, registerSlashCommand } from "./chat-room/slash-commands.js";
|
||||
|
||||
@@ -778,4 +782,5 @@ if (typeof window !== "undefined") {
|
||||
bindChatBotControls();
|
||||
bindGuestbookControls();
|
||||
bindFeedbackControls();
|
||||
bindIdiomQuizControls();
|
||||
}
|
||||
|
||||
@@ -366,6 +366,41 @@ export function bindChatEvents() {
|
||||
}
|
||||
enqueueChatMessage(msg);
|
||||
|
||||
// 猜成语消息:追加【答题】按钮
|
||||
if (msg.idom_game_round_id || msg.idiom_game_round_id) {
|
||||
const roundId = msg.idom_game_round_id || msg.idiom_game_round_id;
|
||||
const hint = msg.content || "";
|
||||
const rewardGold = msg.idiom_reward_gold || 0;
|
||||
const rewardExp = msg.idiom_reward_exp || 0;
|
||||
|
||||
// 延迟等消息渲染完成再追加按钮
|
||||
setTimeout(() => {
|
||||
const containers = [
|
||||
document.getElementById("chat-messages-container"),
|
||||
document.getElementById("chat-messages-container2"),
|
||||
];
|
||||
containers.forEach((container) => {
|
||||
if (!container) return;
|
||||
const lastMsg = container.lastElementChild;
|
||||
if (!lastMsg || lastMsg.querySelector("[data-idiom-answer-btn]")) return;
|
||||
if (lastMsg.dataset.fromUser !== "星海小博士") return;
|
||||
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.dataset.idiomAnswerBtn = String(roundId);
|
||||
btn.dataset.idiomHint = hint;
|
||||
btn.dataset.idiomGold = String(rewardGold);
|
||||
btn.dataset.idiomExp = String(rewardExp);
|
||||
btn.textContent = "🎯 答题";
|
||||
btn.style.cssText =
|
||||
"margin-left:8px;padding:2px 12px;background:linear-gradient(135deg,#7c3aed,#a78bfa);" +
|
||||
"color:#fff;border:none;border-radius:999px;font-size:11px;cursor:pointer;" +
|
||||
"font-weight:bold;vertical-align:middle;";
|
||||
lastMsg.appendChild(btn);
|
||||
});
|
||||
}, 50);
|
||||
}
|
||||
|
||||
if (msg.action === "vip_presence" && typeof window.showVipPresenceBanner === "function") {
|
||||
window.showVipPresenceBanner(msg);
|
||||
}
|
||||
@@ -470,6 +505,20 @@ export function bindChatEvents() {
|
||||
}
|
||||
});
|
||||
|
||||
// chat:idiom-started — 猜成语出题
|
||||
window.addEventListener("chat:idiom-started", (e) => {
|
||||
if (typeof window.handleIdiomGameStarted === "function") {
|
||||
window.handleIdiomGameStarted(e);
|
||||
}
|
||||
});
|
||||
|
||||
// chat:idiom-answered — 猜成语答题结果
|
||||
window.addEventListener("chat:idiom-answered", (e) => {
|
||||
if (typeof window.handleIdiomGameAnswered === "function") {
|
||||
window.handleIdiomGameAnswered(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Echo 级监听器(延迟绑定,等待 Echo 就绪)
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
setupScreenClearedListener();
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
// 猜成语游戏前端模块
|
||||
// 监听 IdiomGameStarted / IdiomGameAnswered 事件,提供答题弹窗功能
|
||||
|
||||
function csrf() {
|
||||
return document.querySelector('meta[name="csrf-token"]')?.content ?? "";
|
||||
}
|
||||
|
||||
let currentRoundId = 0;
|
||||
let currentRoomId = 0;
|
||||
|
||||
/**
|
||||
* 收到猜成语出题事件时,在聊天窗口显示提示消息。
|
||||
*/
|
||||
function handleIdiomGameStarted(e) {
|
||||
const { round_id, hint, reward_gold, reward_exp, message } = e.detail || {};
|
||||
if (!round_id || !hint) return;
|
||||
|
||||
currentRoundId = round_id;
|
||||
currentRoomId = window.chatContext?.roomId || 0;
|
||||
|
||||
// 追加一条聊天室消息(由 MessageSent 事件负责渲染,不重复添加)
|
||||
// 这里只存储当前回合信息
|
||||
console.log(`猜成语开始:${hint},奖励 ${reward_gold}金/${reward_exp}经验`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 收到猜成语结果事件。
|
||||
*/
|
||||
function handleIdiomGameAnswered(e) {
|
||||
const { answer, winner_username, reward_gold, reward_exp } = e.detail || {};
|
||||
if (!answer) return;
|
||||
|
||||
currentRoundId = 0;
|
||||
|
||||
// 如果当前用户打开答题弹窗但被别人抢先了,关闭弹窗
|
||||
const answerModal = document.getElementById("idiom-answer-modal");
|
||||
if (answerModal && answerModal.style.display !== "none") {
|
||||
answerModal.style.display = "none";
|
||||
window.chatToast?.show({
|
||||
title: "被抢先了",
|
||||
message: `${winner_username} 率先答对了「${answer}」,下次加油!`,
|
||||
icon: "😅",
|
||||
color: "#f59e0b",
|
||||
duration: 4000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开答题弹窗。
|
||||
*/
|
||||
function openIdiomAnswerModal(roundId, hint, rewardGold, rewardExp) {
|
||||
currentRoundId = roundId;
|
||||
currentRoomId = window.chatContext?.roomId || 0;
|
||||
|
||||
const modal = document.getElementById("idiom-answer-modal");
|
||||
if (!modal) return;
|
||||
|
||||
const hintEl = document.getElementById("idiom-answer-hint");
|
||||
const rewardEl = document.getElementById("idiom-answer-reward");
|
||||
if (hintEl) hintEl.textContent = hint;
|
||||
if (rewardEl) rewardEl.textContent = `🎁 答对奖励:${rewardGold} 金币 + ${rewardExp} 经验`;
|
||||
|
||||
modal.style.display = "flex";
|
||||
|
||||
const input = document.getElementById("idiom-answer-input");
|
||||
if (input) {
|
||||
input.value = "";
|
||||
input.focus();
|
||||
input.disabled = false;
|
||||
}
|
||||
|
||||
const submitBtn = document.getElementById("idiom-answer-submit");
|
||||
if (submitBtn) {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = "提交答案";
|
||||
}
|
||||
|
||||
const feedbackEl = document.getElementById("idiom-answer-feedback");
|
||||
if (feedbackEl) feedbackEl.textContent = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭答题弹窗。
|
||||
*/
|
||||
function closeIdiomAnswerModal() {
|
||||
const modal = document.getElementById("idiom-answer-modal");
|
||||
if (modal) modal.style.display = "none";
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交答案。
|
||||
*/
|
||||
async function submitIdiomAnswer() {
|
||||
const input = document.getElementById("idiom-answer-input");
|
||||
const feedbackEl = document.getElementById("idiom-answer-feedback");
|
||||
const submitBtn = document.getElementById("idiom-answer-submit");
|
||||
|
||||
if (!input || !feedbackEl || !submitBtn) return;
|
||||
|
||||
const answer = input.value.trim();
|
||||
if (!answer) {
|
||||
feedbackEl.textContent = "请输入成语答案";
|
||||
feedbackEl.style.color = "#ef4444";
|
||||
return;
|
||||
}
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.textContent = "提交中...";
|
||||
|
||||
try {
|
||||
const response = await fetch("/idiom-quiz/answer", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-CSRF-TOKEN": csrf(),
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
round_id: currentRoundId,
|
||||
answer: answer,
|
||||
room_id: currentRoomId,
|
||||
}),
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.status === "success") {
|
||||
feedbackEl.textContent = data.message || "🎉 回答正确!";
|
||||
feedbackEl.style.color = "#16a34a";
|
||||
input.disabled = true;
|
||||
|
||||
// 延迟关闭弹窗
|
||||
setTimeout(() => {
|
||||
closeIdiomAnswerModal();
|
||||
}, 2000);
|
||||
} else {
|
||||
feedbackEl.textContent = data.message || "答案不正确";
|
||||
feedbackEl.style.color = "#ef4444";
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = "提交答案";
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
} catch (error) {
|
||||
feedbackEl.textContent = "网络错误,请稍后重试";
|
||||
feedbackEl.style.color = "#ef4444";
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.textContent = "提交答案";
|
||||
}
|
||||
}
|
||||
|
||||
// ── 事件绑定 ──
|
||||
|
||||
export function bindIdiomQuizControls() {
|
||||
// 已经绑定的不再重复绑定
|
||||
if (document.getElementById("idiom-answer-modal")?.dataset?.idiomBound) return;
|
||||
const modal = document.getElementById("idiom-answer-modal");
|
||||
if (modal) modal.dataset.idiomBound = "1";
|
||||
|
||||
// 关闭按钮
|
||||
document.addEventListener("click", (e) => {
|
||||
const closeBtn = e.target.closest("[data-idiom-answer-close]");
|
||||
if (closeBtn) {
|
||||
closeIdiomAnswerModal();
|
||||
return;
|
||||
}
|
||||
|
||||
// 点击遮罩层关闭
|
||||
const overlay = e.target.closest("#idiom-answer-modal");
|
||||
if (overlay && e.target === overlay) {
|
||||
closeIdiomAnswerModal();
|
||||
}
|
||||
});
|
||||
|
||||
// 提交按钮
|
||||
document.addEventListener("click", (e) => {
|
||||
const submitBtn = e.target.closest("[data-idiom-answer-submit]");
|
||||
if (submitBtn) {
|
||||
e.preventDefault();
|
||||
submitIdiomAnswer();
|
||||
}
|
||||
});
|
||||
|
||||
// 输入框 Enter 提交
|
||||
document.addEventListener("keydown", (e) => {
|
||||
const input = e.target.closest("#idiom-answer-input");
|
||||
if (input && e.key === "Enter" && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
submitIdiomAnswer();
|
||||
}
|
||||
});
|
||||
|
||||
// 聊天消息中的【答题】按钮点击
|
||||
document.addEventListener("click", (e) => {
|
||||
const btn = e.target.closest("[data-idiom-answer-btn]");
|
||||
if (!btn) return;
|
||||
|
||||
const roundId = parseInt(btn.dataset.idiomAnswerBtn || "0", 10);
|
||||
const hint = btn.dataset.idiomHint || "";
|
||||
const rewardGold = parseInt(btn.dataset.idiomGold || "0", 10);
|
||||
const rewardExp = parseInt(btn.dataset.idiomExp || "0", 10);
|
||||
|
||||
if (roundId > 0) {
|
||||
openIdiomAnswerModal(roundId, hint, rewardGold, rewardExp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ── 挂载到 window ──
|
||||
window.openIdiomAnswerModal = openIdiomAnswerModal;
|
||||
window.closeIdiomAnswerModal = closeIdiomAnswerModal;
|
||||
window.submitIdiomAnswer = submitIdiomAnswer;
|
||||
window.handleIdiomGameStarted = handleIdiomGameStarted;
|
||||
window.handleIdiomGameAnswered = handleIdiomGameAnswered;
|
||||
@@ -269,6 +269,16 @@ export function initChat(roomId) {
|
||||
console.log("拍一拍:", e);
|
||||
window.dispatchEvent(new CustomEvent("chat:pat", { detail: e }));
|
||||
})
|
||||
// 监听猜成语出题
|
||||
.listen("IdiomGameStarted", (e) => {
|
||||
console.log("猜成语:", e);
|
||||
window.dispatchEvent(new CustomEvent("chat:idiom-started", { detail: e }));
|
||||
})
|
||||
// 监听猜成语答题结果
|
||||
.listen("IdiomGameAnswered", (e) => {
|
||||
console.log("猜成语结果:", e);
|
||||
window.dispatchEvent(new CustomEvent("chat:idiom-answered", { detail: e }));
|
||||
})
|
||||
// 监听任命公告(礼花 + 隆重弹窗)
|
||||
.listen("AppointmentAnnounced", (e) => {
|
||||
console.log("任命公告:", e);
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
@extends('admin.layouts.app')
|
||||
|
||||
@section('title', '猜成语题库管理')
|
||||
|
||||
@section('content')
|
||||
@php require resource_path('views/admin/partials/list-theme.php'); @endphp
|
||||
|
||||
@php
|
||||
$idiomPayload = $idioms->mapWithKeys(
|
||||
fn($item) => [
|
||||
(string) $item->id => [
|
||||
'id' => $item->id,
|
||||
'answer' => $item->answer,
|
||||
'hint' => $item->hint,
|
||||
'sort' => $item->sort,
|
||||
'is_active' => (bool) $item->is_active,
|
||||
'update_url' => route('admin.idioms.update', $item->id),
|
||||
'toggle_url' => route('admin.idioms.toggle', $item->id),
|
||||
],
|
||||
],
|
||||
);
|
||||
|
||||
$idiomConfig = \App\Models\GameConfig::forGame('idiom');
|
||||
$idiomParams = $idiomConfig?->params ?? [];
|
||||
@endphp
|
||||
|
||||
<script type="application/json" id="admin-idioms-data">@json($idiomPayload)</script>
|
||||
|
||||
<div class="{{ $adminListPageClass }}">
|
||||
|
||||
{{-- 页头 --}}
|
||||
<div class="{{ $adminListHeaderCardClass }}">
|
||||
<div>
|
||||
<h2 class="{{ $adminListHeaderTitleClass }}">🧩 猜成语题库管理</h2>
|
||||
<p class="{{ $adminListHeaderSubtitleClass }}">
|
||||
管理猜成语游戏的题目库,共 <strong class="text-indigo-600">{{ $idioms->count() }}</strong> 条题目
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 游戏参数 + 出题 --}}
|
||||
<div class="{{ $adminListCardClass }}">
|
||||
<div class="{{ $adminListSectionHeadClass }}">
|
||||
<h3 class="{{ $adminListSectionTitleClass }}">⚙️ 游戏参数</h3>
|
||||
</div>
|
||||
<form action="{{ route('admin.idioms.settings.save') }}" method="POST" class="p-5">
|
||||
@csrf
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label class="{{ $adminListFilterLabelClass }}">答对奖励金币</label>
|
||||
<input type="number" name="reward_gold"
|
||||
value="{{ old('reward_gold', $idiomParams['reward_gold'] ?? 50) }}" min="0"
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
</div>
|
||||
<div>
|
||||
<label class="{{ $adminListFilterLabelClass }}">答对奖励经验</label>
|
||||
<input type="number" name="reward_exp"
|
||||
value="{{ old('reward_exp', $idiomParams['reward_exp'] ?? 30) }}" min="0"
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
</div>
|
||||
<div>
|
||||
<label class="{{ $adminListFilterLabelClass }}">自动出题间隔(分钟)</label>
|
||||
<input type="number" name="auto_start_interval"
|
||||
value="{{ old('auto_start_interval', $idiomParams['auto_start_interval'] ?? 0) }}" min="0"
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
<p class="text-xs text-gray-400 mt-1">0=仅手动出题</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex items-center gap-4">
|
||||
<button type="submit" class="{{ $adminListPrimaryButtonClass }}">
|
||||
💾 保存参数
|
||||
</button>
|
||||
<span class="text-sm text-gray-400">|</span>
|
||||
<label class="text-sm text-gray-600">选择房间:</label>
|
||||
<select id="idiom-start-room" class="border border-gray-300 rounded-lg px-3 py-1.5 text-sm">
|
||||
@foreach (\App\Models\Room::orderBy('id')->get() as $room)
|
||||
<option value="{{ $room->id }}">{{ $room->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<button type="button" id="idiom-start-btn"
|
||||
class="inline-flex items-center gap-1.5 px-4 py-2 bg-gradient-to-r from-purple-600 to-indigo-600 text-white text-sm font-bold rounded-lg hover:opacity-90 transition">
|
||||
🧩 出题
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{-- 题目列表 --}}
|
||||
<div class="{{ $adminListCardClass }}">
|
||||
<div class="{{ $adminListTableWrapClass }}">
|
||||
<table class="{{ $adminListTableClass }}">
|
||||
<thead class="{{ $adminListTableHeadRowClass }}">
|
||||
<tr>
|
||||
<th class="{{ $adminListTableHeadCellClass }}">排序</th>
|
||||
<th class="{{ $adminListTableHeadCellClass }}">成语答案</th>
|
||||
<th class="{{ $adminListTableHeadCellClass }} w-2/5">谜语提示</th>
|
||||
<th class="{{ $adminListTableHeadCellClass }} text-center">状态</th>
|
||||
<th class="{{ $adminListTableHeadCellClass }} text-right">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="{{ $adminListTableBodyClass }}">
|
||||
@foreach ($idioms as $item)
|
||||
<tr id="row-{{ $item->id }}" class="{{ $adminListTableRowClass }} {{ $item->is_active ? '' : 'opacity-50' }}">
|
||||
<td class="px-4 py-3 {{ $adminListSecondaryTextClass }}">{{ $item->sort }}</td>
|
||||
<td class="px-4 py-3 font-bold {{ $adminListPrimaryTextClass }}">{{ $item->answer }}</td>
|
||||
<td class="px-4 py-3 {{ $adminListBodyTextClass }} text-sm">{{ $item->hint }}</td>
|
||||
<td class="px-4 py-3 text-center">
|
||||
<button type="button" data-idiom-toggle-id="{{ $item->id }}"
|
||||
id="toggle-{{ $item->id }}"
|
||||
class="{{ $adminListBadgeBaseClass }} px-2 py-1 transition
|
||||
{{ $item->is_active ? 'border-emerald-200 bg-emerald-100 text-emerald-700 hover:bg-emerald-200' : 'border-gray-200 bg-gray-100 text-gray-500 hover:bg-gray-200' }}">
|
||||
{{ $item->is_active ? '启用' : '禁用' }}
|
||||
</button>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<button type="button" data-idiom-edit-id="{{ $item->id }}"
|
||||
class="{{ $adminListActionButtonClass }} bg-indigo-50 text-indigo-700 hover:bg-indigo-100 mr-1">
|
||||
编辑
|
||||
</button>
|
||||
<form action="{{ route('admin.idioms.destroy', $item->id) }}" method="POST"
|
||||
class="inline" data-idiom-delete-confirm="确定删除题目「{{ $item->answer }}」?">
|
||||
@csrf @method('DELETE')
|
||||
<button type="submit"
|
||||
class="{{ $adminListActionButtonClass }} bg-red-50 text-red-600 hover:bg-red-100">
|
||||
删除
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- 新增题目卡片 --}}
|
||||
<div class="{{ $adminListCardClass }}">
|
||||
<div class="{{ $adminListSectionHeadClass }}">
|
||||
<h3 class="{{ $adminListSectionTitleClass }}">➕ 新增成语题目</h3>
|
||||
</div>
|
||||
<form action="{{ route('admin.idioms.store') }}" method="POST" class="p-5">
|
||||
@csrf
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="{{ $adminListFilterLabelClass }}">成语答案</label>
|
||||
<input type="text" name="answer" value="{{ old('answer') }}" placeholder="画蛇添足" required
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
</div>
|
||||
<div>
|
||||
<label class="{{ $adminListFilterLabelClass }}">排序</label>
|
||||
<input type="number" name="sort" value="{{ old('sort', 0) }}" min="0"
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="{{ $adminListFilterLabelClass }}">谜语提示</label>
|
||||
<input type="text" name="hint" value="{{ old('hint') }}" placeholder="🧩 四人比赛画蛇,最慢的那个反而多此一举。猜一成语" required
|
||||
class="w-full {{ $adminListFilterInputClass }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-4 flex items-center gap-4">
|
||||
<button type="submit" class="{{ $adminListPrimaryButtonClass }}">
|
||||
💾 添加题目
|
||||
</button>
|
||||
<label class="flex items-center gap-2 text-sm text-gray-600 cursor-pointer">
|
||||
<input type="checkbox" name="is_active" value="1" checked class="rounded">
|
||||
立即启用
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{-- 编辑弹窗 --}}
|
||||
<div id="edit-modal" class="hidden fixed inset-0 bg-black/40 z-50 flex items-center justify-center p-4">
|
||||
<div class="bg-white rounded-xl w-full max-w-lg shadow-2xl">
|
||||
<div class="p-5 border-b border-gray-100 flex justify-between items-center">
|
||||
<h3 class="font-bold text-gray-800">✏️ 编辑成语题目</h3>
|
||||
<button type="button" data-idiom-edit-close class="text-gray-400 hover:text-gray-600 text-xl">✕</button>
|
||||
</div>
|
||||
<form id="edit-form" method="POST" class="p-5">
|
||||
@csrf @method('PUT')
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">成语答案</label>
|
||||
<input type="text" name="answer" id="edit-answer" required
|
||||
class="w-full border border-gray-300 rounded-lg p-2 text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">排序</label>
|
||||
<input type="number" name="sort" id="edit-sort" min="0"
|
||||
class="w-full border border-gray-300 rounded-lg p-2 text-sm">
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-xs font-bold text-gray-600 mb-1">谜语提示</label>
|
||||
<input type="text" name="hint" id="edit-hint" required
|
||||
class="w-full border border-gray-300 rounded-lg p-2 text-sm">
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="flex items-center gap-2 text-sm cursor-pointer">
|
||||
<input type="checkbox" name="is_active" id="edit-is-active" value="1" class="rounded">
|
||||
启用此题目
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-5 flex gap-3">
|
||||
<button type="submit" class="{{ $adminListPrimaryButtonClass }}">
|
||||
💾 保存修改
|
||||
</button>
|
||||
<button type="button" data-idiom-edit-close
|
||||
class="{{ $adminListSecondaryButtonClass }}">
|
||||
取消
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
{{-- 前端编辑/切换交互脚本 --}}
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const idiomsDataEl = document.getElementById('admin-idioms-data');
|
||||
if (!idiomsDataEl) return;
|
||||
const idiomsData = JSON.parse(idiomsDataEl.textContent || '{}');
|
||||
|
||||
// ── 打开编辑弹窗 ──
|
||||
document.querySelectorAll('[data-idiom-edit-id]').forEach(btn => {
|
||||
btn.addEventListener('click', function () {
|
||||
const id = this.dataset.idiomEditId;
|
||||
const data = idiomsData[id];
|
||||
if (!data) return;
|
||||
|
||||
document.getElementById('edit-answer').value = data.answer;
|
||||
document.getElementById('edit-hint').value = data.hint;
|
||||
document.getElementById('edit-sort').value = data.sort;
|
||||
document.getElementById('edit-is-active').checked = data.is_active;
|
||||
document.getElementById('edit-form').action = data.update_url;
|
||||
document.getElementById('edit-modal').classList.remove('hidden');
|
||||
});
|
||||
});
|
||||
|
||||
// ── 关闭编辑弹窗 ──
|
||||
document.querySelectorAll('[data-idiom-edit-close]').forEach(btn => {
|
||||
btn.addEventListener('click', function () {
|
||||
document.getElementById('edit-modal').classList.add('hidden');
|
||||
});
|
||||
});
|
||||
|
||||
// ── 切换启用/禁用(AJAX) ──
|
||||
document.querySelectorAll('[data-idiom-toggle-id]').forEach(btn => {
|
||||
btn.addEventListener('click', function () {
|
||||
const id = this.dataset.idiomToggleId;
|
||||
const data = idiomsData[id];
|
||||
if (!data) return;
|
||||
|
||||
fetch(data.toggle_url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content ?? '',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(res => {
|
||||
if (res.ok) {
|
||||
const row = document.getElementById('row-' + id);
|
||||
if (row) row.style.opacity = res.is_active ? '1' : '0.5';
|
||||
const btn = document.getElementById('toggle-' + id);
|
||||
if (btn) {
|
||||
btn.textContent = res.is_active ? '启用' : '禁用';
|
||||
btn.className = (res.is_active
|
||||
? 'border-emerald-200 bg-emerald-100 text-emerald-700 hover:bg-emerald-200'
|
||||
: 'border-gray-200 bg-gray-100 text-gray-500 hover:bg-gray-200')
|
||||
+ ' px-2 py-1 transition rounded-full text-xs font-semibold border';
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => alert('操作失败'));
|
||||
});
|
||||
});
|
||||
|
||||
// ── 删除确认 ──
|
||||
document.querySelectorAll('[data-idiom-delete-confirm]').forEach(form => {
|
||||
form.addEventListener('submit', function (e) {
|
||||
if (!confirm(this.dataset.idiomDeleteConfirm)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ── 出题按钮 ──
|
||||
const startBtn = document.getElementById('idiom-start-btn');
|
||||
if (startBtn) {
|
||||
startBtn.addEventListener('click', function () {
|
||||
const roomSelect = document.getElementById('idiom-start-room');
|
||||
const roomId = roomSelect?.value;
|
||||
if (!roomId) return;
|
||||
|
||||
const btn = this;
|
||||
btn.disabled = true;
|
||||
btn.textContent = '出题中...';
|
||||
|
||||
fetch('/idiom-quiz/start', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content ?? '',
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ room_id: parseInt(roomId, 10) }),
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (data.status === 'success') {
|
||||
alert('✅ 出题成功!提示已发送到聊天室。');
|
||||
} else {
|
||||
alert(data.message || '出题失败');
|
||||
}
|
||||
})
|
||||
.catch(() => alert('网络错误,出题失败'))
|
||||
.finally(() => {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '🧩 出题';
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
@@ -98,7 +98,11 @@
|
||||
</a>
|
||||
<a href="{{ route('admin.fishing.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.fishing.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
{!! '🎣 钓鱼事件' !!}
|
||||
🎣 钓鱼事件
|
||||
</a>
|
||||
<a href="{{ route('admin.idioms.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.idioms.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
🧩 猜成语题库
|
||||
</a>
|
||||
<a href="{{ route('admin.departments.index') }}"
|
||||
class="block px-4 py-3 rounded-md transition {{ request()->routeIs('admin.departments.*') ? 'bg-indigo-600 font-bold' : 'hover:bg-white/10' }}">
|
||||
|
||||
@@ -252,6 +252,34 @@
|
||||
@include('chat.partials.system-events')
|
||||
{{-- 初始历史消息、入场欢迎、进场特效、会员横幅和挂起婚姻事件已迁移到 resources/js/chat-room/initial-state.js --}}
|
||||
|
||||
{{-- 猜成语答题弹窗 --}}
|
||||
<div id="idiom-answer-modal"
|
||||
style="display:none;position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:99999;justify-content:center;align-items:center;backdrop-filter:blur(3px);">
|
||||
<div style="background:#fff;border-radius:16px;width:min(90vw,460px);box-shadow:0 24px 64px rgba(0,0,0,.22);overflow:hidden;animation:gdSlideIn .2s ease;">
|
||||
<div style="padding:18px 22px;background:linear-gradient(135deg,#7c3aed,#a78bfa);color:#fff;">
|
||||
<div style="font-size:18px;font-weight:bold;">🧩 猜成语</div>
|
||||
<div id="idiom-answer-reward" style="font-size:12px;margin-top:4px;opacity:.9;"></div>
|
||||
</div>
|
||||
<div style="padding:20px 22px;">
|
||||
<p id="idiom-answer-hint" style="font-size:15px;color:#1e293b;line-height:1.7;margin-bottom:16px;"></p>
|
||||
<input id="idiom-answer-input" type="text" autocomplete="off" placeholder="输入成语答案..."
|
||||
style="width:100%;box-sizing:border-box;padding:12px 14px;border:2px solid #e5e7eb;border-radius:10px;font-size:15px;outline:none;transition:border-color .2s;"
|
||||
onfocus="this.style.borderColor='#7c3aed'" onblur="this.style.borderColor='#e5e7eb'">
|
||||
<p id="idiom-answer-feedback" style="margin-top:8px;font-size:13px;min-height:20px;"></p>
|
||||
</div>
|
||||
<div style="padding:0 22px 18px;display:flex;gap:10px;">
|
||||
<button type="button" data-idiom-answer-close
|
||||
style="flex:1;padding:11px;background:#f3f4f6;color:#555;border:none;border-radius:10px;font-size:14px;cursor:pointer;font-weight:bold;">
|
||||
取消
|
||||
</button>
|
||||
<button type="button" data-idiom-answer-submit id="idiom-answer-submit"
|
||||
style="flex:1;padding:11px;background:linear-gradient(135deg,#7c3aed,#a78bfa);color:#fff;border:none;border-radius:10px;font-size:14px;cursor:pointer;font-weight:bold;">
|
||||
提交答案
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -274,6 +274,7 @@ Route::middleware(['chat.auth'])->group(function () {
|
||||
'fishing' => \App\Models\GameConfig::isEnabled('fishing'),
|
||||
'lottery' => \App\Models\GameConfig::isEnabled('lottery'),
|
||||
'gomoku' => \App\Models\GameConfig::isEnabled('gomoku'),
|
||||
'idiom' => \App\Models\GameConfig::isEnabled('idiom'),
|
||||
]);
|
||||
})->name('games.enabled');
|
||||
|
||||
@@ -291,6 +292,13 @@ Route::middleware(['chat.auth'])->group(function () {
|
||||
->middleware('throttle:chat-send')
|
||||
->name('chat.pat');
|
||||
|
||||
// 猜成语游戏
|
||||
Route::prefix('idiom-quiz')->name('idiom-quiz.')->group(function () {
|
||||
Route::post('/start', [\App\Http\Controllers\IdiomQuizController::class, 'start'])->name('start');
|
||||
Route::post('/answer', [\App\Http\Controllers\IdiomQuizController::class, 'answer'])->name('answer');
|
||||
Route::get('/current', [\App\Http\Controllers\IdiomQuizController::class, 'current'])->name('current');
|
||||
});
|
||||
|
||||
// 挂机心跳存点 (限制每分钟最多调用 6 次防止挂机脚本滥用)
|
||||
Route::post('/room/{id}/heartbeat', [ChatController::class, 'heartbeat'])
|
||||
->middleware('throttle:6,1')
|
||||
@@ -581,6 +589,16 @@ Route::middleware(['chat.auth', 'chat.has_position'])->prefix('admin')->name('ad
|
||||
Route::post('/{fishing}/toggle', [\App\Http\Controllers\Admin\FishingEventController::class, 'toggle'])->name('toggle');
|
||||
Route::delete('/{fishing}', [\App\Http\Controllers\Admin\FishingEventController::class, 'destroy'])->name('destroy');
|
||||
});
|
||||
|
||||
// ── 猜成语题库 ──
|
||||
Route::prefix('idioms')->name('idioms.')->group(function () {
|
||||
Route::get('/', [\App\Http\Controllers\Admin\IdiomController::class, 'index'])->name('index');
|
||||
Route::post('/', [\App\Http\Controllers\Admin\IdiomController::class, 'store'])->name('store');
|
||||
Route::put('/{idiom}', [\App\Http\Controllers\Admin\IdiomController::class, 'update'])->name('update');
|
||||
Route::post('/{idiom}/toggle', [\App\Http\Controllers\Admin\IdiomController::class, 'toggle'])->name('toggle');
|
||||
Route::delete('/{idiom}', [\App\Http\Controllers\Admin\IdiomController::class, 'destroy'])->name('destroy');
|
||||
Route::post('/settings', [\App\Http\Controllers\Admin\IdiomController::class, 'saveSettings'])->name('settings.save');
|
||||
});
|
||||
});
|
||||
|
||||
// ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// 猜成语题库 - 谜语式线索(不直接描述成语含义)
|
||||
// 需要玩家开动脑筋联想
|
||||
|
||||
return [
|
||||
['answer' => '画蛇添足', 'hint' => '🧩 四人比赛画蛇,最慢的那个反而多此一举。猜一成语'],
|
||||
['answer' => '守株待兔', 'hint' => '🧩 农夫不干活,天天蹲树桩旁等天上掉馅饼。猜一成语'],
|
||||
['answer' => '掩耳盗铃', 'hint' => '🧩 小偷以为捂住自己耳朵,别人就听不见铃铛响了。猜一成语'],
|
||||
['answer' => '亡羊补牢', 'hint' => '🧩 羊圈破了个洞,羊跑了几只才想起修。猜一成语'],
|
||||
['answer' => '刻舟求剑', 'hint' => '🧩 船上做了个记号就能在江里找回剑?猜一成语'],
|
||||
['answer' => '叶公好龙', 'hint' => '🧩 家里到处画龙雕龙,真龙来了却吓得屁滚尿流。猜一成语'],
|
||||
['answer' => '狐假虎威', 'hint' => '🧩 狐狸走在老虎前面,小动物们到底怕谁?猜一成语'],
|
||||
['answer' => '井底之蛙', 'hint' => '🧩 住在井里,却以为天空只有井口那么大。猜一成语'],
|
||||
['answer' => '对牛弹琴', 'hint' => '🧩 弹了一首好曲子,听众却在低头吃草。猜一成语'],
|
||||
['answer' => '杯弓蛇影', 'hint' => '🧩 酒杯里有个弯弯曲曲的东西在动,吓得大病一场。猜一成语'],
|
||||
['answer' => '鹤立鸡群', 'hint' => '🧩 一只长腿白鸟混进了院子里的小黄鸡中。猜一成语'],
|
||||
['answer' => '画龙点睛', 'hint' => '🧩 最后两笔点上后,墙上的龙竟然飞走了。猜一成语'],
|
||||
['answer' => '鸡飞蛋打', 'hint' => '🧩 偷鸡不成,竹篮打水一场空。猜一成语'],
|
||||
['answer' => '马到成功', 'hint' => '🧩 战旗一挥,马蹄刚踏出去就赢了。猜一成语'],
|
||||
['answer' => '虎头蛇尾', 'hint' => '🧩 开头气势如虹,结尾却草草收场。猜一成语'],
|
||||
['answer' => '龙飞凤舞', 'hint' => '🧩 王羲之喝醉了,笔下的字好像要飞起来。猜一成语'],
|
||||
['answer' => '鸡犬不宁', 'hint' => '🧩 闹得天翻地覆,连院子里的小动物都不得安生。猜一成语'],
|
||||
['answer' => '狼吞虎咽', 'hint' => '🧩 饿了三天的壮汉看到一碗面。猜一成语'],
|
||||
['answer' => '鱼目混珠', 'hint' => '🧩 地摊上有人拿玻璃球当夜明珠卖。猜一成语'],
|
||||
['answer' => '鼠目寸光', 'hint' => '🧩 只看得到眼前一寸的路,走远就迷路。猜一成语'],
|
||||
['answer' => '九牛一毛', 'hint' => '🧩 亿万富翁丢了一分钱,连弯腰捡都懒得捡。猜一成语'],
|
||||
['answer' => '如鱼得水', 'hint' => '🧩 刘备说:有了诸葛亮,就像什么回到了什么里?猜一成语'],
|
||||
['answer' => '鸟语花香', 'hint' => '🧩 春天来了,你能听到什么、闻到什么?猜一成语'],
|
||||
['answer' => '风花雪月', 'hint' => '🧩 才子佳人写的诗,看起来很美,其实没什么实际内容。猜一成语'],
|
||||
['answer' => '山清水秀', 'hint' => '🧩 桂林漓江边上,你能看到什么颜色?猜一成语'],
|
||||
['answer' => '水落石出', 'hint' => '🧩 水位下降后,河床下的东西藏不住了。猜一成语'],
|
||||
['answer' => '火中取栗', 'hint' => '🧩 猫爪子被烫伤了,猴子却在旁边偷笑吃栗子。猜一成语'],
|
||||
['answer' => '石破天惊', 'hint' => '🧩 一块石头裂开,伴随着一声巨响,所有人都惊呆了。猜一成语'],
|
||||
['answer' => '翻天覆地', 'hint' => '🧩 孙悟空大闹天宫后,凌霄宝殿变成了什么样?猜一成语'],
|
||||
['answer' => '开天辟地', 'hint' => '🧩 盘古拿着斧头,对着混沌用力一劈。猜一成语'],
|
||||
['answer' => '惊天动地', 'hint' => '🧩 汶川大地震那天,连天上的云都在颤抖。猜一成语'],
|
||||
['answer' => '花好月圆', 'hint' => '🧩 婚礼请柬上最常见的四个字祝福。猜一成语'],
|
||||
['answer' => '冰清玉洁', 'hint' => '🧩 她的品格像冬天的什么和深山里的什么?猜一成语'],
|
||||
['answer' => '海阔天空', 'hint' => '🧩 走出小县城,来到大都市,才发现世界有多大。猜一成语'],
|
||||
['answer' => '雪中送炭', 'hint' => '🧩 大冬天你最需要什么?有人偏偏就送来了什么。猜一成语'],
|
||||
['answer' => '锦上添花', 'hint' => '🧩 已经够漂亮了,还要再点缀一下。猜一成语'],
|
||||
['answer' => '落井下石', 'hint' => '🧩 有人掉坑里了,你不救也就算了,还往下面扔砖头。猜一成语'],
|
||||
['answer' => '纸上谈兵', 'hint' => '🧩 赵括说起兵法头头是道,上了战场却一败涂地。猜一成语'],
|
||||
['answer' => '胸有成竹', 'hint' => '🧩 画家文同还没下笔,心里已经有了完整的竹子。猜一成语'],
|
||||
['answer' => '一帆风顺', 'hint' => '🧩 出海前最想听到的一句祝福。猜一成语'],
|
||||
['answer' => '水到渠成', 'hint' => '🧩 不用刻意挖渠,水自然会找到它的路。猜一成语'],
|
||||
['answer' => '百发百中', 'hint' => '🧩 养由基站在百步之外射柳叶,箭无虚发。猜一成语'],
|
||||
['answer' => '一鸣惊人', 'hint' => '🧩 齐威王三年不上朝不理政,一出手就震惊了各国。猜一成语'],
|
||||
['answer' => '对答如流', 'hint' => '🧩 老师提问,他不用思考就说出答案,像江水一样不停。猜一成语'],
|
||||
['answer' => '顺手牵羊', 'hint' => '🧩 路过别人家门口,看到一只羊没人看管……猜一成语'],
|
||||
['answer' => '勇往直前', 'hint' => '🧩 前面是刀山火海,他眼睛都不眨一下继续走。猜一成语'],
|
||||
['answer' => '百折不挠', 'hint' => '🧩 被摔倒一百次,第一百零一次依然站起来。猜一成语'],
|
||||
['answer' => '持之以恒', 'hint' => '🧩 水滴不断地滴在石头上,千年后石头被滴穿了。猜一成语'],
|
||||
['answer' => '知己知彼', 'hint' => '🧩 孙子兵法说:了解自己又了解对方,百战不殆。猜一成语'],
|
||||
['answer' => '四面楚歌', 'hint' => '🧩 项羽被包围在垓下,四面八方都传来熟悉的歌声。猜一成语'],
|
||||
['answer' => '草木皆兵', 'hint' => '🧩 淝水之战中,苻坚看到山上的草和树,都以为是敌军。猜一成语'],
|
||||
['answer' => '一箭双雕', 'hint' => '🧩 长孙晟一箭射出去,两只大鸟应声落地。猜一成语'],
|
||||
['answer' => '背水一战', 'hint' => '🧩 韩信把军队放在河边列阵,断了所有人的退路。猜一成语'],
|
||||
['answer' => '声东击西', 'hint' => '🧩 明明要打左边,却装作全力进攻右边。猜一成语'],
|
||||
['answer' => '调虎离山', 'hint' => '🧩 想占老虎的老窝,得先把老虎引出去。猜一成语'],
|
||||
['answer' => '空城计', 'hint' => '🧩 诸葛亮大开城门,在城楼上弹琴,敌军反而不敢进城。猜一成语'],
|
||||
['answer' => '缓兵之计', 'hint' => '🧩 打不过怎么办?先假装谈判争取时间。猜一成语'],
|
||||
['answer' => '卧薪尝胆', 'hint' => '🧩 越王勾践每天睡在柴堆上,还要舔一口苦胆。猜一成语'],
|
||||
['answer' => '三顾茅庐', 'hint' => '🧩 刘备为了请一个人出山,大冬天跑了三趟。猜一成语'],
|
||||
['answer' => '望梅止渴', 'hint' => '🧩 曹操说前面有片梅林,士兵们嘴里都开始流口水了。猜一成语'],
|
||||
['answer' => '七步成诗', 'hint' => '🧩 曹植被亲哥哥逼着在很短的时间里写诗保命。猜一成语'],
|
||||
['answer' => '才高八斗', 'hint' => '🧩 谢灵运说:天下才华共一石,曹植独占八斗。猜一成语'],
|
||||
['answer' => '入木三分', 'hint' => '🧩 王羲之在木板上写字,墨迹渗入木头三分深。猜一成语'],
|
||||
['answer' => '一字千金', 'hint' => '🧩 吕不韦悬赏:谁能给《吕氏春秋》改动一个字,赏千金。猜一成语'],
|
||||
['answer' => '一诺千金', 'hint' => '🧩 季布的一句话,比黄金千两还贵重。猜一成语'],
|
||||
['answer' => '半途而废', 'hint' => '🧩 走到半山腰觉得累了,就转身下山了。猜一成语'],
|
||||
['answer' => '实事求是', 'hint' => '🧩 不夸大不缩小,是什么就是什么。猜一成语'],
|
||||
['answer' => '量力而行', 'hint' => '🧩 蚂蚁想搬走大象?先掂量掂量自己有几斤几两。猜一成语'],
|
||||
['answer' => '自相矛盾', 'hint' => '🧩 楚国人夸自己的矛能刺穿任何盾,又夸自己的盾什么都刺不穿。猜一成语'],
|
||||
['answer' => '买椟还珠', 'hint' => '🧩 花大价钱买了精美盒子,却把里面的珍珠还给了老板。猜一成语'],
|
||||
['answer' => '杞人忧天', 'hint' => '🧩 有个怪人天天担心天会塌下来,地会陷下去。猜一成语'],
|
||||
['answer' => '画饼充饥', 'hint' => '🧩 饿了看着墙上画的大饼,假装自己吃饱了。猜一成语'],
|
||||
['answer' => '空中楼阁', 'hint' => '🧩 没有地基,没有支柱,一座房子浮在云端。猜一成语'],
|
||||
['answer' => '异想天开', 'hint' => '🧩 有人想在天上种田,海里摘星星。猜一成语'],
|
||||
['answer' => '千方百计', 'hint' => '🧩 为了达到目的,把所有能想到的办法都用上了。猜一成语'],
|
||||
['answer' => '不计其数', 'hint' => '🧩 海边的沙子有多少?天上的星星有多少?猜一成语'],
|
||||
['answer' => '成千上万', 'hint' => '🧩 体育场里坐满了人,放眼望去黑压压一片。猜一成语'],
|
||||
['answer' => '独一无二', 'hint' => '🧩 世界上没有第二个一模一样的你。猜一成语'],
|
||||
['answer' => '举世闻名', 'hint' => '🧩 地球上有几个人,就有几个人知道他。猜一成语'],
|
||||
['answer' => '名不虚传', 'hint' => '🧩 听说很好吃,亲自尝了一口,果然名不虚传。不对,我说的就是~猜一成语'],
|
||||
['answer' => '名副其实', 'hint' => '🧩 大家都叫他「神算子」,他算卦确实从没错过。猜一成语'],
|
||||
['answer' => '引人入胜', 'hint' => '🧩 这本书太好看了,一翻开就停不下来,像被吸进去了一样。猜一成语'],
|
||||
['answer' => '身临其境', 'hint' => '🧩 VR眼镜里的世界太真实了,好像自己真的在里面。猜一成语'],
|
||||
['answer' => '迫不及待', 'hint' => '🧩 快递到了,鞋都没穿就跑下楼去拿。猜一成语'],
|
||||
['answer' => '争先恐后', 'hint' => '🧩 超市大减价,大门一开所有人都在往前冲。猜一成语'],
|
||||
['answer' => '如履薄冰', 'hint' => '🧩 每一步都小心翼翼,生怕脚下突然裂开。猜一成语'],
|
||||
['answer' => '小心翼翼', 'hint' => '🧩 手里捧着一个装满水的气球,大气都不敢喘。猜一成语'],
|
||||
['answer' => '心花怒放', 'hint' => '🧩 听到被录取的消息,心里像有千万朵花同时绽放。猜一成语'],
|
||||
['answer' => '欢天喜地', 'hint' => '🧩 过年了,小孩拿到压岁钱在大街上又蹦又跳。猜一成语'],
|
||||
['answer' => '眉开眼笑', 'hint' => '🧩 嘴角上扬,眼角弯弯,整张脸都在表达开心。猜一成语'],
|
||||
['answer' => '手舞足蹈', 'hint' => '🧩 听到最喜欢的歌,身体不由自主地跟着节奏动起来。猜一成语'],
|
||||
['answer' => '兴高采烈', 'hint' => '🧩 中彩票后,他整个人像打了鸡血一样。猜一成语'],
|
||||
['answer' => '得意忘形', 'hint' => '🧩 考了第一名就开始翘尾巴,连走路姿势都不一样了。猜一成语'],
|
||||
['answer' => '怒气冲天', 'hint' => '🧩 他气得头顶冒烟,火焰快要烧到天花板了。猜一成语'],
|
||||
['answer' => '火冒三丈', 'hint' => '🧩 听到这个消息,他脑袋上的火苗蹿得比房子还高。猜一成语'],
|
||||
['answer' => '心急如焚', 'hint' => '🧩 等结果的那几分钟,心脏像放在火上烤。猜一成语'],
|
||||
['answer' => '愁眉苦脸', 'hint' => '🧩 眉头拧成麻花,嘴角向下弯,整张脸写满了不开心。猜一成语'],
|
||||
['answer' => '泪如雨下', 'hint' => '🧩 他哭得比外面的倾盆大雨还要猛。猜一成语'],
|
||||
['answer' => '目瞪口呆', 'hint' => '🧩 看到 UFO 从头顶飞过,他张大了嘴巴一句话也说不出来。猜一成语'],
|
||||
['answer' => '惊弓之鸟', 'hint' => '🧩 被弓箭射过一次的鸟,听到弓弦声就吓得乱飞。猜一成语'],
|
||||
['answer' => '千钧一发', 'hint' => '🧩 一万斤的重物吊在一根头发丝上,随时会断。猜一成语'],
|
||||
['answer' => '愚公移山', 'hint' => '🧩 九十岁老头发誓要搬走门口的两座大山,子子孙孙无穷匮也。猜一成语'],
|
||||
];
|
||||
Reference in New Issue
Block a user