Beispiel #1
0
 private void CheckReadyOrNot(int placeIndex, WaitingData data)
 {
     // Show tiles and corresponding panel
     if (data.WaitingTiles == null || data.WaitingTiles.Length == 0)
     {
         // no-ting
         Debug.Log($"Place {placeIndex} is not ready");
         controller.TableTilesManager.CloseDown(placeIndex);
         controller.WaitingPanelManagers[placeIndex].NotReady();
     }
     else
     {
         // ting
         Debug.Log($"Place {placeIndex} is ready, waiting {string.Join(",", data.WaitingTiles)}");
         controller.TableTilesManager.OpenUp(placeIndex);
         controller.TableTilesManager.SetHandTiles(placeIndex, data.HandTiles);
         controller.WaitingPanelManagers[placeIndex].Ready(data.WaitingTiles);
     }
 }
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);
                }
            }
        }