| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- // Marsmon
- namespace DCGO.CardEffects.BT25
- {
- public class BT25_020 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Alt Digivolution
- if (timing == EffectTiming.None)
- {
- bool PermanentCondition(Permanent permanent)
- {
- return permanent.TopCard.EqualsTraits("TS");
- }
- cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
- }
- #endregion
- #region Reduce Play Cost
- if (timing == EffectTiming.None)
- {
- ChangeCostClass changeCostClass = new ChangeCostClass();
- changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
- changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
- changeCostClass.SetNotShowUI(true);
- cardEffects.Add(changeCostClass);
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.HasMatchConditionPermanent(WouldPlayCondition);
- }
- bool WouldPlayCondition(Permanent permanent)
- {
- return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
- && permanent.HasDP
- && permanent.DP >= 13000;
- }
- int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
- List<Permanent> targetPermanents)
- {
- if (CardSourceCondition(cardSource) &&
- RootCondition(root) &&
- PermanentsCondition(targetPermanents))
- {
- cost -= 5;
- }
- return cost;
- }
- bool PermanentsCondition(List<Permanent> targetPermanents)
- {
- return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
- }
- bool CardSourceCondition(CardSource cardSource)
- {
- return cardSource == card;
- }
- bool RootCondition(SelectCardEffect.Root root)
- {
- return true;
- }
- bool isUpDown()
- {
- return true;
- }
- }
- #endregion
- #region Shared OP / WD / WA
- string SharedEffectName = "+3K DP to one of your digimon, 1 of your Digimon may battle an opponent's Digimon";
- string SharedEffectDescription(string tag) => $"[{tag}] 1 of your Digimon gets +3000 DP for the turn. Then, 1 of your Digimon may battle 1 of your opponent's Digimon.";
- CardEffectFactory.ActivateClassesForSharedEffects
- (ref cardEffects, timing, card,
- SharedEffectName,
- SharedActivateCoroutine,
- SharedEffectDescription,
- optional: false,
- onPlay: true,
- whenDigivolving: true,
- whenAttacking: true);
- bool IsYourDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
- bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
- IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
- {
- if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
- {
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: IsYourDigimon,
- 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 +3000.", "The opponent is selecting 1 Digimon that will get DP +3000.");
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- IEnumerator SelectPermanentCoroutine(Permanent permanent)
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: 3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
- }
- if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimon))
- {
- //Select attacker
- Permanent selectedAttacker = null;
- SelectPermanentEffect selectAttackerEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectAttackerEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: IsYourDigimon,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectAttackerCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectAttackerEffect.SetUpCustomMessage("Select 1 of your Digimon to battle.", "The opponent is selecting Digimon to battle.");
- yield return ContinuousController.instance.StartCoroutine(selectAttackerEffect.Activate());
- IEnumerator SelectAttackerCoroutine(Permanent permanent)
- {
- selectedAttacker = permanent;
- yield return null;
- }
- if (selectedAttacker != null)
- {
- //select defender
- Permanent selectedDefender = null;
- SelectPermanentEffect selectDefenderEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectDefenderEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: IsEnemyDigimon,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: SelectDefenderCoroutine,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Custom,
- cardEffect: activateClass);
- selectDefenderEffect.SetUpCustomMessage("Select 1 enemy Digimon to battle.", "The opponent is selecting Digimon to battle.");
- yield return ContinuousController.instance.StartCoroutine(selectDefenderEffect.Activate());
- IEnumerator SelectDefenderCoroutine(Permanent permanent)
- {
- selectedDefender = permanent;
- yield return null;
- }
- if (selectedDefender != null)
- {
- yield return ContinuousController.instance.StartCoroutine(new IBattle(selectedAttacker, selectedDefender, null, true).Battle());
- }
- }
- }
- }
- }
- #endregion
- #region All Turns
- if (timing == EffectTiming.OnEndBattle)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Trash opponent's top security", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
- activateClass.SetHashString("BT25_020_AT");
- cardEffects.Add(activateClass);
- string EffectDescription()
- {
- return "[All Turns] [Once Per Turn] When any of your [TS] trait Digimon win a battle, trash your opponent's top security card.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleArea(card))
- {
- bool WinnerCondition(Permanent permanent) => permanent.TopCard.Owner == card.Owner && permanent.TopCard.HasTSTraits;
- if (CardEffectCommons.CanTriggerWhenWinBattle(
- hashtable: hashtable,
- winnerCondition: WinnerCondition))
- {
- return true;
- }
- }
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
- player: card.Owner.Enemy,
- destroySecurityCount: 1,
- cardEffect: activateClass,
- fromTop: true).DestroySecurity());
- }
- }
- #endregion
- return cardEffects;
- }
- }
- }
|