public IEnumerator MaybeCounterDamageResponse(DealDamageAction dd, TurnTaker hero, StatusEffect effect, int[] powerNumerals = null)
        {
            int numDamage = powerNumerals?[0] ?? 3;
            var player    = FindHeroTurnTakerController(hero?.ToHero());

            if (dd.DamageSource.IsCard && dd.DamageSource.IsTarget && player != null && !dd.DamageSource.Card.IsBeingDestroyed && effect.CardMovedExpiryCriteria.Card == null)
            {
                var target = dd.DamageSource.Card;


                //...{Echelon} may...
                var         storedYesNo = new List <YesNoCardDecision>();
                IEnumerator coroutine   = GameController.MakeYesNoCardDecision(player, SelectionType.DealDamage, this.Card, storedResults: storedYesNo, associatedCards: new Card[] { target }, cardSource: GetCardSource(effect));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }

                if (!DidPlayerAnswerYes(storedYesNo))
                {
                    yield break;
                }

                //Once before the start of your next turn...
                //we set a criterion that will (hopefully) not matter much so that future reactions know it's being used
                effect.CardMovedExpiryCriteria.Card = CharacterCard;

                var damageSource = CharacterCard;
                if (effect is OnDealDamageStatusEffect oddEffect)
                {
                    damageSource = oddEffect.TargetLeavesPlayExpiryCriteria.Card ?? damageSource;
                }

                //deal the source of that damage 3 melee damage
                coroutine = DealDamage(damageSource, target, numDamage, DamageType.Melee, isCounterDamage: true, cardSource: GetCardSource(effect));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }

                coroutine = GameController.ExpireStatusEffect(effect, GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
            }
            yield break;
        }
示例#2
0
        private IEnumerator ReturnCardAndRescueMatching(TurnTaker tt)
        {
            var hero              = FindHeroTurnTakerController(tt.ToHero());
            var returnedStorage   = new List <SelectCardDecision> {
            };
            IEnumerator coroutine = SelectAndMoveCardOptional(hero, (Card c) => c.IsInPlay && !c.IsCharacter && c.Owner == hero.TurnTaker && !GameController.IsCardIndestructible(c), hero.HeroTurnTaker.Hand, optional: true, storedResults: returnedStorage, cardSource: GetCardSource());

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

            if (DidSelectCard(returnedStorage))
            {
                List <string> handKeywords = returnedStorage.FirstOrDefault().SelectedCard.GetKeywords().ToList();
                coroutine = SelectAndMoveCardOptional(hero, (Card c) => c.Location == hero.TurnTaker.Trash && c.GetKeywords().Any((string trashKeyword) => handKeywords.Contains(trashKeyword)), hero.HeroTurnTaker.PlayArea, isPutIntoPlay: true, optional: true, storedResults: returnedStorage, cardSource: GetCardSource());
                if (UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine);
                }
            }
            yield break;
        }
        private IEnumerator DrawThenDiscardResponse(TurnTaker tt)
        {
            var result    = new List <DrawCardAction>();
            var htt       = tt.ToHero();
            var httc      = GameController.FindHeroTurnTakerController(htt);
            var coroutine = DrawCard(htt, optional: true, cardsDrawn: result);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            if (GetNumberOfCardsDrawn(result) > 0)
            {
                coroutine = SelectAndDiscardCards(httc, 1);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
            }
        }
 public override TurnPhase AskIfTurnPhaseShouldBeChanged(TurnPhase fromPhase, TurnPhase toPhase)
 {
     if (GameController.ActiveTurnTaker.IsHero)
     {
         TurnTaker isSpecificTurnTaker = GameController.ActiveTurnTaker;
         return(base.GameController.GetNextTurnPhaseIfChoosable(isSpecificTurnTaker.ToHero(), fromPhase, toPhase, GetCardSource()));
     }
     return(base.AskIfTurnPhaseShouldBeChanged(fromPhase, toPhase));
 }
