using System; using System.Collections; using System.Collections.Generic; using System.Linq; // ClavisAngemon namespace DCGO.CardEffects.BT25 { public class BT25_042 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Digivolution Condition if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsTraits("Angel") || targetPermanent.TopCard.EqualsTraits("Archangel") || targetPermanent.TopCard.HasTSTraits; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 5)); } #endregion #region OP/WD/WA Shared string SharedHashString = "BT25_042_OP_WD_WA"; string SharedEffectName = "By trashing top or bottom security, this digimon is immune to digimon effect until opponent turn ends"; string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] By trashing your top or bottom security card, your opponent's Digimon effects don't affect this Digimon until their turn ends."; bool AdditionalCanUseCondition(Hashtable hashtable, ActivateClass activateClass) => card.Owner.SecurityCards.Count >= 1; IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { bool isUsed = false; bool requiresSelection = card.Owner.SecurityCards.Count >= 2; if (card.Owner.SecurityCards.Any()) { #region Setup Location Selection List> selectionElements = new List>(); if (requiresSelection) { selectionElements.Add(new SelectionElement("Top", 1, 0)); selectionElements.Add(new SelectionElement("Bottom", 2, 0)); } else selectionElements.Add(new SelectionElement("Trash only security card", 1, 0)); selectionElements.Add(new SelectionElement("Don't trash", 3, 1)); string selectPlayerMessage = "Will you trash your security?"; string notSelectPlayerMessage = "The opponent is choosing to trash their security"; GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect()); #endregion bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3; bool fromTop = GManager.instance.userSelectionManager.SelectedIntValue == 1; if (doTrash) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult( player: card.Owner, trashAmount: 1, activateClass: activateClass, fromTop: fromTop, successProcess: SuccessProcess, failureProcess: null)); IEnumerator SuccessProcess(List cardSources) { isUsed = true; Permanent thisPermanent = card.PermanentOfThisCard(); thisPermanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(thisPermanent)); yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent().CreateBuffEffect(thisPermanent)); } } } if (!isUsed) activateClass.RemoveUse(); } CardEffectFactory.ActivateClassesForSharedEffects (ref cardEffects, timing, card, SharedEffectName, SharedActivateCoroutine, SharedEffectDescription, optional: false, maxCountPerTurn: 1, hashValue: SharedHashString, onPlay: true, whenDigivolving: true, whenAttacking: true, isSkippable: true, additionalUseCondition: AdditionalCanUseCondition); #endregion #region All Turns if (timing == EffectTiming.OnLoseSecurity) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 level 4 or lower [Angel]/[Iliad] trait card from hand without cost, then 2 digimon gain reboot & blocker until opponent turn end", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription()); activateClass.SetHashString("BT25_042_AT"); cardEffects.Add(activateClass); string EffectDescription() { return "[All Turns] [Once Per Turn] When your security stack is removed from, you may play 1 level 4 or lower [Angel] or [Iliad] trait card from your hand without paying the cost. Then, 2 of your Digimon gain and until your opponent's turn ends."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass) && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, owner => owner == card.Owner); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass); } bool CanPlayCardCondition(CardSource cardSource) => cardSource.HasLevel && cardSource.Level <= 4 && (cardSource.EqualsTraits("Angel") || cardSource.HasIliadTraits) && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass); bool IsOwnedDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card); IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCardCondition)) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect( canTargetCondition: CanPlayCardCondition, SelectCardEffect.Root.Hand, activateClass, payCost: false )); } List selectedPermaments = new List(); ; if (CardEffectCommons.HasMatchConditionPermanent(IsOwnedDigimon)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(IsOwnedDigimon)); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsOwnedDigimon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermaments.Add(permanent); yield break; } selectPermanentEffect.SetUpCustomMessage("Select 2 digimon to gain reboot and blocker.", "The opponent is selecting 2 digimon to gain reboot and blocker."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } if (selectedPermaments.Any()) { foreach (Permanent permanent in selectedPermaments) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot( targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass)); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker( targetPermanent: permanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass)); } } } } #endregion return cardEffects; } } }