예제 #1
0
        private void OnPlayerTurnEnded(TurnType turnType, int amount)
        {
            Debug.Log("OnPlayerTurnEnded");
            if (turnType == TurnType.Invalid)
            {
                Debug.Log("OnPlayerTurnEnded: invalid turn type.");
                return;
            }

            if (turnType == TurnType.Fold)
            {
                CurrentHand.RemovePlayer(CurrentPlayer);
            }
            else if (turnType == TurnType.Call)
            {
                PutChipsToPot(CurrentPlayer, amount);
                GameController.Instance.UpdatePlayerCard(CurrentPlayerIndex, CurrentPlayer);
                GameController.Instance.UpdatePotSizeTexts(CurrentHand.Pots);
            }
            else if (turnType == TurnType.Raise)
            {
                PutChipsToPot(CurrentPlayer, amount);
                GameController.Instance.UpdatePlayerCard(CurrentPlayerIndex, CurrentPlayer);
                GameController.Instance.UpdatePotSizeTexts(CurrentHand.Pots);
            }
            else if (turnType == TurnType.Bet)
            {
                PutChipsToPot(CurrentPlayer, amount);
                GameController.Instance.UpdatePlayerCard(CurrentPlayerIndex, CurrentPlayer);
                GameController.Instance.UpdatePotSizeTexts(CurrentHand.Pots);
            }
            else if (turnType == TurnType.Check)
            {
                // TODO
            }

            CurrentPlayer.LastTurn = turnType;

            GameController.Instance.HighlightActivePlayer(false);
            GameController.Instance.StopTurnTimer();

            if (!HandHasWinner(CurrentHand))
            {
                if (NeedToDealNextStreet())
                {
                    DealNextStreet();
                }
                else
                {
                    PlayTurn();
                }
            }
            else
            {
                EndHand(CurrentHand);
            }
        }