private void TestKongs(int playerIndex, Tile[] handTiles, IList <InTurnOperation> operations) { if (CurrentRoundStatus.KongClaimed == MahjongConstants.MaxKongs) { return; // no more kong can be claimed after 4 kongs claimed } var alreadyRichied = CurrentRoundStatus.RichiStatus(playerIndex); if (alreadyRichied) { // test kongs in richied player hand var richiKongs = MahjongLogic.GetRichiKongs(handTiles, justDraw); if (richiKongs.Any()) { foreach (var kong in richiKongs) { operations.Add(new InTurnOperation { Type = InTurnOperationType.Kong, Meld = kong }); } } } else { // 1. test self kongs, aka four same tiles in hand and lastdraw var selfKongs = MahjongLogic.GetSelfKongs(handTiles, justDraw); if (selfKongs.Any()) { foreach (var kong in selfKongs) { operations.Add(new InTurnOperation { Type = InTurnOperationType.Kong, Meld = kong }); } } // 2. test add kongs, aka whether a single tile in hand and lastdraw is identical to a pong in open melds var addKongs = MahjongLogic.GetAddKongs( CurrentRoundStatus.HandTiles(playerIndex), CurrentRoundStatus.OpenMelds(playerIndex), justDraw); if (addKongs.Any()) { foreach (var kong in addKongs) { operations.Add(new InTurnOperation { Type = InTurnOperationType.Kong, Meld = kong }); } } } }
public static void TestRichiKongs() { var handTiles = new List <Tile> { new Tile(Suit.M, 3), new Tile(Suit.M, 3), new Tile(Suit.M, 4), new Tile(Suit.M, 4), new Tile(Suit.M, 5), new Tile(Suit.M, 5, true), new Tile(Suit.M, 5) }; var kongs = MahjongLogic.GetRichiKongs(handTiles, new Tile(Suit.M, 5)); Debug.Log($"Kongs: {string.Join(",", kongs)}"); handTiles = new List <Tile> { new Tile(Suit.M, 3), new Tile(Suit.M, 3), new Tile(Suit.M, 6), new Tile(Suit.M, 6), new Tile(Suit.M, 5), new Tile(Suit.M, 5, true), new Tile(Suit.M, 5) }; kongs = MahjongLogic.GetRichiKongs(handTiles, new Tile(Suit.M, 5)); Debug.Log($"Kongs: {string.Join(",", kongs)}"); kongs = MahjongLogic.GetRichiKongs(handTiles, new Tile(Suit.M, 3)); Debug.Log($"Kongs: {string.Join(",", kongs)}"); }