//创建一副牌 public Deck() { allCards = new Card[52]; this.count = 52; for (int j = 0; j < 4; j++) { for (int i = 0; i < 13; i++) { allCards[i + j * 13] = new Card((CardRank)i, (CardColor)j); }//点数 }//花色 }
private void Begin_btn_pic_Click(object sender, EventArgs e) { if (player.Points >= bet && banker.Points >= bet) { pictureBox1.Show(); pictureBox2.Show(); pictureBox3.Show(); pictureBox4.Show(); pictureBox5.Show(); Begin_btn_pic.Hide(); NewRound(); //开局每人人分两张牌 Card c = new Card(); c = deck.nextCard(); player.GetACard(c); player_card[0].Image = card_list.Images[c.CardIndex]; c = deck.nextCard(); banker.GetACard(c); banker_card[0].Image = card_list.Images[c.CardIndex]; c = deck.nextCard(); player.GetACard(c); player_card[1].Image = card_list.Images[c.CardIndex]; banker_hidden = deck.nextCard(); banker.GetACard(banker_hidden); //banker_card[1].Image = card_list.Images[c.CardIndex]; banker_card[1].Image = card_list.Images[52]; player_ranks.Text = player.TotalRanks.ToString(); banker_ranks.Text = "未知"; } else MessageBox.Show("游戏结束", "点数不足,游戏结束", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); }
private void Stop_Click(object sender, EventArgs e) { banker_card[1].Image = card_list.Images[banker_hidden.CardIndex]; if (!banker.GetNextCard() && banker.WinOrNot() == 0) { ComparedTo(); } else { while (banker.GetNextCard() && player.WinOrNot() == 0) { MessageBox.Show("庄家不够16点,补牌中"); if (banker.WinOrNot() == 0) { Card c=new Card(); c=deck.nextCard(); banker.GetACard(c); banker_card[banker.Card_count - 1].Image = card_list.Images[c.CardIndex]; banker_ranks.Text = banker.TotalRanks.ToString(); if (banker.WinOrNot() == 1) RoundOverAndWin(banker.Name, bet); if (banker.WinOrNot() == -1) RoundOverAndWin(player.Name, bet); } else { break; } } if (banker.WinOrNot() == 0 && player.WinOrNot() == 0) { ComparedTo(); } } }
private void Calling_Click(object sender, EventArgs e) { Card c = new Card(); c = deck.nextCard(); player.GetACard(c); player_card[player.Card_count - 1].Image = card_list.Images[c.CardIndex]; player_ranks.Text = player.TotalRanks.ToString(); if (player.WinOrNot() == 1) RoundOverAndWin(player.Name, bet); if (player.WinOrNot() == -1) RoundOverAndWin(banker.Name, bet); }
public Player(string name) { this.Name = name; cardList = new Card[52]; Points = 1000; }
public Player() { this.Name = "Bambie"; cardList = new Card[52]; Points = 1000; }
//方法 //收到牌后判断输赢 public void GetACard(Card next_card) { cardList[card_count] = next_card; card_count++; }