From 42b032339ce42c4117d48191161548aa41a519d2 Mon Sep 17 00:00:00 2001 From: xiaoou Date: Sat, 4 Jul 2026 21:54:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=20maxRounds=3D50?= =?UTF-8?q?0=20=E5=AE=89=E5=85=A8=E9=98=80,=20=E7=89=8C=E5=B1=80=E8=87=AA?= =?UTF-8?q?=E7=84=B6=E7=BB=88=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 牌局终止路径: - 胡牌 → IsFinished=true (HandleDiscardReactions/ExecuteWinClaim/StepTurn) - 牌墙耗尽 → Settle() → IsFinished=true - 只剩一人(血战) → AdvancePlayer → IsFinished=true - 所有路径都通过 IsFinished 控制, 不需要额外安全阀 500局×5种玩法压测 0 错误, 证明牌局能自然结束。 --- RuleEngine/MahjongRoom.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/RuleEngine/MahjongRoom.cs b/RuleEngine/MahjongRoom.cs index 7638956..0be42c1 100644 --- a/RuleEngine/MahjongRoom.cs +++ b/RuleEngine/MahjongRoom.cs @@ -123,23 +123,12 @@ public class MahjongRoom Deal(); IsFinished = false; - // Safety valve: prevent infinite loops from edge-case game states - const int maxRounds = 500; - int round = 0; - - while (!IsFinished && round < maxRounds) + while (!IsFinished) { if (State.Phase == "deal") { State.Phase = "play"; continue; } if (State.Phase == "settle" || IsFinished) break; StepTurn(); - round++; - } - - if (!IsFinished) - { - State.AddEvent("max_rounds", "", null, $"超过最大回合数({maxRounds}),强制流局"); - Settle(); } }