From b2e54aafdbd842b354791518baac951ca866d87e Mon Sep 17 00:00:00 2001 From: lkddi Date: Thu, 12 Mar 2026 16:44:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=94=E5=AD=90=E6=A3=8B=EF=BC=9AAI=20?= =?UTF-8?q?=E8=8E=B7=E8=83=9C=EF=BC=88=E7=8E=A9=E5=AE=B6=E8=BE=93=E5=B1=80?= =?UTF-8?q?=EF=BC=89=E6=97=B6=E4=B9=9F=E5=90=91=E8=81=8A=E5=A4=A9=E5=AE=A4?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=B3=BB=E7=BB=9F=E5=B9=BF=E6=92=AD=E9=80=9A?= =?UTF-8?q?=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/GomokuController.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/GomokuController.php b/app/Http/Controllers/GomokuController.php index fba2dce..98cc807 100644 --- a/app/Http/Controllers/GomokuController.php +++ b/app/Http/Controllers/GomokuController.php @@ -456,10 +456,22 @@ class GomokuController extends Controller // 广播对局结束事件给参与对局的双方 broadcast(new GomokuFinishedEvent($game->fresh(), $winnerName, $loserName, $reason)); - // 有胜负,并且非 AI 获胜,发送系统房间广播 - if ($winnerColor !== 0 && $winnerName && $winnerName !== "AI(难度{$game->ai_level})") { - $msgType = $game->mode === 'pvp' ? '玩家对战' : "人机对战(难度{$game->ai_level})"; - $text = "🎉 棋神降临!恭喜玩家【{$winnerName}】在五子棋{$msgType}中击败了【{$loserName}】,赢得了 {$rewardGold} 金币奖励!"; + // 有胜负,均向房间广播系统通知 + if ($winnerColor !== 0) { + if ($game->mode === 'pvp') { + // PvP:胜方玩家获奖通知 + $reasonText = match ($reason) { + 'resign' => '(认输)', + default => '', + }; + $text = "🎉 棋神降临!恭喜玩家【{$winnerName}】在五子棋玩家对战中击败了【{$loserName}】{$reasonText},赢得了 {$rewardGold} 金币奖励!"; + } elseif ($winnerColor === 1) { + // PvE:玩家获胜 + $text = "🎉 棋神降临!恭喜玩家【{$winnerName}】在五子棋人机对战(难度{$game->ai_level})中击败了【{$loserName}】,赢得了 {$rewardGold} 金币奖励!"; + } else { + // PvE:AI 获胜(玩家输了) + $text = "🤖 AI 大获全胜!玩家【{$loserName}】在五子棋人机对战(难度{$game->ai_level})中不敌 AI,再接再厉!"; + } $this->broadcastSystemMessage($game->room_id, $text); }