private IEnumerator tallyUpTheFinalScore() { Debug.Assert(Deck.CountCardsLeft <= 1); float waitBetweenCardFlips = TurboMode ? 0 : 0.5f; // Wait until every player is ready, just in case yield return(new WaitUntil(() => (EveryoneReady && AllCardsDown))); // Flip all the cards that are still not flipped float waitUntil = Time.timeSinceLevelLoad; // First, check if there is still a card in the deck // (there should be, unless a Prince has been played in the ver last turn) CardController cc; if (Deck.CountCardsLeft > 0) { waitUntil += waitBetweenCardFlips; yield return(new WaitUntil(() => (Time.timeSinceLevelLoad > waitUntil))); // Reveal the card cc = Deck.Draw(); cc.FlipUp(); Debug.LogFormat("The final card in the deck was the {0}!", cc); } // Then go through still-active players and find the winner int highestValue = 0, highestTotalDiscardedValue = 0; PlayerController winner = Players[0]; foreach (PlayerController p in Players) { if (!p.KnockedOut) { waitUntil += waitBetweenCardFlips; yield return(new WaitUntil(() => (Time.timeSinceLevelLoad > waitUntil))); // Reveal the hand cc = p.GetHand(); cc.FlipUp(); Debug.LogFormat("{0} had the {1}!", p, cc); // Update the winner if (cc.Value > highestValue || (cc.Value == highestValue && p.TotalDiscardedValue > highestTotalDiscardedValue)) { winner = p; highestValue = cc.Value; highestTotalDiscardedValue = p.TotalDiscardedValue; } } } // Congratulate the winner Debug.LogFormat("{0} wins this round with the {1}!", winner, winner.GetHand()); StartCoroutine(bestowHeart(winner)); }
private IEnumerator Draw() { GameState = GameState.Draw; while ((_attackingHand.Container.Cards.Count < _cardsPerHand || _defendingHand.Container.Cards.Count < _cardsPerHand) && _deck.Container.Cards.Count > 0) { if (_attackingHand.Container.Cards.Count < _cardsPerHand) { yield return(new WaitForSeconds(0.4f)); _attackingHand.Container.AddCard(_deck.Draw()); } if (_defendingHand.Container.Cards.Count < _cardsPerHand) { yield return(new WaitForSeconds(0.4f)); _defendingHand.Container.AddCard(_deck.Draw()); } } CheckGame(); }