示例#5
0
        public IEnumerator StabOrDestroyResponse(PhaseChangeAction pca)
        {
            // "... this card may deal a character card in this play area {H - 1} psychic damage."
            List <DealDamageAction> storedResultsDamage = new List <DealDamageAction>();
            IEnumerator             damageCoroutine     = base.GameController.SelectTargetsAndDealDamage(base.DecisionMaker, new DamageSource(base.GameController, base.Card), Game.H - 1, DamageType.Psychic, 1, false, 0, additionalCriteria: (Card c) => c.IsCharacter && c.Location.HighestRecursiveLocation == base.Card.Location.HighestRecursiveLocation, storedResultsDamage: storedResultsDamage, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(damageCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(damageCoroutine);
            }
            // "If it deals no damage this way, destroy a non-character card from this play area's deck, then destroy this card."
            if (storedResultsDamage == null || storedResultsDamage.Count((DealDamageAction dda) => dda.DidDealDamage) <= 0)
            {
                // Destroy a non-character card from this play area's deck
                TurnTaker host = base.Card.Location.OwnerTurnTaker;
                HeroTurnTakerController boss = DecisionMaker;
                if (host.IsHero)
                {
                    boss = base.GameController.FindHeroTurnTakerController(host.ToHero());
                }
                IEnumerator destroyNonCharacterCoroutine = base.GameController.SelectAndDestroyCard(boss, new LinqCardCriteria((Card c) => c.Owner == host && !c.IsCharacter, "from " + host.Name + "'s deck", useCardsSuffix: false, useCardsPrefix: true), false, responsibleCard: base.Card, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(destroyNonCharacterCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(destroyNonCharacterCoroutine);
                }
                // Destroy this card
                IEnumerator selfDestructCoroutine = base.GameController.DestroyCard(DecisionMaker, base.Card, optional: false, showOutput: true, responsibleCard: base.Card, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(selfDestructCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(selfDestructCoroutine);
                }
            }
            yield break;
        }
示例#6
0
 public IEnumerator PlayOngEqp(TurnTaker tt)
 {
     if (tt.IsHero && !tt.IsIncapacitatedOrOutOfGame)
     {
         HeroTurnTakerController httc          = FindHeroTurnTakerController(tt.ToHero());
         IEnumerator             playCoroutine = SelectAndPlayCardFromHand(httc, cardCriteria: new LinqCardCriteria((Card c) => c.DoKeywordsContain("ongoing") || c.DoKeywordsContain("equipment"), "ongoing or equipment"), associateCardSource: true);
         if (base.UseUnityCoroutines)
         {
             yield return(base.GameController.StartCoroutine(playCoroutine));
         }
         else
         {
             base.GameController.ExhaustCoroutine(playCoroutine);
         }
     }
     yield break;
 }
示例#7
0
        private IEnumerator MayDrawTwoDiscardTwo(TurnTaker tt)
        {
            var player = FindHeroTurnTakerController(tt?.ToHero());

            if (player == null)
            {
                yield break;
            }

            var         storedYesNo = new List <YesNoCardDecision>();
            IEnumerator coroutine   = GameController.MakeYesNoCardDecision(player, SelectionType.DiscardAndDrawCard, this.Card, storedResults: storedYesNo, cardSource: GetCardSource());

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

            if (DidPlayerAnswerYes(storedYesNo))
            {
                coroutine = GameController.DrawCards(player, 2, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }

                coroutine = GameController.SelectAndDiscardCards(player, 2, false, 2, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
            }
            yield break;
        }
        public IEnumerator MoveCardToHandResponse(TurnTaker tt)
        {
            // "... may return a card from their trash to their hand."
            HeroTurnTakerController    httc = FindHeroTurnTakerController(tt.ToHero());
            List <MoveCardDestination> dest = new List <MoveCardDestination>();

            dest.Add(new MoveCardDestination(httc.HeroTurnTaker.Hand));
            IEnumerator moveCoroutine = base.GameController.SelectCardFromLocationAndMoveIt(httc, tt.Trash, new LinqCardCriteria((Card c) => c.Location == tt.Trash), dest, optional: true, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(moveCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(moveCoroutine);
            }
            yield break;
        }
示例#9
0
        public override IEnumerator Play()
        {
            //"1 player may..."
            List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
            IEnumerator coroutine = GameController.SelectHeroTurnTaker(DecisionMaker, SelectionType.RevealCardsFromDeck, optional: true, allowAutoDecide: false, storedResults, new LinqTurnTakerCriteria((TurnTaker tt) => GameController.IsTurnTakerVisibleToCardSource(tt, GetCardSource()) && !tt.IsIncapacitatedOrOutOfGame, "active heroes"), cardSource: GetCardSource());

            if (UseUnityCoroutines)
            {
                yield return(GameController.StartCoroutine(coroutine));
            }
            else
            {
                GameController.ExhaustCoroutine(coroutine);
            }
            TurnTaker hero = GetSelectedTurnTaker(storedResults);

            if (hero == null || !hero.IsHero)
            {
                yield break;
            }
            HeroTurnTakerController heroTTC = FindHeroTurnTakerController(hero.ToHero());

            if (heroTTC != null)
            {
                //"...look at the top 5 cards of their deck, put 1 of them into play, then put the rest on the bottom of their deck in any order."

                IEnumerator coroutine3 = RevealCardsWithCustomLogic(heroTTC);
                if (UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine3));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine3);
                }
            }

            yield break;
        }
        public IEnumerator ChangeDamageTypeResponse(DealDamageAction dd, TurnTaker hero, StatusEffect effect, int[] powerNumerals = null)
        {
            // You may change its type by spending a token

            TokenPool elementPool = base.CharacterCard.FindTokenPool(LadyOfTheWoodElementPoolIdentifier);

            if (elementPool == null || !base.TurnTaker.IsHero)
            {
                TurnTaker turnTaker = FindTurnTakersWhere((TurnTaker tt) => tt.Identifier == "LadyOfTheWood").FirstOrDefault();
                if (turnTaker != null)
                {
                    elementPool = turnTaker.CharacterCard.FindTokenPool(LadyOfTheWoodElementPoolIdentifier);
                }
            }

            List <RemoveTokensFromPoolAction> storedResults = new List <RemoveTokensFromPoolAction>();
            IEnumerator coroutine = base.GameController.RemoveTokensFromPool(elementPool, 1, storedResults: storedResults, optional: true, cardSource: base.GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            if (DidRemoveTokens(storedResults))
            {
                //Select a damage type.
                List <SelectDamageTypeDecision> storedDamageTypeResults = new List <SelectDamageTypeDecision>();
                coroutine = base.GameController.SelectDamageType(FindHeroTurnTakerController(hero.ToHero()), storedDamageTypeResults, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                DamageType damageType = GetSelectedDamageType(storedDamageTypeResults).Value;
                dd.DamageType = damageType;
            }
            yield break;
        }
        public IEnumerator MaybeRedirectDamageResponse(DealDamageAction dd, TurnTaker hero, StatusEffect effect, int[] powerNumerals = null)
        {
            //...you may redirect that damage to Titan.
            var storedYesNo       = new List <YesNoCardDecision> {
            };
            IEnumerator coroutine = GameController.MakeYesNoCardDecision(FindHeroTurnTakerController(hero.ToHero()), SelectionType.RedirectDamage, this.Card, storedResults: storedYesNo, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            if (DidPlayerAnswerYes(storedYesNo))
            {
                coroutine = RedirectDamage(dd, TargetType.SelectTarget, (Card c) => hero.CharacterCards.Contains(c));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
            }
            yield break;
        }
示例#12
0
        private IEnumerator SelectKeywordThenRevealAndMoveCards(TurnTaker tt)
        {
            var player = tt == null ? null : GameController.FindHeroTurnTakerController(tt.ToHero());

            if (player == null)
            {
                yield break;
            }

            var deck = tt.Deck;

            if (deck.Cards.Count() > 0)
            {
                //Selects a keyword
                IOrderedEnumerable <string> words = from s in deck.Cards.SelectMany((Card c) => GameController.GetAllKeywords(c)).Distinct()
                                                    orderby s
                                                    select s;
                var wordsPlus = words.ToList();
                wordsPlus.Add("Discard All");
                List <SelectWordDecision> storedResults = new List <SelectWordDecision>();
                IEnumerator coroutine = GameController.SelectWord(player, wordsPlus, SelectionType.SelectKeyword, storedResults, optional: false, null, GetCardSource());
                if (UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine);
                }
                if (!DidSelectWord(storedResults))
                {
                    yield break;
                }
                string keyword = GetSelectedWord(storedResults);

                //Reveal top 3 cards
                List <Card> revealStored = new List <Card>();
                coroutine = GameController.RevealCards(player, deck, 3, revealStored, fromBottom: false, RevealedCardDisplay.Message, null, GetCardSource());
                if (UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine);
                }

                //Put any revealed cards with that keyword into their hand and discarding the rest.
                foreach (Card c in revealStored)
                {
                    if (GameController.DoesCardContainKeyword(c, keyword))
                    {
                        coroutine = GameController.MoveCard(DecisionMaker, c, player.HeroTurnTaker.Hand, cardSource: GetCardSource());
                    }
                    else
                    {
                        coroutine = GameController.MoveCard(DecisionMaker, c, c.NativeTrash, isDiscard: true, cardSource: GetCardSource());
                    }

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

                //cleanup if needed
                coroutine = CleanupCardsAtLocations(new List <Location> {
                    tt.Revealed
                }, tt.Trash, isDiscard: true, isReturnedToOriginalLocation: false, cardsInList: revealStored);
                if (UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine);
                }
            }
            else
            {
                IEnumerator coroutine2 = GameController.SendMessageAction(tt.Name + "'s deck has no cards for " + this.Card.Title + " to reveal.", Priority.Medium, GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine2));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine2);
                }
            }
            yield break;
        }
