public MyPictureBox(Card c, bool player, int index) : base() { this.Image = Game.cardHelper.drawCard(c.Color, c.Number); this.Location = new Point(105 + index*40, player ? 344 : 124); this.SizeMode = PictureBoxSizeMode.StretchImage; this.Name = "romanalex_card_" + player + "_" + index; Size tempSize = this.Size; tempSize.Height = 137; this.Size = tempSize; }
private void drawPictureBackcard(Card c, bool player, int index) { PictureBox pic = new MyPictureBox(player, index, true); form.Controls.Add(pic); pic.BringToFront(); }
private void addNewCard(Card c, bool player) { gameHelper.calcPoints(c, player); drawPicture(c, player, (player ? cardIndexPlayer++ : cardIndexBank++)); renderPoints(); if (player) { if(gameHelper.points_player == 21) { bankStep(); } else if(gameHelper.points_player > 21) { showWinMessage("Oops!", "You Loose! You're over 21 points :-("); } } }
public void calcPoints(Card c, bool player) { if(player) { this.points_player += getPointsOfCard(c, player); if((this.points_player >21) && (this.count_aces_player > 0)) { this.points_player -= 10; this.count_aces_player--; } } else { this.points_bank += getPointsOfCard(c, player); if ((this.points_bank > 21) && (this.count_aces_bank > 0)) { this.points_bank -= 10; this.count_aces_bank--; } } this.total_points += c.Number; }
public int getPointsOfCard(Card c, bool player) { if (c.Number<9) { return c.Number+2; } else if(c.Number < 12) { return 10; } //falls Ass if(player) { this.count_aces_player++; } else { this.count_aces_bank++; } return 11; }