private bool IsImmuneToDamage()
        {
            //checks the journal for the last time Scurrying Evil was dealt damage
            DealDamageJournalEntry dealDamageJournalEntry = base.GameController.Game.Journal.MostRecentDealDamageEntry((DealDamageJournalEntry e) => e.TargetCard == base.Card && e.Amount > 0);
            int?damageEntryIndex;

            if (dealDamageJournalEntry != null)
            {
                damageEntryIndex = base.GameController.Game.Journal.GetEntryIndex(dealDamageJournalEntry);
            }
            else
            {
                return(false);
            }

            //check the journal for the last room that was played before that damage
            IEnumerable <CardEntersPlayJournalEntry> roomEntries = from e in base.GameController.Game.Journal.CardEntersPlayEntries()
                                                                   where this.IsDefinitionRoom(e.Card) && base.GameController.Game.Journal.GetEntryIndex(e) < damageEntryIndex
                                                                   select e;
            int?latestCardEntersPlayIndex = new int?(0);
            int?roomEntryIndex;
            Dictionary <int?, CardEntersPlayJournalEntry> cardEntryDict = new Dictionary <int?, CardEntersPlayJournalEntry>();

            foreach (CardEntersPlayJournalEntry roomEntry in roomEntries)
            {
                roomEntryIndex = base.GameController.Game.Journal.GetEntryIndex(roomEntry);
                if (roomEntryIndex > latestCardEntersPlayIndex)
                {
                    latestCardEntersPlayIndex = roomEntryIndex;
                    cardEntryDict.Add(roomEntryIndex, roomEntry);
                }
            }

            CardEntersPlayJournalEntry latestRoomBeforeDamageJournalEntry = cardEntryDict[latestCardEntersPlayIndex];

            //check the journal for if there has been a room played since that point

            IEnumerable <CardEntersPlayJournalEntry> newRoomEntries = from e in base.GameController.Game.Journal.CardEntersPlayEntries()
                                                                      where this.IsDefinitionRoom(e.Card) && base.GameController.Game.Journal.GetEntryIndex(e) > damageEntryIndex
                                                                      select e;

            foreach (CardEntersPlayJournalEntry roomEntry in newRoomEntries)
            {
                //if there has been a room since then, check if its the same room as before
                if (roomEntry.Card != latestRoomBeforeDamageJournalEntry.Card)
                {
                    return(false);
                }
            }

            return(true);
        }
        public override IEnumerator Play()
        {
            // "{PalmreaderCharacter} deals 1 target 2 melee damage."
            List <SelectCardDecision> firstTargeting = new List <SelectCardDecision>();
            IEnumerator meleeCoroutine = base.GameController.SelectTargetsAndDealDamage(base.HeroTurnTakerController, new DamageSource(base.GameController, base.CharacterCard), 2, DamageType.Melee, new int?(1), false, new int?(1), storedResultsDecisions: firstTargeting, selectTargetsEvenIfCannotDealDamage: true, cardSource: GetCardSource());

            if (base.UseUnityCoroutines)
            {
                yield return(base.GameController.StartCoroutine(meleeCoroutine));
            }
            else
            {
                base.GameController.ExhaustCoroutine(meleeCoroutine);
            }
            // "If that target was in a play area with a Relay card, {PalmreaderCharacter} deals another target in that play area 2 irreducible psychic damage."
            if (firstTargeting != null && firstTargeting.Count > 0)
            {
                Card firstTarget = firstTargeting.FirstOrDefault().SelectedCard;
                // Figure out where firstTarget was when it was dealt damage
                Location playArea = firstTarget.Location;
                DealDamageJournalEntry      damage     = Journal.DealDamageEntriesThisTurn().Where((DealDamageJournalEntry ddje) => ddje.TargetCard == firstTarget && ddje.SourceCard == base.CharacterCard && ddje.DamageType == DamageType.Melee && ddje.CardThatCausedDamageToOccur == base.Card).LastOrDefault();
                List <MoveCardJournalEntry> movesSince = Journal.MoveCardEntriesThisTurn().Where((MoveCardJournalEntry mcje) => mcje.Card == firstTarget && Journal.GetEntryIndex(mcje) > Journal.GetEntryIndex(damage)).ToList();
                if (movesSince.Any())
                {
                    MoveCardJournalEntry firstMove = movesSince.FirstOrDefault();
                    playArea = firstMove.FromLocation;
                }
                if (playArea.IsInPlay && NumRelaysAt(playArea) > 0)
                {
                    IEnumerator projectileCoroutine = base.GameController.SelectTargetsAndDealDamage(base.HeroTurnTakerController, new DamageSource(base.GameController, base.CharacterCard), 2, DamageType.Psychic, new int?(1), false, new int?(1), isIrreducible: true, additionalCriteria: (Card c) => c.Location == playArea && c != firstTarget, cardSource: GetCardSource());
                    if (base.UseUnityCoroutines)
                    {
                        yield return(base.GameController.StartCoroutine(projectileCoroutine));
                    }
                    else
                    {
                        base.GameController.ExhaustCoroutine(projectileCoroutine);
                    }
                }
            }
            yield break;
        }
Ejemplo n.º 3
0
 private bool HasTargetDealtDamageToTitanSinceHisLastTurn(Card target)
 {
     if (target.IsTarget)
     {
         DealDamageJournalEntry dealDamageJournalEntry = (from d in base.Journal.DealDamageEntriesFromTargetToTargetSinceLastTurn(target, base.CharacterCard, base.TurnTaker) where d.Amount > 0 select d).LastOrDefault <DealDamageJournalEntry>();
         if (dealDamageJournalEntry != null && target.IsInPlayAndHasGameText)
         {
             int?entryIndex = base.GameController.Game.Journal.GetEntryIndex(dealDamageJournalEntry);
             PlayCardJournalEntry playCardJournalEntry = (from c in base.GameController.Game.Journal.PlayCardEntries() where c.CardPlayed == target select c).LastOrDefault <PlayCardJournalEntry>();
             if (playCardJournalEntry == null)
             {
                 return(true);
             }
             int?entryIndex2 = base.GameController.Game.Journal.GetEntryIndex(playCardJournalEntry);
             int?num         = entryIndex;
             int?num2        = entryIndex2;
             if (num.GetValueOrDefault() > num2.GetValueOrDefault() & (num != null & num2 != null))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
        private Card GetLastHeroToDamageVillainTarget()
        {
            DealDamageJournalEntry journalEntry = base.GameController.Game.Journal.DealDamageEntries().LastOrDefault(j => IsVillainTarget(j.TargetCard) && j.CardThatCausedDamageToOccur.IsHero);

            return(journalEntry?.CardThatCausedDamageToOccur);
        }