示例#13
0
        private IEnumerator PlayRelic(TurnTaker tt, List <PlayCardAction> storedPlay)
        {
            IEnumerator coroutine = GameController.SelectAndPlayCardFromHand(FindHeroTurnTakerController(tt.ToHero()), true, storedPlay, new LinqCardCriteria((Card c) => c.IsRelic, "relic"), cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            yield break;
        }
        public override IEnumerator UseIncapacitatedAbility(int index)
        {
            switch (index)
            {
            case 0:
            {
                //One hero may put a random card from their trash into play.
                List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
                IEnumerator coroutine = base.GameController.SelectHeroTurnTaker(DecisionMaker, SelectionType.PutIntoPlay, false, false, storedResults, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                if (DidSelectTurnTaker(storedResults))
                {
                    TurnTaker tt = GetSelectedTurnTaker(storedResults);
                    HeroTurnTakerController  httc = FindHeroTurnTakerController(tt.ToHero());
                    List <YesNoCardDecision> storedYesNoResults = new List <YesNoCardDecision>();
                    coroutine = GameController.MakeYesNoCardDecision(httc, SelectionType.PlayCard, base.Card, storedResults: storedYesNoResults, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine);
                    }
                    if (DidPlayerAnswerYes(storedYesNoResults))
                    {
                        coroutine = base.RevealCards_MoveMatching_ReturnNonMatchingCards(base.TurnTakerController, tt.Trash, false, true, false, new LinqCardCriteria((Card c) => true), 1, shuffleBeforehand: true);
                        if (base.UseUnityCoroutines)
                        {
                            yield return(base.GameController.StartCoroutine(coroutine));
                        }
                        else
                        {
                            base.GameController.ExhaustCoroutine(coroutine);
                        }
                    }
                }

                break;
            }

            case 1:
            {
                //Destroy 1 ongoing card.
                IEnumerator coroutine2 = base.GameController.SelectAndDestroyCard(base.HeroTurnTakerController,
                                                                                  new LinqCardCriteria((Card c) => c.IsOngoing && GameController.IsCardVisibleToCardSource(c, GetCardSource()), "ongoing"),
                                                                                  optional: false,
                                                                                  cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine2));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine2);
                }
                break;
            }

            case 2:
            {
                //The next time a target is destroyed, 1 player may draw 2 cards.
                WhenCardIsDestroyedStatusEffect effect = new WhenCardIsDestroyedStatusEffect(base.Card, "DrawTwoCardsResponse", "The next time a target is destroyed, 1 player may draw 2 cards", new TriggerType[] { TriggerType.DrawCard }, DecisionMaker.HeroTurnTaker, base.Card);
                effect.NumberOfUses   = 1;
                effect.CanEffectStack = true;
                effect.CardDestroyedCriteria.IsTarget = true;
                effect.CanEffectStack = true;
                IEnumerator coroutine3 = AddStatusEffect(effect);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine3));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine3);
                }
                break;
            }
            }
            yield break;
        }
        public IEnumerator ActNowResponse(TurnTaker tt)
        {
            // "... may draw a card, play a card, and use a power in any order..."
            bool drewCard   = false;
            bool playedCard = false;
            bool usedPower  = false;
            List <SelectFunctionDecision> storedFunction = new List <SelectFunctionDecision>();
            Func <string> getNoFunctionString            = delegate
            {
                List <string> list2 = new List <string>();
                if (!usedPower && (!base.GameController.CanUsePowers(base.GameController.FindHeroTurnTakerController(tt.ToHero()), GetCardSource()) || base.GameController.GetUsablePowersThisTurn(base.GameController.FindHeroTurnTakerController(tt.ToHero())).Count() < 1))
                {
                    list2.Add("use a power");
                }
                if (!playedCard && !CanPlayCardsFromHand(base.GameController.FindHeroTurnTakerController(tt.ToHero())))
                {
                    list2.Add("play a card");
                }
                if (!drewCard && !CanDrawCards(base.GameController.FindHeroTurnTakerController(tt.ToHero())))
                {
                    list2.Add("draw a card");
                }
                return(tt.ToHero().Name + " cannot " + list2.ToCommaList(useWordAnd: false, useWordOr: true) + ".");
            };

            for (int i = 0; i < 3; i++)
            {
                List <Function> list = new List <Function>();
                list.Add(new Function(DecisionMaker, "Draw a Card", SelectionType.DrawCard, () => DrawCard(tt.ToHero()), !drewCard && CanDrawCards(base.GameController.FindHeroTurnTakerController(tt.ToHero()))));
                list.Add(new Function(DecisionMaker, "Play a Card", SelectionType.PlayCard, () => SelectAndPlayCardFromHand(base.GameController.FindHeroTurnTakerController(tt.ToHero()), optional: false), !playedCard && CanPlayCardsFromHand(base.GameController.FindHeroTurnTakerController(tt.ToHero()))));
                list.Add(new Function(DecisionMaker, "Use a Power", SelectionType.UsePower, () => base.GameController.SelectAndUsePower(base.GameController.FindHeroTurnTakerController(tt.ToHero()), optional: false, null, 1, eliminateUsedPowers: true, null, showMessage: false, allowAnyHeroPower: false, allowReplacements: true, canBeCancelled: true, null, forceDecision: false, allowOutOfPlayPower: false, GetCardSource()), !usedPower && base.GameController.CanUsePowers(base.GameController.FindHeroTurnTakerController(tt.ToHero()), GetCardSource()) && base.GameController.GetUsablePowersThisTurn(base.GameController.FindHeroTurnTakerController(tt.ToHero())).Count() > 0));
                SelectFunctionDecision selectFunction = new SelectFunctionDecision(base.GameController, base.GameController.FindHeroTurnTakerController(tt.ToHero()), list, optional: true, null, getNoFunctionString(), null, GetCardSource());
                IEnumerator            coroutine      = base.GameController.SelectAndPerformFunction(selectFunction, storedFunction);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                Function selectedFunction = GetSelectedFunction(storedFunction);
                if (selectedFunction != null)
                {
                    switch (selectedFunction.SelectionType)
                    {
                    case SelectionType.DrawCard:
                        drewCard = true;
                        break;

                    case SelectionType.PlayCard:
                        playedCard = true;
                        break;

                    case SelectionType.UsePower:
                        usedPower = true;
                        break;
                    }
                    continue;
                }
                break;
            }
            // "... then their hero deals themself 3 psychic damage."
            List <Card> damagedHero     = new List <Card>();
            IEnumerator chooseCoroutine = base.FindCharacterCardToTakeDamage(tt, damagedHero, null, 3, DamageType.Psychic);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(chooseCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(chooseCoroutine);
            }
            IEnumerator damageCoroutine = base.GameController.DealDamageToSelf(base.GameController.FindHeroTurnTakerController(tt.ToHero()), (Card c) => damagedHero.Contains(c), 3, DamageType.Psychic, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(damageCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(damageCoroutine);
            }
            yield break;
        }
        private IEnumerator AskIfMoveUpCloseResponse(PhaseChangeAction pc)
        {
            Card upClose = FindCardsWhere(new LinqCardCriteria((Card c) => c.IsInTrash && c.Identifier == "UpClose")).FirstOrDefault();

            if (upClose == null)
            {
                IEnumerator message = GameController.SendMessageAction("There were no copies of Up Close in the trash to take.", Priority.High, GetCardSource(), showCardSource: true);
                if (base.UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(message));
                }
                else
                {
                    GameController.ExhaustCoroutine(message);
                }
                yield break;
            }

            TurnTaker activeHero           = pc.ToPhase.TurnTaker;
            HeroTurnTakerController player = FindHeroTurnTakerController(activeHero.ToHero());

            List <YesNoCardDecision> storedResult = new List <YesNoCardDecision> {
            };
            IEnumerator coroutine = GameController.MakeYesNoCardDecision(player, SelectionType.PutIntoPlay, upClose, pc, storedResult, new Card[] { this.Card }, GetCardSource());

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

            if (!DidPlayerAnswerYes(storedResult))
            {
                yield break;
            }

            List <Card> heroResult = new List <Card> {
            };

            coroutine = GameController.FindCharacterCard(player, activeHero, SelectionType.HeroCharacterCard, heroResult, cardSource: GetCardSource());
            if (base.UseUnityCoroutines)
            {
                yield return(GameController.StartCoroutine(coroutine));
            }
            else
            {
                GameController.ExhaustCoroutine(coroutine);
            }

            Card hero = heroResult.FirstOrDefault();

            if (hero != null)
            {
                coroutine = (FindCardController(upClose) as UpCloseCardController).PlayBySpecifiedHero(hero, true, GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(GameController.StartCoroutine(coroutine));
                }
                else
                {
                    GameController.ExhaustCoroutine(coroutine);
                }
            }

            yield break;
        }
        public override IEnumerator UseIncapacitatedAbility(int index)
        {
            switch (index)
            {
            case 0:
            {
                //One hero target deals itself 3 toxic damage.
                IEnumerable <Card>        choices       = FindCardsWhere((Card c) => c.IsInPlayAndNotUnderCard && c.IsTarget && c.IsHero);
                List <SelectCardDecision> storedResults = new List <SelectCardDecision>();
                var         damageInfo = new DealDamageAction(GetCardSource(), new DamageSource(GameController, TurnTaker), null, 3, DamageType.Toxic);
                IEnumerator coroutine  = base.GameController.SelectCardAndStoreResults(DecisionMaker, SelectionType.DealDamageSelf, choices, storedResults,
                                                                                       optional: false,
                                                                                       dealDamageInfo: new[] { damageInfo },
                                                                                       cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                if (DidSelectCard(storedResults))
                {
                    Card card = GetSelectedCard(storedResults);
                    coroutine = DealDamage(card, card, 3, DamageType.Toxic);
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine);
                    }
                }
                break;
            }

            case 1:
            {
                //One hero may use their innate power, then draw a card.
                List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
                IEnumerator coroutine2 = base.GameController.SelectHeroTurnTaker(DecisionMaker, SelectionType.UsePowerOnCard, false, false, storedResults, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine2));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine2);
                }
                if (DidSelectTurnTaker(storedResults))
                {
                    TurnTaker tt = GetSelectedTurnTaker(storedResults);
                    HeroTurnTakerController httc = FindHeroTurnTakerController(tt.ToHero());
                    coroutine2 = base.GameController.SelectAndUsePower(httc, powerCriteria: (Power p) => p.CardController == httc.CharacterCardController, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine2));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine2);
                    }

                    coroutine2 = base.DrawCards(httc, 1);
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine2));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine2);
                    }
                }

                break;
            }

            case 2:
            {
                //One player may discard their hand and draw that many cards.
                List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
                IEnumerator coroutine3 = base.GameController.SelectHeroTurnTaker(DecisionMaker, SelectionType.DiscardAndDrawCard, false, false, storedResults, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine3));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine3);
                }
                TurnTaker turnTaker = (from d in storedResults
                                       where d.Completed
                                       select d.SelectedTurnTaker).FirstOrDefault();
                if (turnTaker != null && turnTaker.IsHero)
                {
                    coroutine3 = DiscardAndDrawResponse(turnTaker);
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine3));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine3);
                    }
                }
                break;
            }
            }
            yield break;
        }
        private IEnumerator DiscardAndDrawResponse(TurnTaker turnTaker)
        {
            List <DiscardCardAction> storedResults           = new List <DiscardCardAction>();
            HeroTurnTakerController  heroTurnTakerController = base.FindHeroTurnTakerController(turnTaker.ToHero());
            IEnumerator coroutine = base.GameController.DiscardHand(heroTurnTakerController, false, storedResults, this.TurnTaker, base.GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            int numberOfCardsDiscarded = base.GetNumberOfCardsDiscarded(storedResults);

            if (numberOfCardsDiscarded > 0)
            {
                coroutine = base.DrawCards(heroTurnTakerController, numberOfCardsDiscarded);
            }
            else
            {
                coroutine = base.GameController.SendMessageAction(base.TurnTaker.Name + " did not discard any cards, so no cards will be drawn.", Priority.High, base.GetCardSource());
            }
            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            yield break;
        }
        public IEnumerator RevealMovePlayResponse(TurnTaker player)
        {
            // "One player reveals the top 5 cards of their deck..."
            List <Card> revealedCards   = new List <Card>();
            IEnumerator revealCoroutine = base.GameController.RevealCards(base.GameController.FindTurnTakerController(player), player.Deck, 5, revealedCards, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(revealCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(revealCoroutine);
            }
            // If not enough cards were available, inform the player
            string countMessage = null;

            switch (revealedCards.Count)
            {
            case 5:
                break;

            case 0:
                countMessage = "No cards were revealed!";
                break;

            case 1:
                countMessage = "Only one card was revealed! It will automatically be put into " + player.Name + "'s hand.";
                break;

            case 2:
                countMessage = "Only two cards were revealed! They will automatically be put into " + player.Name + "'s hand.";
                break;

            default:
                countMessage = "Only " + revealedCards.Count.ToString() + " cards were revealed!";
                break;
            }
            if (countMessage != null)
            {
                IEnumerator messageCoroutine = base.GameController.SendMessageAction(countMessage, Priority.High, GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(messageCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(messageCoroutine);
                }
            }
            if (revealedCards.Count > 0)
            {
                // "... puts 2 into their hand..."
                List <MoveCardAction> toHand        = new List <MoveCardAction>();
                IEnumerator           handCoroutine = base.GameController.SelectCardsFromLocationAndMoveThem(base.GameController.FindHeroTurnTakerController(player.ToHero()), player.Revealed, new int?(2), 2, new LinqCardCriteria(), new MoveCardDestination[] { new MoveCardDestination(player.ToHero().Hand) }, storedResultsMove: toHand, responsibleTurnTaker: player, selectionType: SelectionType.MoveCardToHand, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(handCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(handCoroutine);
                }

                Card inHand = null;
                if (DidMoveCard(toHand))
                {
                    inHand = toHand.FirstOrDefault().CardToMove;
                    revealedCards.Remove(inHand);
                }
                // "... and the rest into their trash."
                int numCardsLeft = revealedCards.Count;
                if (numCardsLeft > 0)
                {
                    Location    heroRevealed   = player.Revealed;
                    IEnumerator trashCoroutine = base.GameController.SelectCardsFromLocationAndMoveThem(base.GameController.FindHeroTurnTakerController(player.ToHero()), heroRevealed, numCardsLeft, numCardsLeft, new LinqCardCriteria(), new MoveCardDestination[] { new MoveCardDestination(player.Trash) }, responsibleTurnTaker: player, allowAutoDecide: true, selectionType: SelectionType.MoveCardToTrash, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(trashCoroutine));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(trashCoroutine);
                    }
                }
            }
            // "That player may play a card now."
            List <PlayCardAction> played        = new List <PlayCardAction>();
            IEnumerator           playCoroutine = SelectAndPlayCardFromHand(base.GameController.FindHeroTurnTakerController(player.ToHero()), optional: true, storedResults: played);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(playCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(playCoroutine);
            }
            if (DidPlayCards(played))
            {
                // "If they do, destroy a Goalposts card."
                IEnumerator destroyCoroutine = base.GameController.SelectAndDestroyCard(base.HeroTurnTakerController, GoalpostsCards, false, responsibleCard: base.Card, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(destroyCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(destroyCoroutine);
                }
            }
            yield break;
        }
 public IEnumerator NameSearchResponse(TurnTaker tt)
 {
     // If the player's deck is empty, this does nothing regardless of their choices, so skip everything
     if (tt.Deck.Cards.Any())
     {
         // "[This player] may name a keyword other than One-Shot."
         IOrderedEnumerable <string> keywords = from s in tt.Deck.Cards.SelectMany((Card c) => base.GameController.GetAllKeywords(c)).Distinct().Where((string s) => s.ToLower() != "one-shot") orderby s select s;
         keywords = keywords.Concat("Another keyword - find nothing, shuffle your deck".ToEnumerable()).OrderBy((string s) => s);
         List <SelectWordDecision> choice = new List <SelectWordDecision>();
         IEnumerator selectCoroutine      = base.GameController.SelectWord(base.GameController.FindHeroTurnTakerController(tt.ToHero()), keywords, SelectionType.SelectKeyword, choice, true, cardSource: GetCardSource());
         if (base.UseUnityCoroutines)
         {
             yield return(base.GameController.StartCoroutine(selectCoroutine));
         }
         else
         {
             base.GameController.ExhaustCoroutine(selectCoroutine);
         }
         if (DidSelectWord(choice))
         {
             string chosen = GetSelectedWord(choice);
             // "[This player] reveals cards from the top of their deck until they reveal a card with the keyword they named, puts that card into play or into their hand, then shuffles the other revealed cards into their deck."
             List <RevealCardsAction> revealedCards = new List <RevealCardsAction>();
             IEnumerator revealCoroutine            = base.GameController.RevealCards(base.GameController.FindTurnTakerController(tt), tt.Deck, (Card c) => c.DoKeywordsContain(chosen), 1, revealedCards, revealedCardDisplay: RevealedCardDisplay.ShowMatchingCards, cardSource: GetCardSource());
             if (base.UseUnityCoroutines)
             {
                 yield return(base.GameController.StartCoroutine(revealCoroutine));
             }
             else
             {
                 base.GameController.ExhaustCoroutine(revealCoroutine);
             }
             RevealCardsAction revealed = revealedCards.FirstOrDefault();
             if (revealed != null && revealed.FoundMatchingCards)
             {
                 Card selectedCard = revealed.MatchingCards.FirstOrDefault();
                 List <MoveCardDestination> choices = new List <MoveCardDestination>();
                 choices.Add(new MoveCardDestination(tt.PlayArea));
                 choices.Add(new MoveCardDestination(tt.ToHero().Hand));
                 if (selectedCard != null)
                 {
                     IEnumerator moveCoroutine = base.GameController.SelectLocationAndMoveCard(base.GameController.FindHeroTurnTakerController(tt.ToHero()), selectedCard, choices, isPutIntoPlay: true, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource());
                     if (base.UseUnityCoroutines)
                     {
                         yield return(base.GameController.StartCoroutine(moveCoroutine));
                     }
                     else
                     {
                         base.GameController.ExhaustCoroutine(moveCoroutine);
                     }
                     revealed.MatchingCards.Remove(selectedCard);
                 }
                 IEnumerator replaceCoroutine = base.GameController.MoveCards(base.GameController.FindTurnTakerController(tt), revealed.RevealedCards.Where((Card c) => c != selectedCard), tt.Deck, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource());
                 if (base.UseUnityCoroutines)
                 {
                     yield return(base.GameController.StartCoroutine(replaceCoroutine));
                 }
                 else
                 {
                     base.GameController.ExhaustCoroutine(replaceCoroutine);
                 }
                 IEnumerator shuffleCoroutine = base.GameController.ShuffleLocation(tt.Deck, cardSource: GetCardSource());
                 if (base.UseUnityCoroutines)
                 {
                     yield return(base.GameController.StartCoroutine(shuffleCoroutine));
                 }
                 else
                 {
                     base.GameController.ExhaustCoroutine(shuffleCoroutine);
                 }
             }
         }
     }
     else
     {
         IEnumerator messageCoroutine = base.GameController.SendMessageAction(tt.Name + "'s deck has no cards for " + base.Card.Title + " to reveal.", Priority.Medium, GetCardSource());
         if (base.UseUnityCoroutines)
         {
             yield return(base.GameController.StartCoroutine(messageCoroutine));
         }
         else
         {
             base.GameController.ExhaustCoroutine(messageCoroutine);
         }
     }
     yield break;
 }
示例#21
0
        public IEnumerator MoveFromTrashToDeckResponse(TurnTaker tt)
        {
            // "... put a card from their trash on the bottom of their deck."
            IEnumerator moveCoroutine = base.GameController.SelectAndMoveCard(base.GameController.FindHeroTurnTakerController(tt.ToHero()), (Card c) => c.IsInLocation(tt.Trash), tt.Deck, toBottom: true, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(moveCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(moveCoroutine);
            }
            yield break;
        }
示例#22
0
        public IEnumerator UsePowerResponse(CardController cardController)
        {
            //  "Destroy 1 of your non-character cards."
            TurnTaker   player           = cardController.TurnTaker;
            IEnumerator destroyCoroutine = base.GameController.SelectAndDestroyCard(base.GameController.FindHeroTurnTakerController(player.ToHero()), new LinqCardCriteria((Card c) => c.Owner == player && !c.IsCharacter && c.IsInPlay, "non-character cards belonging to " + player.Name, false, false, "non-character card belonging to " + player.Name, "non-character cards belonging to " + player.Name), false, responsibleCard: cardController.Card, cardSource: cardController.GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(destroyCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(destroyCoroutine);
            }
            // "Another player draws 2 cards."
            IEnumerator drawCoroutine = base.GameController.SelectHeroToDrawCards(base.GameController.FindHeroTurnTakerController(player.ToHero()), numberOfCards: 2, optionalDrawCards: false, requiredDraws: 2, additionalCriteria: new LinqTurnTakerCriteria((TurnTaker tt) => tt.IsHero && !tt.IsIncapacitatedOrOutOfGame && tt != player), cardSource: cardController.GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(drawCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(drawCoroutine);
            }
            yield break;
        }
示例#23
0
        public override IEnumerator UseIncapacitatedAbility(int index)
        {
            switch (index)
            {
            case 0:
            {
                //one hero deals a target 3 fire damage
                List <SelectCardDecision> storedResults = new List <SelectCardDecision>();
                IEnumerator dealFire = base.GameController.SelectCardAndStoreResults(this.DecisionMaker, SelectionType.SelectTargetNoDamage, new LinqCardCriteria((Card c) => c.IsTarget && c.IsInPlay && c.IsHeroCharacterCard, "hero", true, false, null, null, false), storedResults, false, false, null, true, base.GetCardSource(null));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(dealFire));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(dealFire);
                }
                Card selectedCard = base.GetSelectedCard(storedResults);
                dealFire = base.GameController.SelectTargetsAndDealDamage(this.DecisionMaker, new DamageSource(base.GameController, selectedCard), 3, DamageType.Fire, 1, false, 0, false, false, false, null, null, null, null, null, false, null, null, false, null, GetCardSource(null));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(dealFire));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(dealFire);
                }
                break;
            }

            case 1:
            {
                //Select a hero. Until the start of your next turn, whenever that hero uses a power, that player's hero deals a target 1 Fire damage.
                List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
                IEnumerator selectPlayer = base.GameController.SelectHeroTurnTaker(this.DecisionMaker, SelectionType.TurnTaker, false, false, storedResults, null, null, false, null, null, true, null, GetCardSource(null));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(selectPlayer));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(selectPlayer);
                }
                if (storedResults.Any((SelectTurnTakerDecision d) => d.Completed && d.SelectedTurnTaker != null && d.SelectedTurnTaker.IsHero))
                {
                    TurnTaker selectedTurnTaker = base.GetSelectedTurnTaker(storedResults);
                    if (selectedTurnTaker.IsHero)
                    {
                        HeroTurnTaker htt = selectedTurnTaker.ToHero();
                        Card          damageSource;
                        if (htt.HasMultipleCharacterCards)
                        {
                            damageSource = null;
                        }
                        else
                        {
                            damageSource = htt.CharacterCard;
                        }
                        DealDamageAfterUsePowerStatusEffect ddaupse = new DealDamageAfterUsePowerStatusEffect(htt, damageSource, null, 1, DamageType.Fire, 1, false);
                        ddaupse.TurnTakerCriteria.IsSpecificTurnTaker = htt;
                        if (!htt.HasMultipleCharacterCards)
                        {
                            ddaupse.CardDestroyedExpiryCriteria.Card = htt.CharacterCard;
                        }
                        ddaupse.UntilStartOfNextTurn(this.TurnTaker);
                        IEnumerator dealDamageEffect = base.AddStatusEffect(ddaupse, true);
                        if (base.UseUnityCoroutines)
                        {
                            yield return(base.GameController.StartCoroutine(dealDamageEffect));
                        }
                        else
                        {
                            base.GameController.ExhaustCoroutine(dealDamageEffect);
                        }
                    }
                }
                break;
            }

            case 2:
            {
                //one hero may use a power
                IEnumerator usePower = base.GameController.SelectHeroToUsePower(base.HeroTurnTakerController, false, true, false, null, null, null, true, true, base.GetCardSource(null));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(usePower));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(usePower);
                }
                break;
            }
            }
            yield break;
        }
