/// <summary> /// An attempt to jump start the game when no player can act and the game is not yet over. /// Plays one card each from their closed stacks on hand to respective open stack. /// </summary> public void Draw() { // Stale mate, players pick up the respective stack. Two cards are needed to do a draw. if ((PlayerOne.Hand.Cards.Count + PlayerTwo.Hand.Cards.Count) < 2) { while (LeftStack.Cards.Count > 0) { PlayerOne.PickUpCard(LeftStack.DrawCard()); } while (RightStack.Cards.Count > 0) { PlayerTwo.PickUpCard(RightStack.DrawCard()); } } // If one player has an empty hand, and the other player has more than one card on hand // the player without a card will draw one from the other players hand. if (PlayerOne.Hand.Cards.Count == 0 && PlayerTwo.Hand.Cards.Count > 1) { PlayerOne.Hand.Cards.Push(PlayerTwo.Hand.DrawCard()); } else if (PlayerTwo.Hand.Cards.Count == 0 && PlayerOne.Hand.Cards.Count > 1) { PlayerTwo.Hand.Cards.Push(PlayerOne.Hand.DrawCard()); } LeftStack.AddCard(PlayerOne.Hand.DrawCard(), true); RightStack.AddCard(PlayerTwo.Hand.DrawCard(), true); }
/// <summary> /// If the players are ready, deal the full deck of cards to the players. /// </summary> public void Deal() { if (!CanStart()) { throw new InvalidOperationException("Game is not in a ready state"); } while (Deck.Cards.Count > 0) { var drawnCard = Deck.DrawCard(); if (drawnCard != null) { PlayerOne.PickUpCard(drawnCard); } drawnCard = Deck.DrawCard(); if (drawnCard != null) { PlayerTwo.PickUpCard(drawnCard); } } }