예제 #1
0
        // deal 1 card from the card deck
        public void dealCard(BlackjackPlayer player, int hand_id)
        {
            Console.WriteLine("current_card: " + current_card);// test

            Card card = deck.Cards[current_card];

            if (current_card == 51)
            {
                Console.WriteLine("DEALER RESHUFFLES");// test
                deck.shuffle();
                current_card = 0;
            }
            else
            {
                current_card++;
            }

            // set the offset for the card
            card.x = player.hands[hand_id].x_nextOffset;
            card.y = player.hands[hand_id].y_nextOffset;
            player.hands[hand_id].x_nextOffset += 10;
            player.hands[hand_id].y_nextOffset += 20;

            // if this is dealer's 1st card, set it as face down
            if (player.id == this.id && player.hands[hand_id].cards.Count == 0)
            {
                card.IsFaceDown = true;
            }

            // give Player the card
            player.hands[hand_id].addCard(card);

            // display the card on the form
            form_controls.displayCard(card, player.id);
        }// close function
예제 #2
0
        // deal 1 card from the card deck 
        public void dealCard(BlackjackPlayer player, int hand_id)
        {
            Console.WriteLine("current_card: " + current_card);// test

            Card card = deck.Cards[current_card];

            if (current_card == 51)
            {
                Console.WriteLine("DEALER RESHUFFLES");// test
                deck.shuffle();
                current_card = 0;
            }
            else
            {
                current_card++;
            }

            // set the offset for the card
            card.x = player.hands[hand_id].x_nextOffset;
            card.y = player.hands[hand_id].y_nextOffset;
            player.hands[hand_id].x_nextOffset += 10;
            player.hands[hand_id].y_nextOffset += 20;

            // if this is dealer's 1st card, set it as face down
            if (player.id == this.id && player.hands[hand_id].cards.Count == 0)
            {
                card.IsFaceDown = true;
            }

            // give Player the card
            player.hands[hand_id].addCard(card);

            // display the card on the form
            form_controls.displayCard(card, player.id);
        }// close function
예제 #3
0
        // check final results
        void showResult(BlackjackPlayer player)
        {
            double win = 0;

            // compare player hands to dealer
            foreach (BlackjackHand hand in player.hands)
            {
                // set hand to win or lose
                if (currentHand.Status > hand.Status || hand.Status == -100)
                {
                    // player loses
                    hand.result = BlackjackHand.Result.LOSE;

                    // check player balance, if < 5 game over for them
                    NumActivePlayers += player.isActive();

                    hand.label_bet.Text = "";
                }
                else if (currentHand.Status == hand.Status)
                {
                    // push
                    hand.result = BlackjackHand.Result.PUSH;

                    // return bet to player
                    player.Balance += hand.Bet;

                    hand.label_bet.Text = "+" + hand.Bet;
                }
                else
                {
                    // player wins
                    hand.result = BlackjackHand.Result.WIN;

                    // pay player

                    if (hand.Sum == 21)
                    {
                        // 2.5 x bet if blackjack
                        win                 = (hand.Bet * 2) + (hand.Bet / 2);
                        player.Balance     += win;
                        hand.label_bet.Text = "+" + win;
                    }
                    else
                    {
                        // 2 x bet if win
                        win                 = hand.Bet * 2;
                        player.Balance     += win;
                        hand.Bet            = win;
                        hand.label_bet.Text = "+" + win;
                    }
                }

                // update label of the hand with results (SUM - WIN/LOSE/PUSH)
                form_controls.displayFinalResult(player.id, hand);
            } // close foreach
        }     // close function
예제 #4
0
        // set List to store Player objects
        public void createPlayers(string num_players)
        {
            NumGamePlayers   = int.Parse(num_players);
            NumActivePlayers = NumGamePlayers;

            // use NumPlayers to create CasinoPlayer objects
            for (int i = 0; i < NumGamePlayers; i++)
            {
                BlackjackPlayer player = new BlackjackPlayer();
                player.id = i;
                players.Add(player);
            }
        }
예제 #5
0
        // check final results
        void showResult(BlackjackPlayer player) 
        {
            double win = 0;

            // compare player hands to dealer
            foreach (BlackjackHand hand in player.hands){

                // set hand to win or lose
                if (currentHand.Status > hand.Status || hand.Status == -100){
                        // player loses
                        hand.result = BlackjackHand.Result.LOSE;
                        
                        // check player balance, if < 5 game over for them
                        NumActivePlayers += player.isActive();

                        hand.label_bet.Text = "";
                }
                else if (currentHand.Status == hand.Status){
                        // push
                        hand.result = BlackjackHand.Result.PUSH;

                        // return bet to player
                        player.Balance += hand.Bet;

                        hand.label_bet.Text = "+" + hand.Bet;

                }
                else{
                        // player wins
                        hand.result = BlackjackHand.Result.WIN;

                        // pay player
                        
                        if(hand.Sum == 21){
                            // 2.5 x bet if blackjack
                            win = (hand.Bet * 2) + (hand.Bet / 2);
                            player.Balance += win;
                            hand.label_bet.Text = "+" + win;
                        }
                        else{
                            // 2 x bet if win
                            win = hand.Bet * 2;
                            player.Balance += win;
                            hand.Bet = win;
                            hand.label_bet.Text = "+" + win;
                        }
                }

                // update label of the hand with results (SUM - WIN/LOSE/PUSH)
                form_controls.displayFinalResult(player.id, hand);
            }// close foreach
        }// close function
예제 #6
0
        // set List to store Player objects
        public void createPlayers(string num_players)
        {
            NumGamePlayers = int.Parse(num_players);
            NumActivePlayers = NumGamePlayers;

            // use NumPlayers to create CasinoPlayer objects 
            for (int i = 0; i < NumGamePlayers; i++)
            {
                BlackjackPlayer player = new BlackjackPlayer();       
                player.id = i;
                players.Add(player);
            }
        }