示例#24
0
        public override IEnumerator UseIncapacitatedAbility(int index)
        {
            switch (index)
            {
            case 0:
            {
                //One player may draw a card now.
                IEnumerator coroutine = GameController.SelectHeroToDrawCard(DecisionMaker, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                break;
            }

            case 1:
            {
                //Destroy an environment card.
                IEnumerator coroutine2 = base.GameController.SelectAndDestroyCard(base.HeroTurnTakerController,
                                                                                  new LinqCardCriteria((Card c) => c.IsEnvironment && GameController.IsCardVisibleToCardSource(c, GetCardSource()), "environment"),
                                                                                  optional: false,
                                                                                  cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine2));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine2);
                }
                break;
            }

            case 2:
            {
                //One player may play 2 random cards from their hand now.
                List <SelectTurnTakerDecision> storedResults = new List <SelectTurnTakerDecision>();
                IEnumerator coroutine3 = base.GameController.SelectHeroTurnTaker(DecisionMaker, SelectionType.PutIntoPlay, false, false, storedResults, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine3));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine3);
                }
                if (DidSelectTurnTaker(storedResults))
                {
                    TurnTaker tt = GetSelectedTurnTaker(storedResults);
                    HeroTurnTakerController  httc = FindHeroTurnTakerController(tt.ToHero());
                    List <YesNoCardDecision> storedYesNoResults = new List <YesNoCardDecision>();
                    coroutine3 = GameController.MakeYesNoCardDecision(httc, SelectionType.PlayCard, base.Card, storedResults: storedYesNoResults, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(coroutine3));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(coroutine3);
                    }
                    if (DidPlayerAnswerYes(storedYesNoResults))
                    {
                        coroutine3 = base.RevealCards_MoveMatching_ReturnNonMatchingCards(base.TurnTakerController, tt.ToHero().Hand, true, false, false, new LinqCardCriteria((Card c) => true), 2, shuffleBeforehand: true);
                        if (base.UseUnityCoroutines)
                        {
                            yield return(base.GameController.StartCoroutine(coroutine3));
                        }
                        else
                        {
                            base.GameController.ExhaustCoroutine(coroutine3);
                        }
                    }
                }
                break;
            }
            }
            yield break;
        }
