void ShuffleCards() { // Remove all cards from present deck. deck.Clear(); ShuffleInts shuffle = new ShuffleInts(); int[] shuffleOrder = shuffle.Shuffle(54); for(var i = 0; i < shuffleOrder.Length; i++) { deck.Add(playingCards[shuffleOrder[i]]); } StartCoroutine( DealCards() ); }
void ChooseAction() { int[] playOrder = shuffle.Shuffle(hand.Count); for (var i = 0; i < playOrder.Length; i++) { // Check if the card breaks the rules, if it does, skip it. if (!controller.rules.CheckCardValidity(playedCards[playedCards.Count - 1], hand[playOrder[i]])) { continue; } // If a suitable card is found, play it. else if (hand[playOrder[i]].Suit != "Joker") { Debug.Log("AI Playing card"); RemoveCard(hand[playOrder[i]]); return; } } // If no suitable cards are found, play any wild cards. foreach (PlayingCard card in hand) { if (card.Suit == "Joker") { Debug.Log("AI Playing card"); RemoveCard(card); return; } } // None of the cards passed the rules so pickup (if the deck isn't empty). if (deck.Count > 0) { AddCard(deck[0], true); deck.RemoveAt(0); } else { Debug.Log("AI Player knocking!"); timeOffset = Time.time + 0.3f; delay = true; } }