Ejemplo n.º 1
0
        public void interpret_state()
        {
            switch (state)
            {
            case 0:     //pre-deal
                lblResults.Visible = false;
                btnDeal.Enabled    = true;
                btnHit.Enabled     = false;
                btnStand.Enabled   = true;
                btnShuffle.Enabled = true;
                break;

            case 1:     //Game in Play
                lblResults.Visible = false;
                btnDeal.Enabled    = false;
                btnHit.Enabled     = true;
                btnShuffle.Enabled = false;
                break;

            case 2:     //Bust
                lblResults.Text      = "BUST!";
                lblResults.ForeColor = Color.Red;
                lblResults.Visible   = true;
                btnDeal.Enabled      = true;
                btnHit.Enabled       = false;
                btnStand.Enabled     = false;
                btnShuffle.Enabled   = true;
                player1.evaluateBet("loss");
                break;

            case 3:     //BlackJack
                lblResults.Text      = "BlackJack!";
                lblResults.ForeColor = Color.Gold;
                lblResults.Visible   = true;
                btnDeal.Enabled      = true;
                btnHit.Enabled       = false;
                btnShuffle.Enabled   = true;
                player1.evaluateBet("BJ");
                break;

            case 4:     //evaluate hands
                if (dealer.getValue() > 21)
                {
                    lblResults.Text = "Player Wins!";
                    player1.evaluateBet("win");
                }
                else if (player.getValue() > dealer.getValue())
                {
                    lblResults.Text = "Player Wins!";
                    player1.evaluateBet("win");
                }
                else if (player.getValue() == dealer.getValue())
                {
                    lblResults.Text = "Push!";
                    player1.evaluateBet("push");
                }
                else if (player.getValue() < dealer.getValue())
                {
                    lblResults.Text = "Dealer Wins!";
                    player1.evaluateBet("loss");
                }
                lblResults.ForeColor = Color.Black;
                lblResults.Visible   = true;
                btnHit.Enabled       = false;
                btnDeal.Enabled      = true;
                btnShuffle.Enabled   = true;
                break;
            }
        }