//MOVED TO PLAYER RPC
    public void Call()
    {
        GameObject         textGameObject = GameObject.Find("Chip and Bet Amount Texts");
        BettingTextDisplay btd            = textGameObject.GetComponent <BettingTextDisplay> ();

        var currentPlayerPos  = BettingTextDisplay.currentPlayerPos;
        var previousPlayerPos = BettingTextDisplay.previousPlayerPos;

        //current player's chips equals chips + previous bet - current bet
        btd.chipAmountText [currentPlayerPos].text = (int.Parse(btd.chipAmountText[currentPlayerPos].text) + int.Parse(btd.betAmountText [currentPlayerPos].text) - int.Parse(btd.betAmountText [previousPlayerPos].text)).ToString();

        //current player's bet equals previous player's bet
        btd.betAmountText [currentPlayerPos].text = btd.betAmountText [previousPlayerPos].text;


        //assign current player to previous player before incrementing to next player
        BettingTextDisplay.previousPlayerPos = BettingTextDisplay.currentPlayerPos;

        //finding the new current player position based on active player position list
        if (BettingTextDisplay.activePlayerPosList.IndexOf(BettingTextDisplay.previousPlayerPos) == BettingTextDisplay.activePlayerPosList.Count - 1)
        {
            BettingTextDisplay.currentPlayerPos = BettingTextDisplay.activePlayerPosList[0];
        }
        else
        {
            BettingTextDisplay.currentPlayerPos = BettingTextDisplay.activePlayerPosList[BettingTextDisplay.activePlayerPosList.IndexOf(BettingTextDisplay.previousPlayerPos) + 1];
        }

        btd.chipAmountText [BettingTextDisplay.currentPlayerPos].color  = Color.yellow;
        btd.chipAmountText [BettingTextDisplay.previousPlayerPos].color = Color.black;


        //CHECK FOR STRADDLE
        CheckBetEquality.CheckIfBetsAreEqual();
    }
Ejemplo n.º 2
0
    public void Check()
    {
        //CHECK BUTTON SHOULD NOT BE VISIBLE IF PLAYER CAN'T CHECK

        //TODO: can't check during pre-flop unless you are straddle/big blind

        //move the current player to the next player if bet is equal to previous bet
        if (GameState.currentPlayer.myBetAmount == GameState.lastBetAmount)
        {
            //if all bets are equal, move the bets to the pot and go to the next round
            if (CheckBetEquality.CheckIfBetsAreEqual())
            {
                GameObject       cbeObject = GameObject.Find("CheckBetEquality");
                CheckBetEquality cbe       = cbeObject.GetComponent <CheckBetEquality> ();

                //move bets to pot after delay
                cbe.Invoke("MoveBetsToPot", 2f);

                //GO TO THE NEXT GAMESTATE.ROUNDS!!!!

                //assign the new current player
            }
            else
            {
                //make next player the new current player
                if (GamePlayManager.playerList.IndexOf(GameState.currentPlayer) == GamePlayManager.playerList.Count - 1)
                {
                    GameState.currentPlayer = GamePlayManager.playerList [0];
                }
                else
                {
                    GameState.currentPlayer = GamePlayManager.playerList [GamePlayManager.playerList.IndexOf(GameState.currentPlayer) + 1];
                }
            }
        }
        else
        {
            //CHECK BUTTON DOES NOTHING IF MY BET DOES NOT EQUAL PREVIOUS BET
        }
    }
