Beispiel #1
0
    public int TestDealCard(int turnCounter = 0) // used for testing purposes
    {
        if (tableSeats[turnCounter].cardValue >= 21 || tableSeats[turnCounter].isFrozen)
        {
            return(-1);
        }
        if (deckQ.Count <= 0)
        {
            CreateDeckQueue();
        }

        CardObject c = deckQ.Dequeue();

        //adds the cards into the list of cards at each seat
        tableSeats[turnCounter].seatCards.Add(c);

        //creates a card object from the prefab
        GameObject g = Instantiate(c.prefab, GetCardHolder(turnCounter));

        tableSeats[turnCounter].IncrementCardsInPlay();
        CardPool.Add(g);

        tableSeats[turnCounter].cardValue = LogicModel.Check21(tableSeats[turnCounter]);
        //checks and returns players total
        return(tableSeats[turnCounter].cardValue);
    }
Beispiel #2
0
    public void QuadDown() // like double down except its 4x2 so you bet quads and have to get dealt two cards in a row
    {
        if (tableSeats[playerTurn].cardValue >= 21)
        {
            Debug.Log("Busted before second card could come out :(");

            return;
        }
        if (deckQ.Count <= 0)
        {
            CreateDeckQueue();
        }

        tableSeats[playerTurn].quadDown = true;

        CardObject c = deckQ.Dequeue();

        //creates a card object from the prefab
        GameObject g = Instantiate(c.prefab, GetCardHolder(playerTurn));

        //adds the cards into the list of card objects and game objects at each seat
        tableSeats[playerTurn].seatCards.Add(c);
        tableSeats[playerTurn].CardGameObjects.Add(g);

        tableSeats[playerTurn].IncrementCardsInPlay();
        CardPool.Add(g);

        tableSeats[playerTurn].cardValue = LogicModel.Check21(tableSeats[playerTurn]);
    }
Beispiel #3
0
    public void StartDealerTurn()
    {
        isPaused = true;
        FlipCard(tableSeats[0].CardGameObjects[0]);
        while (LogicModel.DealerDecision(tableSeats[0]) == "HIT")
        {
            if (deckQ.Count <= 0)
            {
                CreateDeckQueue();
            }
            CardObject c = deckQ.Dequeue();

            //creates a card object from the prefab
            GameObject g = Instantiate(c.prefab, GetCardHolder(0));
            //adds the cards into the list of card objects and game objects at each seat
            tableSeats[0].seatCards.Add(c);
            tableSeats[0].CardGameObjects.Add(g);

            tableSeats[0].IncrementCardsInPlay();
            CardPool.Add(g);
        }

        isPaused = false;
        incrementTurnCounter();
        tableSeats[0].cardValue = LogicModel.Check21(tableSeats[0]);
        // EndGame();
        CalculateBets();
        game.uiManager.enableNewGame();
        Debug.Log(LogicModel.DealerDecision(tableSeats[playerTurn]));
    }
Beispiel #4
0
    public void Stay()
    {
        if (isPaused)
        {
            return;
        }
        tableSeats[playerTurn].cardValue = LogicModel.Check21(tableSeats[playerTurn]);

        tableSeats[playerTurn].isFrozen = true;
        incrementTurnCounter();
    }
Beispiel #5
0
    public void DoubleDown()
    {
        if (tableSeats[playerTurn].doubleDown)
        {
            incrementTurnCounter();
            return;
        }
        if (!(game.betManager.myWallet.money >= tableSeats[playerTurn].tableBet))
        {
            Debug.Log("Not enough funds to double down..");
            return;
        }
        tableSeats[playerTurn].doubleDown = true;
        if (deckQ.Count <= 0)
        {
            CreateDeckQueue();
        }


        CardObject c = deckQ.Dequeue();

        //creates a card object from the prefab
        GameObject g = Instantiate(c.prefab, GetCardHolder(playerTurn));

        //adds the cards into the list of card objects and game objects at each seat
        tableSeats[playerTurn].seatCards.Add(c);
        tableSeats[playerTurn].CardGameObjects.Add(g);

        tableSeats[playerTurn].IncrementCardsInPlay();
        CardPool.Add(g);

        tableSeats[playerTurn].cardValue = LogicModel.Check21(tableSeats[playerTurn]);
        Debug.Log("doubled down!!");
        game.betManager.DoubleBet();
        incrementTurnCounter();
        if (playerTurn == 0)
        {
            isPaused = true;
            StartDealerTurn();
            return;
        }
    }
Beispiel #6
0
 public void incrementTurnCounter() // increments player turn counter in game and this module
 {
     tableSeats[playerTurn].cardValue = LogicModel.Check21(tableSeats[playerTurn]);
     if (tableSeats[playerTurn].cardValue == 21)
     {
         Debug.Log("BlackJack!!");
         playerTurn += 1;
         if (playerTurn >= numPlayers)
         {
             playerTurn = 0;
         }
         return;
     }
     if (playerTurn >= numPlayers)
     {
         playerTurn = 0;
     }
     else
     {
         playerTurn += 1;
     }
 }
Beispiel #7
0
    public void Hit()
    {
        if (isPaused)
        {
            return;
        }
        if (deckQ.Count <= 0)
        {
            CreateDeckQueue();
        }


        CardObject c = deckQ.Dequeue();

        //creates a card object from the prefab
        GameObject g = Instantiate(c.prefab, GetCardHolder(playerTurn));

        //adds the cards into the list of card objects and game objects at each seat
        tableSeats[playerTurn].seatCards.Add(c);
        tableSeats[playerTurn].CardGameObjects.Add(g);

        tableSeats[playerTurn].IncrementCardsInPlay();
        CardPool.Add(g);

        tableSeats[playerTurn].cardValue = LogicModel.Check21(tableSeats[playerTurn]);
        if (tableSeats[playerTurn].cardValue >= 21 || tableSeats[playerTurn].isFrozen)
        {
            Debug.Log("Turn OVER!");
            incrementTurnCounter();
            if (playerTurn == 0)
            {
                isPaused = true;
                StartDealerTurn();
                return;
            }
        }
    }