示例#25
0
        public IEnumerator DiscardReorderResponse(PhaseChangeAction pca)
        {
            // "... discard the top card of [the active player's] deck."
            TurnTaker             currentPlayer    = pca.ToPhase.TurnTaker;
            List <MoveCardAction> discardResults   = new List <MoveCardAction>();
            IEnumerator           discardCoroutine = base.GameController.DiscardTopCard(currentPlayer.Deck, discardResults, (Card c) => true, responsibleTurnTaker: base.TurnTaker, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(discardCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(discardCoroutine);
            }
            // "If a One-Shot is discarded this way, that player skips their power phase this turn and uses a power immediately."
            MoveCardAction discard = discardResults.FirstOrDefault();

            if (discard != null && discard.CardToMove != null && discard.WasCardMoved && discard.CardToMove.DoKeywordsContain("one-shot"))
            {
                IEnumerator messageCoroutine = base.GameController.SendMessageAction("Reverberations are at high levels! " + currentPlayer.Name + " had their turn shuffled in the Reverb!", Priority.Medium, GetCardSource(), discard.CardToMove.ToEnumerable(), true);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(messageCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(messageCoroutine);
                }
                OnPhaseChangeStatusEffect skipsPower = new OnPhaseChangeStatusEffect(base.Card, nameof(SkipPowerPhaseResponse), currentPlayer.Name + " skips their power phase this turn.", new TriggerType[] { TriggerType.SkipPhase }, base.Card);
                skipsPower.TurnTakerCriteria.IsSpecificTurnTaker = currentPlayer;
                skipsPower.TurnIndexCriteria.EqualTo             = base.Game.TurnIndex;
                skipsPower.TurnPhaseCriteria.Phase = Phase.UsePower;
                IEnumerator statusCoroutine = base.GameController.AddStatusEffect(skipsPower, true, GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(statusCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(statusCoroutine);
                }
                IEnumerator powerCoroutine = base.GameController.SelectAndUsePower(base.GameController.FindHeroTurnTakerController(currentPlayer.ToHero()), optional: false, cardSource: GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(powerCoroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(powerCoroutine);
                }
            }
            yield break;
        }
示例#26
0
        public override IEnumerator Play()
        {
            //"Select a player."
            List <SelectTurnTakerDecision> storedTurnTakerDecisions = new List <SelectTurnTakerDecision> {
            };
            IEnumerator chooseGivingPlayer = GameController.SelectTurnTaker(HeroTurnTakerController, SelectionType.MoveCard, storedTurnTakerDecisions,
                                                                            additionalCriteria: (TurnTaker tt) => tt.IsHero &&
                                                                            GameController.IsTurnTakerVisibleToCardSource(tt, GetCardSource()) &&
                                                                            tt.ToHero().HasCardsWhere((Card c) => c.IsInHand && c.IsOneShot),
                                                                            cardSource: GetCardSource());

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

            if (!DidSelectTurnTaker(storedTurnTakerDecisions))
            {
                yield break;
            }

            var decision = storedTurnTakerDecisions.FirstOrDefault();

            storedTurnTakerDecisions.Remove(decision);

            TurnTaker giver = decision.SelectedTurnTaker;

            //"That player passes a one-shot card..."
            List <SelectCardDecision> storedCardDecision = new List <SelectCardDecision> {
            };
            IEnumerator chooseOneShot = GameController.SelectCardAndStoreResults(FindHeroTurnTakerController(giver.ToHero()),
                                                                                 SelectionType.PutIntoPlay,
                                                                                 new LinqCardCriteria((Card c) => giver.ToHero().Hand.Cards.Contains(c) && c.IsOneShot),
                                                                                 storedCardDecision,
                                                                                 false,
                                                                                 cardSource: GetCardSource());

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


            if (!DidSelectCard(storedCardDecision))
            {
                yield break;
            }
            Card passedCard = storedCardDecision.FirstOrDefault().SelectedCard;

            //"..to another player..."
            IEnumerator chooseReceivingPlayer = GameController.SelectTurnTaker(FindHeroTurnTakerController(giver.ToHero()), SelectionType.MoveCard, storedTurnTakerDecisions,
                                                                               additionalCriteria: (TurnTaker tt) => tt.IsHero &&
                                                                               !tt.IsIncapacitatedOrOutOfGame &&
                                                                               GameController.IsTurnTakerVisibleToCardSource(tt, GetCardSource()) &&
                                                                               tt != giver,
                                                                               cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(chooseReceivingPlayer));
            }
            else
            {
                base.GameController.ExhaustCoroutine(chooseReceivingPlayer);
            }
            if (!DidSelectTurnTaker(storedTurnTakerDecisions))
            {
                yield break;
            }

            decision = storedTurnTakerDecisions.FirstOrDefault();
            TurnTaker receiver = decision.SelectedTurnTaker;

            _passedCard         = passedCard;
            _giverController    = FindHeroTurnTakerController(giver.ToHero());
            _receiverController = FindHeroTurnTakerController(receiver.ToHero());

            //just in case we pass to Sentinels, we make them pick one character card to be "their" hero
            var storedResults = new List <Card> {
            };
            var selectReceiverCharacterCard = FindCharacterCard(receiver, SelectionType.CharacterCard, storedResults);

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(selectReceiverCharacterCard));
            }
            else
            {
                base.GameController.ExhaustCoroutine(selectReceiverCharacterCard);
            }
            _receiverCharacterCard = storedResults.FirstOrDefault();

            AddThisCardControllerToList(CardControllerListType.ReplacesCards);
            AddThisCardControllerToList(CardControllerListType.ReplacesTurnTakerController);
            ITrigger associatedCardSourceTrigger = AddTrigger((GameAction ga) => ga.CardSource != null && ga.CardSource.Card == _passedCard, AddThisAsAssociatedCardSource, TriggerType.Hidden, TriggerTiming.Before);

            CardController passedController = FindCardController(_passedCard);

            passedController.AddAssociatedCardSource(GetCardSource());

            //send a message to tell the player what is happening
            IEnumerator sendMessage = GameController.SendMessageAction(receiver.CharacterCard.Title + " puts " + passedCard.Title + " into play!", Priority.High, cardSource: GetCardSource(), showCardSource: true);

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

            //"who then puts that card into play as if it were their card, treating any hero name on the card as the name of their hero instead."
            IEnumerator swappedPlay = GameController.PlayCard(_receiverController, passedCard, true, cardSource: GetCardSource());

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

            RemoveThisCardControllerFromList(CardControllerListType.ReplacesCards);
            RemoveThisCardControllerFromList(CardControllerListType.ReplacesTurnTakerController);
            RemoveTrigger(associatedCardSourceTrigger);
            passedController.RemoveAssociatedCardSource(GetCardSource());

            _passedCard            = null;
            _giverController       = null;
            _receiverController    = null;
            _receiverCharacterCard = null;

            yield break;
        }
