Esempio n. 1
0
        public void RpcRoundDraw(EventMessages.RoundDrawInfo info)
        {
            var roundDrawState = new RoundDrawState
            {
                CurrentRoundStatus = CurrentRoundStatus,
                RoundDrawType      = info.RoundDrawType,
                WaitingData        = info.WaitingData
            };

            StateMachine.ChangeState(roundDrawState);
        }
Esempio n. 2
0
 private void HandleSpecialType(RoundDrawType type)
 {
     for (int i = 0; i < players.Count; i++)
     {
         infos[i] = new EventMessages.RoundDrawInfo
         {
             RoundDrawType = type
         };
     }
     next  = false;
     extra = true;
 }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
                }
            }
        }