public override IEnumerator Play()
        {
            // "Up to 2 other players may each return a card from their trash to their hand."
            SelectTurnTakersDecision selectPlayers = new SelectTurnTakersDecision(base.GameController, base.HeroTurnTakerController, new LinqTurnTakerCriteria((TurnTaker tt) => tt != base.TurnTaker && tt.IsHero && !tt.IsIncapacitatedOrOutOfGame && GameController.IsTurnTakerVisibleToCardSource(tt, GetCardSource())), SelectionType.MoveCardToHandFromTrash, 2, isOptional: false, numberOfCards: 1, cardSource: GetCardSource());
            IEnumerator returnCoroutine            = base.GameController.SelectTurnTakersAndDoAction(selectPlayers, (TurnTaker tt) => base.GameController.SelectCardFromLocationAndMoveIt(FindHeroTurnTakerController(tt.ToHero()), tt.Trash, new LinqCardCriteria((Card c) => true), new List <MoveCardDestination> {
                new MoveCardDestination(tt.ToHero().Hand)
            }, optional: true, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource()), cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(returnCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(returnCoroutine);
            }
            // "You may draw a card or play an Ongoing card."
            List <Function>       options = new List <Function>();
            List <PlayCardAction> plays   = new List <PlayCardAction>();

            options.Add(new Function(base.HeroTurnTakerController, "Draw a card", SelectionType.DrawCard, () => base.GameController.DrawCard(base.HeroTurnTaker, optional: true, cardSource: GetCardSource())));
            options.Add(new Function(base.HeroTurnTakerController, "Play an Ongoing card", SelectionType.PlayCard, () => SelectAndPlayCardFromHand(base.HeroTurnTakerController, storedResults: plays, cardCriteria: new LinqCardCriteria((Card c) => c.DoKeywordsContain("ongoing"), "Ongoing"))));
            SelectFunctionDecision choice          = new SelectFunctionDecision(base.GameController, base.HeroTurnTakerController, options, true, noSelectableFunctionMessage: base.CharacterCard.Title + " cannot draw or play any cards.", cardSource: GetCardSource());
            IEnumerator            chooseCoroutine = base.GameController.SelectAndPerformFunction(choice);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(chooseCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(chooseCoroutine);
            }
            yield break;
        }
        private IEnumerator AbsorbDiscardResponse(PhaseChangeAction action)
        {
            SelectTurnTakersDecision turnTakerDecision = new SelectTurnTakersDecision(base.GameController, this.DecisionMaker, new LinqTurnTakerCriteria((TurnTaker tt) => tt.IsHero), SelectionType.DiscardCard, Game.H - 2, cardSource: base.GetCardSource());
            //...{H - 2} players must discard a card.
            IEnumerator coroutine = base.GameController.SelectTurnTakersAndDoAction(turnTakerDecision, (TurnTaker tt) => base.GameController.SelectAndDiscardCard(base.FindHeroTurnTakerController(tt.ToHero()), cardSource: base.GetCardSource()), cardSource: base.GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
        }
        private IEnumerator HeroesDiscardResponse(PhaseChangeAction pc)
        {
            SelectTurnTakersDecision orderDiscard = new SelectTurnTakersDecision(GameController, DecisionMaker, new LinqTurnTakerCriteria((TurnTaker tt) => tt.IsHero && !tt.IsIncapacitatedOrOutOfGame && IsUpClose(tt), "Up Close hero"), SelectionType.DiscardCard, cardSource: GetCardSource());
            IEnumerator coroutine = GameController.SelectTurnTakersAndDoAction(orderDiscard,
                                                                               (TurnTaker tt) => GameController.SelectAndDiscardCard(FindHeroTurnTakerController(tt.ToHero()), cardSource: GetCardSource()),
                                                                               cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(GameController.StartCoroutine(coroutine));
            }
            else
            {
                GameController.ExhaustCoroutine(coroutine);
            }
            yield break;
        }
        private IEnumerator TwoPlayersMayDrawACard()
        {
            LinqTurnTakerCriteria    criteria = new LinqTurnTakerCriteria(tt => tt.IsHero && !tt.IsIncapacitatedOrOutOfGame && GameController.IsTurnTakerVisibleToCardSource(tt, GetCardSource()));
            SelectTurnTakersDecision selectTurnTakersDecision = new SelectTurnTakersDecision(GameController, DecisionMaker, criteria, SelectionType.DrawCard, numberOfTurnTakers: 2, cardSource: GetCardSource());;
            IEnumerator coroutine = GameController.SelectTurnTakersAndDoAction(selectTurnTakersDecision, tt => DrawCard(hero: tt.ToHero(), optional: true));

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }

            yield break;
        }
Beispiel #5
0
        public override IEnumerator Play()
        {
            // "The {H - 2} players with the most cards in play each destroy 1 of their non-character cards."
            // Find those players, store them as loadedHeroes...
            List <TurnTaker> loadedHeroes         = new List <TurnTaker>();
            IEnumerator      findPlayersCoroutine = base.FindHeroWithMostCardsInPlay(loadedHeroes, numberOfHeroes: base.H - 2);

            if (base.UseUnityCoroutines)
            {
                yield return(this.GameController.StartCoroutine(findPlayersCoroutine));
            }
            else
            {
                this.GameController.ExhaustCoroutine(findPlayersCoroutine);
            }
            Log.Debug("LightenTheLoadCardController.Play: loadedHeroes.Count = " + loadedHeroes.Count.ToString());
            foreach (TurnTaker hero in loadedHeroes)
            {
                Log.Debug("    " + hero.NameRespectingVariant);
            }
            LinqTurnTakerCriteria isListedHero = new LinqTurnTakerCriteria((TurnTaker tt) => tt.IsHero && loadedHeroes.Contains(tt));

            // Ask each of them to destroy a card if they have at least 1 in play
            List <DestroyCardAction> destroyAttempts  = new List <DestroyCardAction>();
            List <DestroyCardAction> playersDestroyed = new List <DestroyCardAction>();

            if (GameController.FindCardsWhere(new LinqCardCriteria((Card c) => !c.IsCharacter && loadedHeroes.Contains(c.Owner))).Any())
            {
                SelectTurnTakersDecision destroyOrder = new SelectTurnTakersDecision(base.GameController, this.DecisionMaker, isListedHero, SelectionType.DestroyCard, numberOfTurnTakers: Game.H - 2, allowAutoDecide: true, cardSource: GetCardSource());
                IEnumerator playersDestroyCoroutine   = base.GameController.SelectTurnTakersAndDoAction(destroyOrder, (TurnTaker tt) => base.GameController.SelectAndDestroyCard(base.FindHeroTurnTakerController(tt.ToHero()), cardCriteria: new LinqCardCriteria((Card c) => !c.IsCharacter && c.Owner == tt, "non-character"), false, storedResultsAction: playersDestroyed, cardSource: GetCardSource()));
                if (base.UseUnityCoroutines)
                {
                    yield return(this.GameController.StartCoroutine(playersDestroyCoroutine));
                }
                else
                {
                    this.GameController.ExhaustCoroutine(playersDestroyCoroutine);
                }
            }

            // "Destroy a hero card in the villain play area."
            List <DestroyCardAction> villainDestroyed = new List <DestroyCardAction>();
            IEnumerator villainDestroyCoroutine       = base.GameController.SelectAndDestroyCards(this.DecisionMaker, new LinqCardCriteria((Card c) => c.IsHero && c.Location.HighestRecursiveLocation == base.TurnTaker.FindCard("BreakawayCharacter").Location.HighestRecursiveLocation), new int?(1), storedResultsAction: villainDestroyed, responsibleCard: this.Card, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(this.GameController.StartCoroutine(villainDestroyCoroutine));
            }
            else
            {
                this.GameController.ExhaustCoroutine(villainDestroyCoroutine);
            }

            // "If a card was destroyed this way, {Breakaway} regains 2 HP."
            DestroyCardAction villainAttempt = villainDestroyed.FirstOrDefault();

            if (villainAttempt != null && villainAttempt.WasCardDestroyed)
            {
                IEnumerator hpGainCoroutine = base.GameController.GainHP(base.TurnTaker.FindCard("BreakawayCharacter"), 2, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(this.GameController.StartCoroutine(hpGainCoroutine));
                }
                else
                {
                    this.GameController.ExhaustCoroutine(hpGainCoroutine);
                }
            }

            // "Reduce the next damage dealt by each non-villain target by X, where X = 2 plus the number of cards destroyed by this card."
            destroyAttempts = destroyAttempts.Concat(playersDestroyed).ToList();
            destroyAttempts = destroyAttempts.Concat(villainDestroyed).ToList();
            List <DestroyCardAction> destroySuccesses = destroyAttempts.FindAll((DestroyCardAction da) => da.WasCardDestroyed);
            int reduction = 2 + destroySuccesses.Count();

            // Do ReduceNextDamage for EACH non-villain target in play
            foreach (Card nvt in base.GameController.FindTargetsInPlay((Card c) => c.IsNonVillainTarget))
            {
                IEnumerator reduceCoroutine = this.ReduceNextDamage(nvt, reduction);
                if (base.UseUnityCoroutines)
                {
                    yield return(this.GameController.StartCoroutine(reduceCoroutine));
                }
                else
                {
                    this.GameController.ExhaustCoroutine(reduceCoroutine);
                }
            }

            yield break;
        }