diff --git a/app/Http/Controllers/Admin/GameHistoryController.php b/app/Http/Controllers/Admin/GameHistoryController.php index 74ee98d..a95502a 100644 --- a/app/Http/Controllers/Admin/GameHistoryController.php +++ b/app/Http/Controllers/Admin/GameHistoryController.php @@ -17,6 +17,7 @@ use App\Http\Controllers\Controller; use App\Models\BaccaratBet; use App\Models\BaccaratRound; use App\Models\FortuneLog; +use App\Models\GomokuGame; use App\Models\HorseBet; use App\Models\HorseRace; use App\Models\LotteryIssue; @@ -83,6 +84,14 @@ class GameHistoryController extends Controller 'today_issues' => LotteryIssue::query()->whereDate('created_at', today())->count(), ]; + // 五子棋 + $gomoku = [ + 'total_games' => GomokuGame::query()->count(), + 'pvp_count' => GomokuGame::query()->where('is_pvp', true)->count(), + 'pve_count' => GomokuGame::query()->where('is_pvp', false)->count(), + 'today_games' => GomokuGame::query()->whereDate('created_at', today())->count(), + ]; + return response()->json([ 'baccarat' => $baccarat, 'slot' => $slot, @@ -90,6 +99,7 @@ class GameHistoryController extends Controller 'mystery_box' => $mysteryBox, 'fortune' => $fortune, 'lottery' => $lottery, + 'gomoku' => $gomoku, ]); } @@ -281,4 +291,25 @@ class GameHistoryController extends Controller return view('admin.game-history.lottery-issue', compact('issue', 'tickets')); } + + /** + * 五子棋历史记录页面。 + */ + public function gomoku(Request $request): View + { + $summary = [ + 'total_games' => GomokuGame::query()->count(), + 'pvp_count' => GomokuGame::query()->where('is_pvp', true)->count(), + 'pve_count' => GomokuGame::query()->where('is_pvp', false)->count(), + 'completed' => GomokuGame::query()->where('status', 'finished')->count(), + 'today_games' => GomokuGame::query()->whereDate('created_at', today())->count(), + ]; + + $games = GomokuGame::query() + ->with(['playerBlack', 'playerWhite']) + ->latest() + ->paginate(30); + + return view('admin.game-history.gomoku', compact('games', 'summary')); + } } diff --git a/resources/views/admin/game-configs/index.blade.php b/resources/views/admin/game-configs/index.blade.php index b86c957..dc25361 100644 --- a/resources/views/admin/game-configs/index.blade.php +++ b/resources/views/admin/game-configs/index.blade.php @@ -65,6 +65,7 @@ 'horse_racing' => 'admin.game-history.horse', 'fortune_telling' => 'admin.game-history.fortune', 'lottery' => 'admin.game-history.lottery', + 'gomoku' => 'admin.game-history.gomoku', default => null, }; @endphp @@ -505,6 +506,24 @@ }, ], color: 'border-rose-200 bg-rose-50', + }, + { + icon: '♟️', + title: '五子棋', + items: [{ + label: '总对局', + value: data.gomoku.total_games.toLocaleString() + ' 局' + }, + { + label: '人机/对战', + value: data.gomoku.pve_count + ' / ' + data.gomoku.pvp_count + }, + { + label: '今日对局', + value: data.gomoku.today_games.toLocaleString() + }, + ], + color: 'border-blue-200 bg-blue-50', } ]; @@ -516,11 +535,11 @@
查询全站所有的五子棋人机及 PvP 对局。
+| 赛事ID | +创建时间 | +模式 | +黑方 (发起) | +白方 (迎战) | +状态 | +胜负 | +
|---|---|---|---|---|---|---|
| #{{ $game->id }} | ++ {{ $game->created_at ? $game->created_at->format('m-d H:i') : '—' }} + | ++ @if ($game->mode === 'pve') + 单机 + PvE(L{{ $game->ai_level }}) + @else + 在线 + PvP + @endif + | ++ {{ $game->playerBlack?->username ?? '已注销/未知' }} + | ++ @if ($game->mode === 'pve') + AI 机器人 + @else + {{ $game->playerWhite?->username ?? '已注销/未加入' }} + @endif + | ++ @php + $s = match ($game->status) { + 'waiting' => ['label' => '等待中', 'bg' => 'bg-amber-100 text-amber-600'], + 'playing' => ['label' => '对弈中', 'bg' => 'bg-blue-100 text-blue-600'], + 'finished' => ['label' => '已结束', 'bg' => 'bg-emerald-100 text-emerald-700'], + default => ['label' => $game->status, 'bg' => 'bg-gray-100 text-gray-600'], + }; + @endphp + {{ $s['label'] }} + | ++ @if ($game->status !== 'finished') + - + @else + @if ($game->winner === 1) + ⚫ + 黑胜 + @elseif($game->winner === 2) + ⚪ + 白胜 + @else + 平局撤销 + @endif + @endif + | +
| 暂无记录 | +||||||