public override IEnumerator UsePower(int index = 0) { List <int> powerNumerals = new List <int>() { this.GetPowerNumeral(0, 1), // Number of targets. this.GetPowerNumeral(1, 1), // Amount of damage. }; List <DealDamageAction> storedResults = new List <DealDamageAction>(); IEnumerator coroutine; // Deal up to 1 targets damage. coroutine = this.GameController.SelectTargetsAndDealDamage(this.DecisionMaker, new DamageSource(this.GameController, this.CharacterCard), powerNumerals[1], DamageType.Fire, powerNumerals[0], false, powerNumerals[0], true, storedResultsDamage: storedResults, cardSource: this.GetCardSource(null)); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } // If damaged targets are destroyed. This is weird in case of redirectors, but blame Wrecking Uppercut for doing it this way, opposed to 'original target'. IEnumerable <Card> damageTargets = from dd in storedResults select dd.Target; if (damageTargets.Count <Card>() > 0) { DestroyCardJournalEntry destroyCardJournalEntry = (from dcje in this.Journal.DestroyCardEntriesThisTurn() where damageTargets.Contains(dcje.Card) select dcje).LastOrDefault <DestroyCardJournalEntry>(); if (destroyCardJournalEntry != null && destroyCardJournalEntry.Card != null) { coroutine = this.GameController.UsePower(this.CardWithoutReplacements, 0, true, this.GetCardSource()); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } } } }
public void TestUpCloseDestroysSelfWhenNoValidHero() { SetupGameController("Cauldron.TheRam", "Legacy", "Haka", "TheVisionary", "Megalopolis"); StartGame(); PlayCard("UpClose"); PlayCard("UpClose"); Card livingClose = PlayCard("UpClose"); AssertNextMessages("All heroes were already Up Close, so the new one destroys itself.", "This fails the test unless the UpClose message went off."); Card doomedClose = GetCardFromTrash(ram, "UpClose"); PlayCard(doomedClose); AssertInTrash(doomedClose); DestroyCardJournalEntry doomedDies = GameController.Game.Journal.DestroyCardEntries().Where((DestroyCardJournalEntry dc) => dc.Card == doomedClose).FirstOrDefault(); Assert.IsNotNull(doomedDies); DestroyCardJournalEntry livingDies = GameController.Game.Journal.DestroyCardEntries().Where((DestroyCardJournalEntry dc) => dc.Card == livingClose).FirstOrDefault(); Assert.IsNull(livingDies); GameController.ExhaustCoroutine(GameController.SendMessageAction("This fails the test unless the UpClose message went off.", Priority.High, null)); }
public override IEnumerator UsePower(int index = 0) { int[] powerNumerals = new int[] { this.GetPowerNumeral(0, 5), this.GetPowerNumeral(1, 2) }; List <SelectCardDecision> storedResults = new List <SelectCardDecision>(); IEnumerator coroutine; // Discard the top card of the deck. coroutine = DiscardCardsFromTopOfDeck(this.DecisionMaker, 1, responsibleTurnTaker: this.HeroTurnTaker); if (UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } // Select a device target. coroutine = this.GameController.SelectCardAndStoreResults(this.DecisionMaker, SelectionType.SelectTarget, new LinqCardCriteria((Card c) => c.IsInPlayAndHasGameText && c.IsDevice && c.IsTarget, "device target"), storedResults, false, cardSource: this.GetCardSource()); if (UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } Card selectedCard = this.GetSelectedCard(storedResults); if (selectedCard != null) { // Device Damages Self. coroutine = this.GameController.DealDamageToTarget(new DamageSource(this.GameController, selectedCard), selectedCard, powerNumerals[0], DamageType.Lightning, cardSource: this.GetCardSource()); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } // If device was destroyed... DestroyCardJournalEntry destroyCardJournalEntry = (from dcje in this.Journal.DestroyCardEntriesThisTurn() where selectedCard == dcje.Card select dcje).LastOrDefault <DestroyCardJournalEntry>(); if (destroyCardJournalEntry != null && destroyCardJournalEntry.Card != null) { // Draw 2 cards. coroutine = this.DrawCards(this.DecisionMaker, powerNumerals[1]); if (this.UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } // You may play a device. coroutine = this.GameController.SelectAndPlayCardFromHand(this.HeroTurnTakerController, true, cardCriteria: new LinqCardCriteria((Card c) => c.IsDevice, "device"), cardSource: this.GetCardSource()); if (UseUnityCoroutines) { yield return(this.GameController.StartCoroutine(coroutine)); } else { this.GameController.ExhaustCoroutine(coroutine); } } } }