public Card DrawCardFromTop() { Card c = null; if (Cards.Count > 0) { c = Cards[Cards.Count - 1]; Cards.RemoveAt(Cards.Count - 1); //update Cards left text CardsLeftText.text = CardsLeft.ToString(); cardsInMotion.Add(c); DrawnCard = c; //move card to the top of other cards. DrawnCard.GO.transform.SetAsLastSibling(); s.CardsOnTable.Add(c); DrawnCard.Move(ShiftCardPosition(DrawPosition, Config.XStep, Config.YStep, drawnCards), Config.cardMovingSpeed, DoneDrawingCard); Condition = Condition.DrawingCard; //play draw card sound audioSource.Play(); } else { //here player is requested to draw card which he does not have. //it can only happen while betting because quantity of player Cards is checked at the end of each turn. Role = Role.Defeated; s.DoneDrawingCard(this); } return(c); }
private static IList <string> RenderCard(DrawnCard card) { if (card == null) { return(RenderNoCard()); } else if (card.OnHold) { return(RenderOnHoldCard(card.Card)); } else { return(RenderShownCard(card.Card)); } }
public void KeepDrawnCard() { if (DrawnCard == null) { throw new Exception("Player does not have a drawn card to keep."); } var newCard = DrawnCard.Clone(); DrawnCard = null; Hand.AddCard(newCard); if (CardKept != null) { CardKept(null, new PlayerCardEventArgs(this, newCard)); } }
private void Form1_Load(object sender, EventArgs e) { //プレイヤーの作成 player = new Player(); //ディーラーの作成 dealer = new Player(); //フロアレイアウトパネルの設定 flp = new FlowLayoutPanel[2]; for (int i = 0; i < flp.Length; i++) { flp[i] = new FlowLayoutPanel(); flp[i].Size = new Size(this.ClientSize.Width, 160); flp[i].Parent = this; } flp[0].Dock = DockStyle.Bottom; flp[1].Dock = DockStyle.Top; flp[1].FlowDirection = FlowDirection.RightToLeft; //引いたカードリストの作成 drawnCardList = new DrawnCard(); //プレイヤーの初期化 for (int i = 0; i < 2; i++) { player.DrawCard(drawnCardList); } label1.Text = player.Total().ToString(); //プレイヤーのカードの描画 PlayerDraw(); //ディーラーの初期化 for (int i = 0; i < 2; i++) { dealer.DrawCard(drawnCardList); } //ディーラーのカードの描画 DealerDraw(); }
//カードを引く public void DrawCard(DrawnCard drawnCard) { int type = random.Next(0); int number = random.Next(1, 8); ////すでに引いたカードかチェック bool drawn = drawnCard.DrawnCardCheck(type, number); //まだ引いてないカードが出るまで引く while (drawn) { type = random.Next(0); number = random.Next(1, 8); drawn = drawnCard.DrawnCardCheck(type, number); } //カードの作成 Card card = new Card(type, number); //引いたカードを引いたカードリストに登録 drawnCard.SetDrawnCard(type, number); //カードをリストに追加 cards.Add(card); }
private bool HasDrawnCard(ICard card) { return(DrawnCard != null && DrawnCard.Is(card)); }
private void BlackJack_Load(object sender, EventArgs e) { SplitLabel1.Enabled = false; SplitLabel2.Enabled = false; //プレイヤーの作成 player = new Player(); player.Number = 1; //ディーラーの作成 dealer = new Player(); dealer.Number = 0; //スプリットしたとき用のプレイヤー splitPlayer = new Player(); splitPlayer.Number = 2; //フローレイアウトパネルの設定 flp = new FlowLayoutPanel[2]; for (int i = 0; i < flp.Length; i++) { flp[i] = new FlowLayoutPanel(); } flp[0].Dock = DockStyle.Left; flp[1].Dock = DockStyle.Top; flp[1].FlowDirection = FlowDirection.RightToLeft; flp[0].Size = new Size(this.ClientSize.Width, 140); flp[1].Size = new Size(this.ClientSize.Width, 140); tableLayoutPanel1.Controls.Add(flp[0], 1, 6); tableLayoutPanel1.Controls.Add(flp[1], 1, 1); ////スプリット用の画面配置にする //for (int i = 0; i < 2; i++) //{ // sflp[i] = new FlowLayoutPanel(); // //flp[0].Controls.Add(sflp[i]); // sflp[i].Parent = flp[0]; //} //sflp[0].Size = new Size(this.ClientSize.Width / 2 - 120, 300); //sflp[1].Size = new Size(this.ClientSize.Width / 2 - 100, 300); for (int i = 0; i < 2; i++) { playerPictureBoxes[i] = new List <PictureBox>(); } //引いたカードリストの作成 drawnCardList = new DrawnCard(); //プレイヤーの初期化 for (int i = 0; i < 2; i++) { player.DrawCard(drawnCardList); } label1.Text = player.Total().ToString(); //プレイヤーのカードの描画 PlayerDraw(); //ディーラーの初期化 for (int i = 0; i < 2; i++) { dealer.DrawCard(drawnCardList); } //ディーラーのカードの描画 DealerDraw(true); SplitButton.Enabled = false; Split(); }