Ejemplo n.º 1
0
        /* Constructor to initialize the fields*/
        public main()
        {
            InitializeComponent();
            // buttons
            dealButton.Visible = false; standButton.Enabled = false;
            hitButton.Enabled  = false; doubleButton.Enabled = false;
            betButton.Enabled  = false; surrender.Visible = false;
            // coins/chips
            whiteCoin.Enabled = true; blueCoin.Enabled = true;
            redCoin.Enabled   = true; blackCoin.Enabled = true;
            greenCoin.Enabled = true;
            // player cards
            playerCard1.Visible = false; playerCard2.Visible = false;
            playerCard3.Visible = false; playerCard4.Visible = false;
            playerCard5.Visible = false; dealerCard1.Visible = false;
            // dealer cards
            dealerCard2.Visible = false; dealerCard3.Visible = false;
            dealerCard4.Visible = false; dealerCard5.Visible = false;
            dealerLabel.Visible = false;

            playerLabel.Visible = false;
            // value of cards
            handPlayer      = new HandPlayer();
            handDealer      = new HandDealer();
            playerCounter   = 0; // counter to draw more cards
            coinsTotal      = 1500;
            bet             = 0; surrenderCounter = 0;
            coinsLabel.Text = " = $" + coinsTotal.ToString();
            betLabel.Text   = "Click on chips to bet!: $" + bet.ToString();

            exitTimer.Elapsed += new ElapsedEventHandler(CloseEvent); // elapse time to exit application
            exitTimer.Interval = 1500;                                // set an interval
        }
Ejemplo n.º 2
0
        /* Starts a new round by enabling/disabling buttons, labels, and cards.
         * Sets values back to 0
         */
        private void newRound()
        {
            // start new game if players clicks on new game button
            newGame.Play(); // new game sound
            // reset buttons
            dealButton.Visible = false; standButton.Enabled = false;
            hitButton.Enabled  = false; doubleButton.Enabled = false;
            betButton.Enabled  = false; surrender.Visible = false;
            // rest coins/chips
            whiteCoin.Enabled = true; blueCoin.Enabled = true;
            redCoin.Enabled   = true; blackCoin.Enabled = true;
            greenCoin.Enabled = true;
            // reset player cards
            playerCard1.Visible = false; playerCard2.Visible = false;
            playerCard3.Visible = false; playerCard4.Visible = false;
            playerCard5.Visible = false;
            // reset dealer cards
            dealerCard1.Visible = false; dealerCard2.Visible = false;
            dealerCard3.Visible = false; dealerCard4.Visible = false;
            dealerCard5.Visible = false; dealerLabel.Visible = false;

            gameOverLabel.Visible = false;
            endGame.Visible       = false; dealerEndGame.Visible = false;
            playerLabel.Visible   = false;
            betButton.Visible     = true; amountWin.Visible = false;
            // values in hand
            valuePlayer.Visible = false; valueDealer.Visible = false; standDealer.Visible = false;

            handPlayer = new HandPlayer(); // set values in hand back to zero
            handDealer = new HandDealer(); // set values in hand back to zero

            playerCounter = 0;             // counter to draw more cards back to zero

            // start new round if player surrenders
            if (surrenderCounter == 0)
            {
                coinsTotal      = 1500;
                bet             = 0;
                coinsLabel.Text = " = $" + coinsTotal.ToString();
                betLabel.Text   = "Click on chips to bet!: $" + bet.ToString();
            }
            else if (surrenderCounter == 1)
            {
                coinsTotal      = coinsTotal + bet - (bet / 2);
                coinsLabel.Text = " = $" + coinsTotal.ToString();
                bet             = 0;
                betLabel.Text   = "You surrended! Click on chips to bet!: $" + bet.ToString();
                surrenderCounter--; // back to zero
            }
        }
Ejemplo n.º 3
0
        /* Resets labels and images on table for the next round*/
        private void resetTable()
        {
            whiteCoin.Enabled = true; redCoin.Enabled = true;
            blackCoin.Enabled = true; greenCoin.Enabled = true;
            blueCoin.Enabled  = true;

            dealButton.Visible  = false; betButton.Visible = true;
            betButton.Enabled   = false; hitButton.Enabled = false;
            standButton.Enabled = false; amountWin.Visible = false;

            handPlayer    = new HandPlayer(); // set values in hand back to zero
            handDealer    = new HandDealer(); // set values in hand back to zero
            playerCounter = 0;
        }