Beispiel #1
0
 public void CalculateWaitingTiles()
 {
     if (LocalPlayerHandTiles == null)
     {
         return;
     }
     if (!GameSetting.AllowHint)
     {
         WaitingTiles = null;
         return;
     }
     WaitingTiles = MahjongLogic.WinningTiles(LocalPlayerHandTiles, null);
     NotifyObservers();
 }
Beispiel #2
0
        private void HandleFourRichis()
        {
            // Get waiting tiles for each player
            var waitingDataArray = new WaitingData[players.Count];

            for (int playerIndex = 0; playerIndex < players.Count; playerIndex++)
            {
                var hand = CurrentRoundStatus.HandTiles(playerIndex);
                var open = CurrentRoundStatus.Melds(playerIndex);
                waitingDataArray[playerIndex] = new WaitingData
                {
                    HandTiles    = hand,
                    WaitingTiles = MahjongLogic.WinningTiles(hand, open).ToArray()
                };
            }

            // Get messages
            for (int i = 0; i < players.Count; i++)
            {
                infos[i] = new EventMessages.RoundDrawInfo
                {
                    RoundDrawType = RoundDrawType,
                    WaitingData   = waitingDataArray
                };
            }

            next  = waitingDataArray[CurrentRoundStatus.OyaPlayerIndex].WaitingTiles.Length > 0;
            extra = true;
            // Get point transfers
            for (int playerIndex = 0; playerIndex < players.Count; playerIndex++)
            {
                var waitingTiles = waitingDataArray[playerIndex].WaitingTiles;
                if (waitingTiles.Length > 0)
                {
                    continue;
                }
                GetTransfersForFalseRichi(playerIndex, transfers);
            }
        }
Beispiel #3
0
        private void HandleRoundDraw()
        {
            // Get waiting tiles for each player
            var waitingDataArray = new WaitingData[players.Count];

            for (int playerIndex = 0; playerIndex < players.Count; playerIndex++)
            {
                var hand = CurrentRoundStatus.HandTiles(playerIndex);
                var open = CurrentRoundStatus.Melds(playerIndex);
                waitingDataArray[playerIndex] = new WaitingData
                {
                    HandTiles    = hand,
                    WaitingTiles = MahjongLogic.WinningTiles(hand, open).ToArray()
                };
            }

            // Get messages
            for (int i = 0; i < players.Count; i++)
            {
                infos[i] = new EventMessages.RoundDrawInfo
                {
                    RoundDrawType = RoundDrawType,
                    WaitingData   = waitingDataArray
                };
            }

            // Get point transfers
            // get player indices of those are ready and not
            var readyIndices    = new List <int>();
            var notReadyIndices = new List <int>();

            for (int playerIndex = 0; playerIndex < players.Count; playerIndex++)
            {
                if (waitingDataArray[playerIndex].WaitingTiles.Length > 0)
                {
                    readyIndices.Add(playerIndex);
                }
                else
                {
                    notReadyIndices.Add(playerIndex);
                }
            }

            next  = notReadyIndices.Contains(CurrentRoundStatus.OyaPlayerIndex);
            extra = true;
            // no one is ready or every one is ready
            if (readyIndices.Count == 0 || notReadyIndices.Count == 0)
            {
                return;
            }
            // get transfers according to total count of players
            switch (players.Count)
            {
            case 2:
                GetTransfersFor2(readyIndices, notReadyIndices, transfers);
                break;

            case 3:
                GetTransfersFor3(readyIndices, notReadyIndices, transfers);
                break;

            case 4:
                GetTransfersFor4(readyIndices, notReadyIndices, transfers);
                break;

            default:
                Debug.LogError("This should not happen");
                break;
            }

            // test for false richi
            foreach (var playerIndex in notReadyIndices)
            {
                if (CurrentRoundStatus.RichiStatus(playerIndex))
                {
                    GetTransfersForFalseRichi(playerIndex, transfers);
                }
            }
        }
Beispiel #4
0
    public static void TestGuoshiWushuang()
    {
        var handTiles = new List <Tile> {
            new Tile(Suit.M, 1), new Tile(Suit.M, 9),
            new Tile(Suit.P, 1), new Tile(Suit.P, 9),
            new Tile(Suit.S, 1), new Tile(Suit.S, 9),
            new Tile(Suit.Z, 1), new Tile(Suit.Z, 2),
            new Tile(Suit.Z, 4), new Tile(Suit.Z, 3),
            new Tile(Suit.Z, 5), new Tile(Suit.Z, 7),
            new Tile(Suit.Z, 6)
        };

        Debug.Log($"Hand tiles: {string.Join("", handTiles)}\nWaiting tiles: {string.Join("", MahjongLogic.WinningTiles(handTiles, new List<Meld>()))}");
    }