예제 #1
0
        private void BtnContinuar_Click(object sender, EventArgs e)
        {
            string name  = txtNombre.Text;
            string name2 = txtNombre2.Text;

            if (name == "Insert name player 1" || name2 == "Insert name player 2" || name2 == "")
            {
                MessageBox.Show("Before continuing, please insert your name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                PlayerName1 = name;
                PlayerName2 = name2;
                frmTwoPlayersTable twoPlayersTable = new frmTwoPlayersTable(name, 200000, name2, 200000);
                twoPlayersTable.Show();
                this.Hide();
            }
        }
예제 #2
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();
                    }
                }
            }
        }
예제 #3
0
        private void BtnBegin_Click(object sender, EventArgs e)
        {
            if (txtPlayerBet.Text == "Bet" || txtPlayerBet.Text == "" || txtPlayerBet2.Text == "Bet" || txtPlayerBet2.Text == "")
            {
                MessageBox.Show("Yo have to bet to start the game", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                player1.BetValue = Convert.ToInt32(txtPlayerBet.Text);
                player2.BetValue = Convert.ToInt32(txtPlayerBet2.Text);

                if (player1.BetValue > 100000 || player2.BetValue > 100000)
                {
                    MessageBox.Show("Bet must be less than 100,000", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (player1.BetMoney > 0 && player2.BetMoney > 0)
                    {
                        if (player1.BetMoney >= player1.BetValue && player2.BetMoney >= player2.BetValue)
                        {
                            player1.BetMoney -= player1.BetValue;
                            player2.BetMoney -= player2.BetValue;

                            btnBegin.Enabled             = false;
                            txtPlayerBet.Enabled         = false;
                            txtPlayerBet2.Enabled        = false;
                            lblTurn.Visible              = true;
                            btnAsk.Enabled               = true;
                            btnPass.Enabled              = true;
                            btnBegin.Enabled             = false;
                            lblPlayerTotalMoney.Text     = player1.BetMoney.ToString();
                            lblPlayer2TotalMoney.Text    = player2.BetMoney.ToString();
                            lblPlayer2TotalMoney.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)
                                {
                                    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();
                                }
                            }
                            else if (CheckVictoryPlayer())
                            {
                                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 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;

                                    this.Hide();
                                    twoPlayersTable.Show();
                                }
                                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();
                        }
                    }
                }
            }
        }
예제 #4
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();
            }
        }