fix: 人类玩家显示摸到的牌 (LastDrawnTile + 箭头高亮)
- GameState新增LastDrawnTile字段 - StepTurn摸牌时记录LastDrawnTile - HumanMahjongPlayer显示'刚刚摸到:X'并用→←箭头标记新牌 - 庄家首轮LastDrawnTile清空
This commit is contained in:
@ -21,13 +21,22 @@ public class HumanMahjongPlayer
|
||||
var hand = state.Hands.GetValueOrDefault(Name, new List<int>());
|
||||
var sorted = hand.OrderBy(t => t).ToList();
|
||||
|
||||
// Highlight last drawn tile
|
||||
int? drawnTile = state.LastDrawnTile;
|
||||
int drawnIdx = drawnTile.HasValue ? sorted.IndexOf(drawnTile.Value) : -1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine($"=== {Name} 的回合 ===");
|
||||
if (drawnTile.HasValue && drawnIdx >= 0)
|
||||
Console.WriteLine($" 🀫 刚刚摸到: {MahjongTile.ToString(drawnTile.Value)}");
|
||||
Console.WriteLine($"手牌 ({hand.Count}张):");
|
||||
for (int i = 0; i < sorted.Count; i++)
|
||||
Console.WriteLine($" [{i + 1}] {MahjongTile.ToString(sorted[i])}");
|
||||
{
|
||||
bool isDrawn = (i == drawnIdx);
|
||||
Console.WriteLine($" [{i + 1}] {(isDrawn ? "→ " : " ")}{MahjongTile.ToString(sorted[i])}{(isDrawn ? " ← 新摸" : "")}");
|
||||
}
|
||||
Console.WriteLine();
|
||||
|
||||
// Show available actions
|
||||
|
||||
@ -31,6 +31,7 @@ public class MahjongGameState
|
||||
public bool IsDeckExhausted { get; set; }
|
||||
public List<GameEvent> RecentEvents { get; set; } = new();
|
||||
public int FlowerReplaced { get; set; }
|
||||
public int? LastDrawnTile { get; set; }
|
||||
|
||||
public MahjongGameState Clone()
|
||||
{
|
||||
|
||||
@ -135,13 +135,16 @@ public class MahjongRoom
|
||||
|
||||
// Phase 2: Draw card (skip for dealer on first turn — they already have 14)
|
||||
bool isDealerFirstTurn = (player == State.Dealer && State.RoundNumber == 0);
|
||||
if (!isDealerFirstTurn)
|
||||
if (isDealerFirstTurn)
|
||||
State.LastDrawnTile = null;
|
||||
else
|
||||
{
|
||||
if (State.Deck.Count > 0)
|
||||
{
|
||||
int drawn = State.Deck[^1];
|
||||
State.Deck.RemoveAt(State.Deck.Count - 1);
|
||||
State.Hands[player].Add(drawn);
|
||||
State.LastDrawnTile = drawn;
|
||||
State.AddEvent("draw", player, drawn,
|
||||
$"摸牌: {MahjongTile.ToString(drawn)}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user