Esempio n. 1
0
        private void FrmTwoPlayersTable_FormClosing(object sender, FormClosingEventArgs e)
        {
            frmMainMenu mainMenu = new frmMainMenu();

            mainMenu.Show();
            this.Hide();
        }
Esempio n. 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();
                        }
                    }
                }
            }
        }
Esempio n. 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();
                    }
                }
            }
        }
Esempio n. 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();
            }
        }
Esempio n. 5
0
        private void CheckVictory()
        {
            if (!CheckDefeatPlayer() && !CheckDefeatPlayer2() && !CheckVictoryPlayer() && !CheckVictoryPlayer2())
            {
                if (player1.Accumulated > player2.Accumulated)
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡Player 1 has won with a score of " + player1.Accumulated + " points!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player1.BetMoney += player1.BetValue + player2.BetValue;
                        frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(player1.Name, player1.BetMoney, player2.Name, player2.BetMoney);

                        int temp1 = twoPlayersTable.player2.Accumulated;
                        int temp2 = twoPlayersTable.player1.Accumulated;

                        twoPlayersTable.player2             = this.player2;
                        twoPlayersTable.player1             = this.player1;
                        twoPlayersTable.player2.Accumulated = temp1;
                        twoPlayersTable.player1.Accumulated = temp2;


                        twoPlayersTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
                else if (player1.Accumulated < player2.Accumulated)
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡Player 2 has won with a score of  " + player2.Accumulated + " points!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player2.BetMoney += player1.BetValue + player2.BetValue;
                        frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(player1.Name, player1.BetMoney, player2.Name, player2.BetMoney);

                        int temp1 = twoPlayersTable.player2.Accumulated;
                        int temp2 = twoPlayersTable.player1.Accumulated;

                        twoPlayersTable.player2             = this.player2;
                        twoPlayersTable.player1             = this.player1;
                        twoPlayersTable.player2.Accumulated = temp1;
                        twoPlayersTable.player1.Accumulated = temp2;

                        this.Hide();
                        twoPlayersTable.Show();
                    }
                    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)
                    {
                        player2.BetMoney += player2.BetValue;
                        player1.BetMoney += player1.BetValue;

                        frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(player1.Name, player1.BetMoney, player2.Name, player2.BetMoney);

                        int temp1 = twoPlayersTable.player2.Accumulated;
                        int temp2 = twoPlayersTable.player1.Accumulated;

                        twoPlayersTable.player2             = this.player2;
                        twoPlayersTable.player1             = this.player1;
                        twoPlayersTable.player2.Accumulated = temp1;
                        twoPlayersTable.player1.Accumulated = temp2;

                        twoPlayersTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
            }
        }
Esempio n. 6
0
        public void GiveCardPlayer2()
        {
            if (!CheckCardsGiven())
            {
                player2.ExtraCard    = deck.GetDeck()[cardsGiven];
                lblCECS1.Text        = player2.ExtraCard.CardSymbol;
                lblCECS2.Text        = player2.ExtraCard.CardSymbol;
                lblCECT.Text         = player2.ExtraCard.CardType.ToString();
                player2.Accumulated += player2.ExtraCard.CardValue;
                lblPlayer2Score.Text = player2.Accumulated.ToString();
                cardsGiven++;

                if (CheckVictoryPlayer2())
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡Player 2 wins!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player2.BetMoney += player1.BetValue + player2.BetValue;

                        frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(player1.Name, player1.BetMoney, player2.Name, player2.BetMoney);

                        int temp1 = twoPlayersTable.player2.Accumulated;
                        int temp2 = twoPlayersTable.player1.Accumulated;

                        twoPlayersTable.player2             = this.player2;
                        twoPlayersTable.player1             = this.player1;
                        twoPlayersTable.player2.Accumulated = temp1;
                        twoPlayersTable.player1.Accumulated = temp2;

                        twoPlayersTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
                else if (CheckDefeatPlayer2())
                {
                    DialogResult result;
                    result = MessageBox.Show("¡¡Player 1 wins!!", "Victory", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        player1.BetMoney += player1.BetValue + player2.BetValue;

                        frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(player1.Name, player1.BetMoney, player2.Name, player2.BetMoney);

                        int temp1 = twoPlayersTable.player2.Accumulated;
                        int temp2 = twoPlayersTable.player1.Accumulated;

                        twoPlayersTable.player2             = this.player2;
                        twoPlayersTable.player1             = this.player1;
                        twoPlayersTable.player2.Accumulated = temp1;
                        twoPlayersTable.player1.Accumulated = temp2;
                        twoPlayersTable.Show();
                        this.Hide();
                    }
                    else if (result == System.Windows.Forms.DialogResult.Cancel)
                    {
                        frmMainMenu mainMenu = new frmMainMenu();
                        mainMenu.Show();
                        this.Close();
                    }
                }
            }
            else
            {
                deck.SortDeck();
                cardsGiven = 0;
                GiveCardPlayer2();
            }
        }