コード例 #1
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;
        }