Ejemplo n.º 3
0
    public void Call()
    {
        //TODO: IF STRADDLE JUST CALLED, MAKE STRADDLE NULL. ALSO BIG BLIND

        foreach (Player player in GamePlayManager.playerList)
        {
            if (player.ID == 1)
            {
                player.myBetAmount++;
                GameObject.Find("MyBetAmountText").GetComponent <Text> ().text = player.myBetAmount.ToString();
            }
        }

        //add back my previous bet to my chips stack
        myChipAmount += myBetAmount;
        myBetAmount   = GameState.lastBetAmount;

        myChipAmount -= myBetAmount;


        //the possible new current player (if bets are not equal or if he is the straddle)
        Player newCurrentPlayer;

        //make next player the possible new current player
        if (GamePlayManager.playerList.IndexOf(GameState.currentPlayer) == GamePlayManager.playerList.Count - 1)
        {
            newCurrentPlayer = GamePlayManager.playerList [0];
        }
        else
        {
            newCurrentPlayer = GamePlayManager.playerList [GamePlayManager.playerList.IndexOf(GameState.currentPlayer) + 1];
        }

        //if the round is pre-flop, straddle or big blind can raise or check (if bets are equal)
        if (GameState.currentRound == GameState.Rounds.isPreFlop)
        {
            //if straddle player exists
            if (GameState.straddlePlayer != null)
            {
                if (CheckBetEquality.CheckIfBetsAreEqual() && newCurrentPlayer != GameState.straddlePlayer)
                {
                    CheckBetEquality.MoveBetsToPot();
                    GameState.currentRound++;

                    //TODO: MAKE FIRST PERSON TO LEFT OF DEALER THE NEW CURRENT PLAYER
                }
                else
                {
                    GameState.currentPlayer = newCurrentPlayer;
                }
            }
            else                 //straddle player doesn't exist so big blind has option of betting/checking

            {
                if (CheckBetEquality.CheckIfBetsAreEqual() && newCurrentPlayer != GameState.bigBlindPlayer)
                {
                    CheckBetEquality.MoveBetsToPot();
                    GameState.currentRound++;

                    //TODO: MAKE FIRST PERSON TO LEFT OF DEALER THE NEW CURRENT PLAYER
                }
                else
                {
                    GameState.currentPlayer = newCurrentPlayer;
                }
            }
        }
        else           //round is not preflop

        {
            //if bets are equal
            if (CheckBetEquality.CheckIfBetsAreEqual())
            {
                CheckBetEquality.MoveBetsToPot();

                //if showdown
                if (GameState.currentRound == GameState.Rounds.isShowdown)
                {
                    GamePlayManager.AddPointsToWinners();

                    //TODO: ANIMATE THE WIN, START NEW GAME
                }
                else
                {
                    GameState.currentRound++;

                    //TODO: MAKE FIRST PERSON TO LEFT OF DEALER THE NEW CURRENT PLAYER
                }
            }
            else                 //bets are not equal

            {
                GameState.currentPlayer = newCurrentPlayer;
            }
        }
    }
Ejemplo n.º 4
0
    public void Fold()
    {
        //ANIMATE CARDS TO DEALER

        //move my bet to the pot
        GameState.potAmount += myBetAmount;
        myBetAmount          = 0;

        //ANIMATE BET CHIPS TO POT

        //save index of folded player
        int indexOfFoldedPlayer = GamePlayManager.playerList.IndexOf(GameState.currentPlayer);

        //remove the player from playerList
        GamePlayManager.playerList.RemoveAt(GamePlayManager.playerList.IndexOf(GameState.currentPlayer));

        //if only 1 player left, he is the winner
        if (GamePlayManager.playerList.Count == 1)
        {
            print("Winner ID " + GamePlayManager.playerList [0].ID);

            //add winPoints and a win to the winner
            GamePlayManager.AddPointsToWinners();

            //move the pot to the winner
            GamePlayManager.playerList [0].myChipAmount += GameState.potAmount;
            GameState.potAmount = 0;

            //START NEW GAME

            //else assign the new current player and continue game
        }
        else
        {
            //the possible new current player (if bets are not equal or if he is the straddle)
            Player newCurrentPlayer;

            //make next player the possible new current player
            //if the folded player was at the last index of the playerList before folding
            if (indexOfFoldedPlayer == GamePlayManager.playerList.Count)
            {
                newCurrentPlayer = GamePlayManager.playerList [0];

                //new current player is at same index of folded player in the smaller playerList
            }
            else
            {
                newCurrentPlayer = GamePlayManager.playerList [indexOfFoldedPlayer];
            }


            //COPIED FROM CALL FUNCTION
            //check if new current player is straddle. If not, check if bets are equal
            //ALSO CHECK IF PRE-FLOP?
            if (newCurrentPlayer == GameState.straddlePlayer)
            {
                if (CheckBetEquality.CheckIfBetsAreEqual())
                {
                    //MOVE BETS TO POT AND DEAL THE NEW COMM CARDS DEPENDING ON GAME STATE
                    //NEED TO SPLIT UP THE CHECKIFBETSEQUAL FUNCTION
                }
                else
                {
                    GameState.currentPlayer = newCurrentPlayer;
                }

                //if new current player is the straddle, he has option of raising or checking
            }
            else
            {
                GameState.currentPlayer = newCurrentPlayer;
            }
        }
    }