/// <summary> /// When user clicks the deck, we need to execute the next turn. /// </summary> public void OnUserDeckClick() { //Reset visuals UserCard.gameObject.SetActive(true); OpponentCard.gameObject.SetActive(true); UserTieParent.gameObject.SetActive(false); OpponentTieParent.gameObject.SetActive(false); BattleResultText.gameObject.SetActive(false); //Deal next round Card userCard = UserDeck.GetNextCard(); Card opponentCard = OpponentDeck.GetNextCard(); //Update visuals OpponentDeckSizeText.text = OpponentDeck.GetDeckSize().ToString(); UserDeckSizeText.text = UserDeck.GetDeckSize().ToString(); SetCardUI(UserCard.gameObject, userCard); SetCardUI(OpponentCard.gameObject, opponentCard); OpponentDeckSizeText.text = OpponentDeck.GetDeckSize().ToString(); UserDeckSizeText.text = UserDeck.GetDeckSize().ToString(); //Battle MatchupOutcomes outcome = userCard.Battle(opponentCard); if (outcome == MatchupOutcomes.Tie) { HandleTie(new List <Card>() { userCard, opponentCard }); } else { BattleResultText.gameObject.SetActive(true); if (outcome == MatchupOutcomes.Win) { BattleResultText.text = "You won this one!"; UserDeck.AddCardToBottom(userCard); UserDeck.AddCardToBottom(opponentCard); } else { BattleResultText.text = "You lost this one!"; OpponentDeck.AddCardToBottom(userCard); OpponentDeck.AddCardToBottom(opponentCard); } } OpponentDeckSizeText.text = OpponentDeck.GetDeckSize().ToString(); UserDeckSizeText.text = UserDeck.GetDeckSize().ToString(); if (UserDeck.GetDeckSize() == 0) { HandleEndGame(false); } if (OpponentDeck.GetDeckSize() == 0) { HandleEndGame(true); } }
public DeckTests() { Deck = new Deck(); Discards = new Deck(); Card1 = new Card { Suit = Card.CardSuit.Spades, Value = 1 }; Card2 = new Card { Suit = Card.CardSuit.Spades, Value = 2 }; Deck.AddCardToBottom(Card1); Discards.AddCardToBottom(Card2); Dealer = new Dealer { Deck = Deck, Discards = Discards }; Dealer.Init(); }
public void DiscardHandSlot(int slot) { Debug.Log($"Hand Discard ({slot})"); if (SelectedHandSlot == slot) { DeselectAll(); } var card = Hand.RemoveCardAtSlot(slot); if (card != null) { Deck.AddCardToBottom(card); } RedrawAll(); }
/// <summary> /// Start the game by instantiating the deck and passing out cards to user and opponent /// </summary> public void StartGame() { Deck startDeck = Deck.GetNewDeck(); OpponentDeck = new Deck(); UserDeck = new Deck(); for (int i = 0; i < Deck.NUM_CARDS_IN_DECK; i++) { if (i % 2 == 0) { OpponentDeck.AddCardToBottom(startDeck.GetNextCard()); } else { UserDeck.AddCardToBottom(startDeck.GetNextCard()); } } OpponentDeckSizeText.text = OpponentDeck.GetDeckSize().ToString(); UserDeckSizeText.text = UserDeck.GetDeckSize().ToString(); }