feat: HUD显示所有玩家出牌记录 (DiscardHistory)
- GameState新增DiscardHistory字典 (per-player出牌记录) - MahjongRoom.RecordDiscard统一记录出牌 - 人类模式HUD: 对手显示最近6张出牌 例: AI-南: 10张手牌 | 已pung[..] | 出: 1万 3条 5筒
This commit is contained in:
@ -163,7 +163,13 @@ else
|
||||
$"{m.Type}[{string.Join(",", m.Tiles.Where(t => t != -1).Select(MahjongTile.ToString))}]");
|
||||
exposedStr = $" | 已{string.Join(" ", descs)}";
|
||||
}
|
||||
Console.WriteLine($" {p}: {hand.Count}张手牌{exposedStr}");
|
||||
var discardStr = "";
|
||||
if (room.State.DiscardHistory.TryGetValue(p, out var discards) && discards.Count > 0)
|
||||
{
|
||||
var recent = discards.TakeLast(6).Select(MahjongTile.ToString);
|
||||
discardStr = $" | 出: {string.Join(" ", recent)}";
|
||||
}
|
||||
Console.WriteLine($" {p}: {hand.Count}张手牌{exposedStr}{discardStr}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -18,6 +18,7 @@ public class MahjongGameState
|
||||
public Dictionary<string, List<int>> FlowerPool { get; set; } = new();
|
||||
public List<int> Deck { get; set; } = new();
|
||||
public List<int> DiscardPool { get; set; } = new();
|
||||
public Dictionary<string, List<int>> DiscardHistory { get; set; } = new();
|
||||
public int? LastDiscard { get; set; }
|
||||
public string? LastDiscardPlayer { get; set; }
|
||||
public string CurrentPlayer { get; set; } = "";
|
||||
|
||||
@ -116,6 +116,14 @@ public class MahjongRoom
|
||||
Settle();
|
||||
}
|
||||
|
||||
private void RecordDiscard(string player, int tile)
|
||||
{
|
||||
State.DiscardPool.Add(tile);
|
||||
if (!State.DiscardHistory.ContainsKey(player))
|
||||
State.DiscardHistory[player] = new List<int>();
|
||||
State.DiscardHistory[player].Add(tile);
|
||||
}
|
||||
|
||||
public List<GameEvent> StepTurn()
|
||||
{
|
||||
State.RecentEvents.Clear();
|
||||
@ -223,7 +231,7 @@ public class MahjongRoom
|
||||
State.Hands[player].Remove(tile.Value);
|
||||
State.LastDiscard = tile.Value;
|
||||
State.LastDiscardPlayer = player;
|
||||
State.DiscardPool.Add(tile.Value);
|
||||
RecordDiscard(player, tile.Value);
|
||||
State.AddEvent("discard", player, tile.Value,
|
||||
$"出牌: {MahjongTile.ToString(tile.Value)}");
|
||||
}
|
||||
@ -350,7 +358,7 @@ public class MahjongRoom
|
||||
State.Hands[p].Remove(tileToDiscard);
|
||||
State.LastDiscard = tileToDiscard;
|
||||
State.LastDiscardPlayer = p;
|
||||
State.DiscardPool.Add(tileToDiscard);
|
||||
RecordDiscard(p, tileToDiscard);
|
||||
State.AddEvent("discard", p, tileToDiscard,
|
||||
$"出牌: {MahjongTile.ToString(tileToDiscard)}");
|
||||
return true;
|
||||
@ -409,7 +417,7 @@ public class MahjongRoom
|
||||
State.Hands[player].Remove(tileToDiscard);
|
||||
State.LastDiscard = tileToDiscard;
|
||||
State.LastDiscardPlayer = player;
|
||||
State.DiscardPool.Add(tileToDiscard);
|
||||
RecordDiscard(player, tileToDiscard);
|
||||
State.AddEvent("discard", player, tileToDiscard,
|
||||
$"出牌: {MahjongTile.ToString(tileToDiscard)}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user