示例#27
0
        public override IEnumerator UseIncapacitatedAbility(int index)
        {
            switch (index)
            {
            case 0:
            {
                //One player may shuffle a card from their trash into their deck, then put all cards with the same name from their trash into their hand.
                List <SelectTurnTakerDecision> selectTurnTakerDecision = new List <SelectTurnTakerDecision>();
                //One player...
                IEnumerator coroutine = base.GameController.SelectHeroTurnTaker(base.HeroTurnTakerController, SelectionType.MoveCard, false, false, selectTurnTakerDecision, cardSource: base.GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                TurnTaker selectedTurnTaker = selectTurnTakerDecision.FirstOrDefault().SelectedTurnTaker;
                List <SelectCardDecision> selectCardDecision = new List <SelectCardDecision>();
                //...may shuffle a card from their trash into their deck...
                coroutine = base.GameController.SelectCardAndStoreResults(base.GameController.FindHeroTurnTakerController(selectedTurnTaker.ToHero()), SelectionType.ShuffleCardFromTrashIntoDeck, new LinqCardCriteria((Card c) => c.Location == selectedTurnTaker.Trash), selectCardDecision, true, cardSource: base.GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                Card selectedCard = selectCardDecision.FirstOrDefault().SelectedCard;
                coroutine = base.GameController.ShuffleCardsIntoLocation(base.GameController.FindHeroTurnTakerController(selectedTurnTaker.ToHero()), selectedCard.ToEnumerable <Card>(), selectedTurnTaker.Deck, cardSource: base.GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                //...then put all cards with the same name from their trash into their hand.
                IEnumerable <Card>  cardsToMove  = base.FindCardsWhere(new LinqCardCriteria((Card c) => c.Location == selectedTurnTaker.Trash && c.Identifier == selectedCard.Identifier));
                MoveCardDestination selectedHand = new MoveCardDestination(selectedTurnTaker.ToHero().Hand);
                coroutine = base.GameController.MoveCards(base.GameController.FindHeroTurnTakerController(selectedTurnTaker.ToHero()), cardsToMove, selectedTurnTaker.ToHero().Hand, cardSource: base.GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine);
                }
                yield break;
            }

            case 1:
            {
                //Each target regains 1 HP.
                IEnumerator coroutine2 = base.GameController.GainHP(base.HeroTurnTakerController, (Card c) => c.IsTarget, 1, cardSource: base.GetCardSource());
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine2));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine2);
                }
                break;
            }

            case 2:
            {
                //Each hero character may deal themselves 3 toxic damage to play a card now.
                this.actedHeroes = new List <Card>();
                IEnumerable <Function> functionsBasedOnCard(Card c) => new Function[]
                {
                    new Function(base.FindCardController(c).DecisionMaker, "Deal self 3 toxic damage to play a card now.", SelectionType.PlayCard, () => this.DealDamageAndDrawResponse(c))
                };
                IEnumerator coroutine3 = base.GameController.SelectCardsAndPerformFunction(this.DecisionMaker, new LinqCardCriteria((Card c) => c.IsHeroCharacterCard && c.IsInPlayAndHasGameText && !c.IsIncapacitatedOrOutOfGame && !this.actedHeroes.Contains(c), "active hero character cards", false, false, null, null, false), functionsBasedOnCard, true, base.GetCardSource(null));
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(coroutine3));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(coroutine3);
                }
                break;
            }
            }
            yield break;
        }
        private IEnumerator DiscardAndDrawResponse(TurnTaker turnTaker)
        {
            HeroTurnTakerController heroTurnTakerController = base.FindHeroTurnTakerController(turnTaker.ToHero());

            //ask the selected player if they want to discard and draw
            YesNoDecision yesNo     = new YesNoDecision(base.GameController, heroTurnTakerController, SelectionType.DiscardAndDrawCard, cardSource: GetCardSource());
            IEnumerator   coroutine = base.GameController.MakeDecisionAction(yesNo);

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

            //discard hand
            List <DiscardCardAction> storedResults = new List <DiscardCardAction>();

            coroutine = base.GameController.DiscardHand(heroTurnTakerController, false, storedResults, turnTaker, GetCardSource());
            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }

            //draw same number of cards
            int numberOfCardsDiscarded = base.GetNumberOfCardsDiscarded(storedResults);

            if (numberOfCardsDiscarded > 0)
            {
                coroutine = base.DrawCards(heroTurnTakerController, numberOfCardsDiscarded);
            }
            else
            {
                coroutine = base.GameController.SendMessageAction(base.TurnTaker.Name + " did not discard any cards, so no cards will be drawn.", Priority.High, base.GetCardSource());
            }
            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(coroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(coroutine);
            }
            yield break;
        }
        public IEnumerator ReturnToHandResponse(TurnTaker tt)
        {
            // "... returns 1 of [their non-character cards in play] to their hand."
            IEnumerator returnCoroutine = base.GameController.SelectAndMoveCard(base.GameController.FindHeroTurnTakerController(tt.ToHero()), (Card c) => c.IsInPlay && !c.IsCharacter && c.Owner == tt, tt.ToHero().Hand, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(returnCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(returnCoroutine);
            }
            yield break;
        }
示例#30
0
        public override IEnumerator Play()
        {
            // Find hero with the highest HP
            List <Card> storedHighestHp     = new List <Card>();
            IEnumerator getHighestHpRoutine = this.GameController.FindTargetWithHighestHitPoints(1, card => card.IsHeroCharacterCard && !card.IsIncapacitatedOrOutOfGame, storedHighestHp);

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

            if (storedHighestHp.Any())
            {
                // Deal the hero with the highest HP 5 projectile damage
                IEnumerator dealDamageToHighestHpRoutine = this.DealDamage(CharacterCard, storedHighestHp.First(), DamageToDealHighestHp, DamageType.Projectile);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(dealDamageToHighestHpRoutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(dealDamageToHighestHpRoutine);
                }
            }

            // Find hero with the lowest HP
            List <Card> storedLowestHp     = new List <Card>();
            IEnumerator getLowestHpRoutine = this.GameController.FindTargetWithLowestHitPoints(1, card => card.IsHeroCharacterCard && !card.IsIncapacitatedOrOutOfGame, storedLowestHp);

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

            if (storedLowestHp.Any())
            {
                // Deal the hero with the lowest HP 2 irreducible infernal damage
                IEnumerator dealDamageToLowestHpRoutine = this.DealDamage(CharacterCard, storedLowestHp.First(), DamageToDealLowestHp, DamageType.Infernal, true);
                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(dealDamageToLowestHpRoutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(dealDamageToLowestHpRoutine);
                }
            }

            // Find hero with fewest cards in play
            List <TurnTaker> fewestCardsInPlayResults        = new List <TurnTaker>();
            IEnumerator      heroWithLeastCardsInPlayRoutine = base.FindHeroWithFewestCardsInPlay(fewestCardsInPlayResults);

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

            if (fewestCardsInPlayResults.Any())
            {
                // Destroy 1 equipment and 1 ongoing from the hero with the fewest cards in play
                TurnTaker fewestTt = fewestCardsInPlayResults.First();
                HeroTurnTakerController fewestCardsHttc = FindHeroTurnTakerController(fewestTt.ToHero());

                IEnumerator destroyOneOngoingRoutine = base.GameController.SelectAndDestroyCards(fewestCardsHttc,
                                                                                                 new LinqCardCriteria(card => card.IsOngoing && card.IsInPlay && card.Owner == fewestTt), CardsToDestroyFewestCards, cardSource: this.GetCardSource());

                IEnumerator destroyOneEquipmentRoutine = base.GameController.SelectAndDestroyCards(fewestCardsHttc,
                                                                                                   new LinqCardCriteria(card => IsEquipment(card) && card.IsInPlay && card.Owner == fewestTt), CardsToDestroyFewestCards, cardSource: this.GetCardSource());

                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(destroyOneOngoingRoutine));

                    yield return(base.GameController.StartCoroutine(destroyOneEquipmentRoutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(destroyOneOngoingRoutine);
                    base.GameController.ExhaustCoroutine(destroyOneEquipmentRoutine);
                }
            }

            // Find hero with most cards in play
            List <TurnTaker> mostCardsInPlayResults         = new List <TurnTaker>();
            IEnumerator      heroWithMostCardsInPlayRoutine = base.FindHeroWithMostCardsInPlay(mostCardsInPlayResults);

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

            if (mostCardsInPlayResults.Any())
            {
                // Destroy 2 equipment and 2 ongoing from the hero with the most cards in play
                TurnTaker mostTt = mostCardsInPlayResults.First();
                HeroTurnTakerController mostCardsHttc = FindHeroTurnTakerController(mostTt.ToHero());

                IEnumerator destroyTwoOngoingRoutine = base.GameController.SelectAndDestroyCards(mostCardsHttc,
                                                                                                 new LinqCardCriteria(card => card.IsOngoing && card.IsInPlay && card.Owner == mostTt), CardsToDestroyMostCards, cardSource: this.GetCardSource());

                IEnumerator destroyTwoEquipmentRoutine = base.GameController.SelectAndDestroyCards(mostCardsHttc,
                                                                                                   new LinqCardCriteria(card => IsEquipment(card) && card.IsInPlay && card.Owner == mostTt), CardsToDestroyMostCards, cardSource: this.GetCardSource());

                if (base.UseUnityCoroutines)
                {
                    yield return(base.GameController.StartCoroutine(destroyTwoOngoingRoutine));

                    yield return(base.GameController.StartCoroutine(destroyTwoEquipmentRoutine));
                }
                else
                {
                    base.GameController.ExhaustCoroutine(destroyTwoOngoingRoutine);
                    base.GameController.ExhaustCoroutine(destroyTwoEquipmentRoutine);
                }
            }
        }