| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- 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<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #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<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
- if (requiresSelection)
- {
- selectionElements.Add(new SelectionElement<int>("Top", 1, 0));
- selectionElements.Add(new SelectionElement<int>("Bottom", 2, 0));
- }
- else selectionElements.Add(new SelectionElement<int>("Trash only security card", 1, 0));
- selectionElements.Add(new SelectionElement<int>("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<CardSource> cardSources)
- {
- isUsed = true;
- Permanent thisPermanent = card.PermanentOfThisCard();
- thisPermanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(thisPermanent));
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().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 <Reboot> and <Blocker> 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<Permanent> selectedPermaments = new List<Permanent>(); ;
- if (CardEffectCommons.HasMatchConditionPermanent(IsOwnedDigimon))
- {
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- 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;
- }
- }
- }
|