| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- // CannonBeemon
- namespace DCGO.CardEffects.BT23
- {
- public class BT23_043 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Alternative Digivolution Condition
- if (timing == EffectTiming.None)
- {
- bool PermanentCondition(Permanent targetPermanent)
- {
- return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4
- && (targetPermanent.TopCard.HasCSTraits || targetPermanent.TopCard.HasRoyalBaseTraits);
- }
- cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
- permanentCondition: PermanentCondition,
- digivolutionCost: 3,
- ignoreDigivolutionRequirement: false,
- card: card,
- condition: null)
- );
- }
- #endregion Alternative Digivolution Condition
- #region Opponents Turn - Security
- if (timing == EffectTiming.None)
- {
- bool Condition()
- {
- return CardEffectCommons.IsExistInSecurity(card, false) &&
- CardEffectCommons.IsOpponentTurn(card);
- }
- bool PermanentCondition(Permanent permanent)
- {
- if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
- {
- if (permanent.TopCard.EqualsTraits("Royal Base"))
- {
- return true;
- }
- }
- return false;
- }
- cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
- permanentCondition: PermanentCondition,
- isInheritedEffect: false,
- card: card,
- condition: Condition));
- }
- #endregion
- #region All Turns - OPT
- if (timing == EffectTiming.WhenRemoveField)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("By flipping your top face up security card face down, prevent remove from field", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
- activateClass.SetHashString("BT23_AT");
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, by flipping your top face-up security card face down, it doesn't leave.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
- && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && CardEffectCommons.HasMatchConditionOwnersSecurity(card, _ => true, false);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- var flippedSecurity = false;
- foreach (CardSource source in card.Owner.SecurityCards)
- {
- if (source.IsFlipped) continue;
- source.SetReverse();
- GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
- flippedSecurity = true;
- break;
- }
- if (flippedSecurity)
- {
- var thisPermament = card.PermanentOfThisCard();
- thisPermament.HideDeleteEffect();
- thisPermament.HideHandBounceEffect();
- thisPermament.HideDeckBounceEffect();
- thisPermament.HideWillRemoveFieldEffect();
- thisPermament.DestroyingEffect = null;
- thisPermament.IsDestroyedByBattle = false;
- thisPermament.HandBounceEffect = null;
- thisPermament.LibraryBounceEffect = null;
- thisPermament.willBeRemoveField = false;
- }
- yield return null;
- }
- }
- #endregion
- #region All Turns - ESS - OPT
- if (timing == EffectTiming.WhenRemoveField)
- {
- List<Permanent> removedPermanents = new List<Permanent>();
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("By flipping your top face up security card face down, prevent remove from field", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
- activateClass.SetHashString("BT23_ESS_AT");
- activateClass.SetIsInheritedEffect(true);
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns] [Once Per Turn] When any of your [Royal Base] trait Digimon would leave the battle area other than by your effects, by flipping your top face-up security card face down, 1 of those Digimon doesn't leave.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, CanSelectPermanentCondition)
- && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && card.Owner.SecurityCards.Count(source => !source.IsFlipped) > 0;
- }
- bool CanSelectPermanentCondition(Permanent permanent)
- {
- return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
- && permanent.TopCard.HasRoyalBaseTraits;
- }
- bool CanSelectPermament(Permanent permanent)
- {
- return removedPermanents.Contains(permanent);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(CanSelectPermanentCondition);
- var flippedSecurity = false;
- foreach (CardSource source in card.Owner.SecurityCards)
- {
- if (source.IsFlipped) continue;
- source.SetReverse();
- GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
- flippedSecurity = true;
- break;
- }
- if (flippedSecurity)
- {
- Permanent selectedPermanent = null;
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermament));
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectPermament,
- 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 prevent removal.", "The opponent is selecting 1 Digimon to prevent removal.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- if (selectedPermanent != null)
- {
- selectedPermanent.HideDeleteEffect();
- selectedPermanent.HideHandBounceEffect();
- selectedPermanent.HideDeckBounceEffect();
- selectedPermanent.HideWillRemoveFieldEffect();
- selectedPermanent.DestroyingEffect = null;
- selectedPermanent.IsDestroyedByBattle = false;
- selectedPermanent.HandBounceEffect = null;
- selectedPermanent.LibraryBounceEffect = null;
- selectedPermanent.willBeRemoveField = false;
- }
- }
- yield return null;
- }
- }
- #endregion
- return cardEffects;
- }
- }
- }
|