예제 #1
0
        private void btnContinue_Click(object sender, EventArgs e)
        {
            string name = txtName.Text;

            if (name == "Insert your name")
            {
                MessageBox.Show("Before continuing, please insert your name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                PlayerName = name;
                frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(name, 200000, 200000);
                onePlayerTable.Show();
                this.Hide();
            }
        }
예제 #2
0
        private void btnBegin_Click(object sender, EventArgs e)
        {
            if (txtPlayerBet.Text == "Bet" || txtPlayerBet.Text == "")
            {
                MessageBox.Show("Yo have to bet to start the game", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                player.BetValue = Convert.ToInt32(txtPlayerBet.Text);

                if (player.BetValue > 100000)
                {
                    MessageBox.Show("Bet must be less than 100,000", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (player.BetMoney > 0)
                    {
                        if (player.BetMoney >= player.BetValue)
                        {
                            player.BetMoney -= player.BetValue;
                            computer.Bet();
                            txtComputerBet.Text = computer.BetValue.ToString();

                            btnBegin.Enabled              = false;
                            txtPlayerBet.Enabled          = false;
                            lblTurn.Visible               = true;
                            btnAsk.Enabled                = true;
                            btnPass.Enabled               = true;
                            btnBegin.Enabled              = false;
                            lblPlayerTotalMoney.Text      = player.BetMoney.ToString();
                            lblComputerTotalMoney.Text    = computer.BetMoney.ToString();
                            lblComputerTotalMoney.Visible = true;
                            lblPlayerTotalMoney.Visible   = true;
                            btnAsk.Visible                = true;
                            btnPass.Visible               = true;

                            if (checkDrawBegin())
                            {
                                DialogResult result;
                                result = MessageBox.Show("¡¡It's a tie!!", "Draw", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

                                if (result == System.Windows.Forms.DialogResult.Retry)
                                {
                                    computer.BetMoney += computer.BetValue;
                                    player.BetMoney   += player.BetValue;
                                    frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                                    int temp1 = onePlayerTable.computer.Accumulated;
                                    int temp2 = onePlayerTable.player.Accumulated;

                                    onePlayerTable.computer             = this.computer;
                                    onePlayerTable.player               = this.player;
                                    onePlayerTable.computer.Accumulated = temp1;
                                    onePlayerTable.player.Accumulated   = temp2;


                                    onePlayerTable.Show();
                                    this.Hide();
                                }
                                else if (result == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    frmMainMenu mainMenu = new frmMainMenu();
                                    mainMenu.Show();
                                    this.Close();
                                }
                            }
                            else if (CheckVictoryPlayer())
                            {
                                DialogResult result;
                                result = MessageBox.Show("¡¡You won!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

                                if (result == System.Windows.Forms.DialogResult.Retry)
                                {
                                    player.BetMoney += player.BetValue + computer.BetValue;
                                    frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                                    int temp1 = onePlayerTable.computer.Accumulated;
                                    int temp2 = onePlayerTable.player.Accumulated;

                                    onePlayerTable.computer             = this.computer;
                                    onePlayerTable.player               = this.player;
                                    onePlayerTable.computer.Accumulated = temp1;
                                    onePlayerTable.player.Accumulated   = temp2;


                                    onePlayerTable.Show();
                                    this.Hide();
                                }
                                else if (result == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    frmMainMenu mainMenu = new frmMainMenu();
                                    mainMenu.Show();
                                    this.Close();
                                }
                            }
                            else if (CheckVictoryComputer())
                            {
                                DialogResult result;
                                result = MessageBox.Show("¡¡You lose!!", "Defeat", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

                                if (result == System.Windows.Forms.DialogResult.Retry)
                                {
                                    computer.BetMoney += player.BetValue + computer.BetValue;

                                    frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                                    int temp1 = onePlayerTable.computer.Accumulated;
                                    int temp2 = onePlayerTable.player.Accumulated;

                                    onePlayerTable.computer             = this.computer;
                                    onePlayerTable.player               = this.player;
                                    onePlayerTable.computer.Accumulated = temp1;
                                    onePlayerTable.player.Accumulated   = temp2;

                                    onePlayerTable.Show();
                                    this.Hide();
                                }
                                else if (result == System.Windows.Forms.DialogResult.Cancel)
                                {
                                    frmMainMenu mainMenu = new frmMainMenu();
                                    mainMenu.Show();
                                    this.Close();
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("You don't have all that money available", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                    else
                    {
                        DialogResult result;
                        result = MessageBox.Show("You lost all your money", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        if (result == System.Windows.Forms.DialogResult.OK)
                        {
                            frmMainMenu mainMenu = new frmMainMenu();
                            mainMenu.Show();
                            this.Close();
                        }
                    }
                }
            }
        }
예제 #3
0
        private void CheckVictory()
        {
            if (!CheckDefeatPlayer() && !CheckDefeatComputer() && !CheckVictoryPlayer() && !CheckVictoryComputer())
            {
                if (player.Accumulated > computer.Accumulated)
                {
                    lblComputerScore.Text = computer.Accumulated.ToString();
                    DialogResult result;
                    result = MessageBox.Show("¡¡You have won with a score of " + player.Accumulated + " points!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player.BetMoney += player.BetValue + computer.BetValue;
                        frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                        int temp1 = onePlayerTable.computer.Accumulated;
                        int temp2 = onePlayerTable.player.Accumulated;

                        onePlayerTable.computer             = this.computer;
                        onePlayerTable.player               = this.player;
                        onePlayerTable.computer.Accumulated = temp1;
                        onePlayerTable.player.Accumulated   = temp2;


                        onePlayerTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
                else if (player.Accumulated < computer.Accumulated)
                {
                    lblComputerScore.Text = computer.Accumulated.ToString();
                    DialogResult result;
                    result = MessageBox.Show("¡¡You have lost to a score of  " + computer.Accumulated + " points!!", "Defeat", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        computer.BetMoney += player.BetValue + computer.BetValue;
                        frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                        int temp1 = onePlayerTable.computer.Accumulated;
                        int temp2 = onePlayerTable.player.Accumulated;

                        onePlayerTable.computer             = this.computer;
                        onePlayerTable.player               = this.player;
                        onePlayerTable.computer.Accumulated = temp1;
                        onePlayerTable.player.Accumulated   = temp2;


                        onePlayerTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
                else
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡It's a tie!!", "Draw", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        computer.BetMoney += computer.BetValue;
                        player.BetMoney   += player.BetValue;

                        frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                        int temp1 = onePlayerTable.computer.Accumulated;
                        int temp2 = onePlayerTable.player.Accumulated;

                        onePlayerTable.computer             = this.computer;
                        onePlayerTable.player               = this.player;
                        onePlayerTable.computer.Accumulated = temp1;
                        onePlayerTable.player.Accumulated   = temp2;

                        onePlayerTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
            }
        }
예제 #4
0
        public void GiveCardPlayer()
        {
            if (!CheckCardsGiven())
            {
                player.ExtraCard    = deck.GetDeck()[cardsGiven];
                lblPECS1.Text       = player.ExtraCard.CardSymbol;
                lblPECS2.Text       = player.ExtraCard.CardSymbol;
                lblPECT.Text        = player.ExtraCard.CardType.ToString();
                player.Accumulated += player.ExtraCard.CardValue;
                lblPlayerScore.Text = player.Accumulated.ToString();
                cardsGiven++;

                if (CheckVictoryPlayer())
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡You won!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);

                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player.BetMoney += player.BetValue + computer.BetValue;
                        frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                        int temp1 = onePlayerTable.computer.Accumulated;
                        int temp2 = onePlayerTable.player.Accumulated;

                        onePlayerTable.computer             = this.computer;
                        onePlayerTable.player               = this.player;
                        onePlayerTable.computer.Accumulated = temp1;
                        onePlayerTable.player.Accumulated   = temp2;

                        onePlayerTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
                else if (CheckDefeatPlayer())
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡You lose!!", "Defeat", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        computer.BetMoney += player.BetValue + computer.BetValue;
                        frmOnePlayerTable onePlayerTable = new frmOnePlayerTable(player.Name, player.BetMoney, computer.BetMoney);

                        int temp1 = onePlayerTable.computer.Accumulated;
                        int temp2 = onePlayerTable.player.Accumulated;

                        onePlayerTable.computer             = this.computer;
                        onePlayerTable.player               = this.player;
                        onePlayerTable.computer.Accumulated = temp1;
                        onePlayerTable.player.Accumulated   = temp2;

                        onePlayerTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
            }
            else
            {
                deck.SortDeck();
                cardsGiven = 0;
                GiveCardPlayer();
            }
        }