//generates standard 52 card deck public void createDeck(onePlayerGame game) { Card[] cards = new Card[52]; //generates deck with array of card objects int index = 0; for (int suit = 1; suit <= 4; suit++) { for (int value = 2; value <= 14; value++) { cards[index] = new Card(value, suit, new PictureBox(), "C:\\Users\\Herndel\\Desktop\\Blackjack Project\\Blackjack Images\\Playing Cards\\" + suit + "\\" + suit + "_of_" + value + ".png"); index++; } } //catches the addition of the face cards and the aces. This then changes their value accordingly //this makes the order of values strange, (2-11, then 3 additional 10's) for (int x = 0; x < cards.Length; x++) { if (cards[x].cardValue >= 11 && cards[x].cardValue != 14) { cards[x].cardValue = 10; } if (cards[x].cardValue == 14) { cards[x].cardValue = 11; } } game.deck = new List <Card>(cards); }
public bettingWindow() { InitializeComponent(); onePlayerGame game = new onePlayerGame(); currentChipsTextBox.Text = game.player1.chipTotal + ""; currentChipsTextBox.Enabled = false; }
private void onePlayerButton_Click(object sender, EventArgs e) { this.Hide(); onePlayerGame game1 = new onePlayerGame(); game1.StartPosition = FormStartPosition.CenterScreen; game1.Show(); bettingWindow betWindow = new bettingWindow(); betWindow.StartPosition = FormStartPosition.CenterScreen; betWindow.Show(); }
private void acceptButton_Click(object sender, EventArgs e) { onePlayerGame game = new onePlayerGame(); //if(desiredWagerUpDown.) if (Convert.ToInt32(Math.Round(desiredWagerUpDown.Value, 0)) > game.player1.chipTotal) { MessageBox.Show("Insufficient amount of chips!"); } else if (Convert.ToInt32(Math.Round(desiredWagerUpDown.Value, 0)) <= 0) { MessageBox.Show("You must bet over $0!"); } else { game.player1.chipTotal = game.player1.chipTotal - Convert.ToInt32(Math.Round(desiredWagerUpDown.Value, 0)); bet = Convert.ToInt32(Math.Round(desiredWagerUpDown.Value, 0)); this.Hide(); Console.WriteLine(game.player1.chipTotal); } }
//resets hand totals for the player and dealer //eventually find a way to move into reset() method public void resetHandTotals(onePlayerGame game) { game.player1.handTotal = 0; game.dealer.handTotal = 0; }