void DealStarte() { Card temp = deck.Pop(); pictureBox1.Image = temp.GetImage(); playval += temp.value; if (temp.value == 11) { pace++; } temp = deck.Pop(); pictureBox2.Image = temp.GetImage(); playval += temp.value; if (temp.value == 11) { pace++; } temp = deck.Pop(); AIval += temp.value; pictureBox5.Image = temp.GetImage(); if (temp.value == 11) { AIce++; } pictureBox6.Image = Properties.Resources.gbCard52; temp = deck.Pop(); pictureBox15.SendToBack(); pictureBox15.Image = temp.GetImage(); AIval += temp.value; if (temp.value == 11) { AIce++; } }
private void NANI_Click(object sender, EventArgs e) { if (playval < 21) { Card temp = deck.Pop(); if (pictureBox3.Image == null) { pictureBox3.Image = temp.GetImage(); } else if (pictureBox7.Image == null) { pictureBox7.Image = temp.GetImage(); } else if (pictureBox8.Image == null) { pictureBox8.Image = temp.GetImage(); } else if (pictureBox9.Image == null) { pictureBox9.Image = temp.GetImage(); } else if (pictureBox10.Image == null) { pictureBox10.Image = temp.GetImage(); } else if (pictureBox11.Image == null) { pictureBox11.Image = temp.GetImage(); } else if (pictureBox12.Image == null) { pictureBox12.Image = temp.GetImage(); } else if (pictureBox13.Image == null) { pictureBox13.Image = temp.GetImage(); } else if (pictureBox14.Image == null) { pictureBox14.Image = temp.GetImage(); } else { deck.Push(temp); } if (temp.value == 11) { pace++; } playval += temp.value; //if (pad == true && temp.value == 11) //{ // playval -= 10; //} } }
internal void AddCard(Card card, bool isDealer) {//display the card //Add Picture box with new card, PictureBox pictureBox = new PictureBox(); pictureBox.Image = card.GetImage(); //pictureBox.Image = Images.ace_of_clubs; if (!isDealer) { PlayerPoint.X += cardXchange; PlayerPoint.Y += 8; pictureBox.Location = PlayerPoint; //ADD FUNCTION HERE // lblPlayerHandScore.Text = game.player.score.ToString(); updatePlayerHandScoreLabel(game.playerList[game.currentHand - 1]); playerPics.Add(pictureBox); } else { DealerPoint.X += cardXchange; DealerPoint.Y += 8; pictureBox.Location = DealerPoint; lblDealerHandScore.Text = game.dealer.score.ToString(); if (dealerPics.Count() == 1) { pictureBox.Image = Images.back; } dealerPics.Add(pictureBox); } pictureBox.Size = new Size(80, 100); pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.BackColor = Color.White; Controls.Add(pictureBox); pictureBox.BringToFront(); }
private void timer1_Tick(object sender, EventArgs e) { label1.Text = playval.ToString(); label2.Text = AIval.ToString(); CheckAce(); if (AIHit == true) { if (AIval > 16 && AIHit == true) { roundend = true; label3.Visible = true; pictureBox6.SendToBack(); AIHit = false; } else { Card temp = deck.Pop(); if (pictureBox4.Image == null) { pictureBox4.Image = temp.GetImage(); } else if (pictureBox16.Image == null) { pictureBox16.Image = temp.GetImage(); } else if (pictureBox17.Image == null) { pictureBox17.Image = temp.GetImage(); } else if (pictureBox18.Image == null) { pictureBox18.Image = temp.GetImage(); } else if (pictureBox19.Image == null) { pictureBox19.Image = temp.GetImage(); } else if (pictureBox20.Image == temp.GetImage()) { pictureBox20.Image = temp.GetImage(); } else if (pictureBox21.Image == null) { pictureBox21.Image = temp.GetImage(); } else if (pictureBox22.Image == null) { pictureBox22.Image = temp.GetImage(); } else if (pictureBox23.Image == null) { pictureBox23.Image = temp.GetImage(); } else { deck.Push(temp); } if (temp.value == 11) { AIce++; } AIval += temp.value; } } CheckAce(); int checkWin = -1; if (playval > 21 || AIval > 21) { roundend = true; } if (roundend == true) { pictureBox6.SendToBack(); } if (roundend == true || playval > 21 || AIval > 21) { checkWin = isWin(); } if (checkWin == 2) { label3.Text = "Nice job winning against the AI!"; timer1.Enabled = false; DealDat.Visible = true; button1.Visible = false; Hit.Visible = false; } else if (checkWin == 0) { label3.Text = "You lose..."; timer1.Enabled = false; DealDat.Visible = true; button1.Visible = false; Hit.Visible = false; } else if (checkWin == 1) { label3.Text = "You tied."; DealDat.Visible = true; button1.Visible = false; Hit.Visible = false; timer1.Enabled = false; } if (roundend == false) { label3.Text = "Round in progress... Please wait for results."; } }