RuleEngine 核心类: - MahjongTile.cs — int编码 (1-29万条筒, 31-37字, 41-48花, 50-59宝牌) - MeldsSolver.cs — 标准回溯 + wildcard缺口填充 + 七对/十三幺/全不靠 - PhaseMachine.cs — 回合机(摸打碰杠胡 + 优先级仲裁) - ScoreEngine.cs — 番型计分 + 互斥图 - DslLoader.cs — YAML DSL加载 + 能力检查 4个DSL: 四川血战/广东鸡平胡/国标麻将/武汉麻将 控制台Demo: 交互模式 + 自动模式(--auto) 测试: 33个测试用例, 32个通过
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
namespace RuleEngine;
|
|
|
|
public class Meld
|
|
{
|
|
public string Type { get; set; } = ""; // "kezi", "shunzi", "pair", "chi", "pung", "kong_ming", "kong_an", "kong_bu"
|
|
public List<int> Tiles { get; set; } = new(); // -1 = wildcard placeholder
|
|
public bool IsConcealed { get; set; }
|
|
public string SourcePlayer { get; set; } = ""; // who discarded the tile that triggered pung/chi/kong
|
|
|
|
public Meld Clone() => new()
|
|
{
|
|
Type = Type,
|
|
Tiles = new List<int>(Tiles),
|
|
IsConcealed = IsConcealed,
|
|
SourcePlayer = SourcePlayer
|
|
};
|
|
}
|
|
|
|
public class MeldsResult
|
|
{
|
|
public bool IsWin { get; set; }
|
|
public List<Meld> Melds { get; set; } = new();
|
|
public List<int> PairTiles { get; set; } = new(); // the pair (将牌)
|
|
public List<string> Fans { get; set; } = new();
|
|
public int WildcardsUsed { get; set; }
|
|
|
|
public MeldsResult Clone() => new()
|
|
{
|
|
IsWin = IsWin,
|
|
Melds = Melds.Select(m => m.Clone()).ToList(),
|
|
PairTiles = new List<int>(PairTiles),
|
|
Fans = new List<string>(Fans),
|
|
WildcardsUsed = WildcardsUsed
|
|
};
|
|
}
|