using System; using System.Collections; using System.Collections.Generic; using System.Linq; // MagnaAngemon namespace DCGO.CardEffects.BT25 { public class BT25_040 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Static Effects #region Digivolution Condition if (timing == EffectTiming.None) { bool Condition(Permanent permanent) { return permanent.TopCard.HasTSTraits; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: Condition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region When Trashed if (timing == EffectTiming.OnDiscardSecurity) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 level 4 or lower [Angel] or [Iliad] card", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription()); activateClass.SetIsSkippable(true); cardEffects.Add(activateClass); string EffectDescription() { return "When effects trashing this card from the security stack, you may play 1 level 4 or lower [Angel] or [Iliad] trait card from your hand without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card); } bool CanPlayCardCondition(CardSource cardSource) { return cardSource.HasPlayCost && cardSource.HasLevel && cardSource.Level <= 4 && (cardSource.EqualsTraits("Angel") || cardSource.EqualsTraits("Iliad")) && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnTrash(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCardCondition); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect( canTargetCondition: CanPlayCardCondition, SelectCardEffect.Root.Hand, activateClass, payCost: false )); } } #endregion #region Ascension if (timing == EffectTiming.OnDestroyedAnyone) { cardEffects.Add(CardEffectFactory.AscensionSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #endregion #region Shared OP/WD string SharedEffectName = "By trashing top or bottom security card, 1 opponent digimon gains -8k DP until their turn ends"; string SharedEffectDescription(string tag) => $"[{tag}] By trashing your top or bottom security card, 1 of your opponent's Digimon gets -8000 DP until their turn ends."; bool CanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card); IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { 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) { Permanent selectedPermanent = null; #region Select Opponent's Digimon if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, CanSelectPermanentCondition)); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, 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) { selectedPermanent = permanent; yield return null; } selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to give -8K DP", "The opponent is selecting a digimon to give -8K DP"); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } #endregion if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP( targetPermanent: selectedPermanent, changeValue: -8000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass)); } } } } CardEffectFactory.ActivateClassesForSharedEffects (ref cardEffects, timing, card, SharedEffectName, SharedActivateCoroutine, SharedEffectDescription, optional: false, isSkippable: true, onPlay: true, whenDigivolving: true); #endregion #region All Turns if (timing == EffectTiming.OnLoseSecurity) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("1 of your opponent's Digimon gets -4000 DP", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription()); activateClass.SetHashString("BT25_040_WST_AT"); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDescription() => "[All Turns] [Once Per Turn] When your security stack is removed from, 1 of your opponent's Digimon gets -4000 DP for the turn."; bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { Permanent selectedPermanent = null; SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP( targetPermanent: selectedPermanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass)); } } } } #endregion return cardEffects; } } }