| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- namespace DCGO.CardEffects.EX1
- {
- public class EX1_071 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- if (timing == EffectTiming.None)
- {
- IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
- ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
- ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
- cardEffects.Add(ignoreColorConditionClass);
- bool CanUseCondition(Hashtable hashtable)
- {
- return card.Owner.GetBattleAreaPermanents().Some(permanet => permanet.IsTamer);
- }
- bool CardCondition(CardSource cardSource)
- {
- return cardSource == card;
- }
- }
- if (timing == EffectTiming.OptionSkill)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[Main] The next time one of your Digimon digivolves this turn, you may trash 1 Digimon card in your hand of the same color as the digivolving Digimon to reduce the memory cost of the digivolution by 4.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
- yield return new WaitForSeconds(0.2f);
- ActivateClass activateClass1 = new ActivateClass();
- Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
- activateClass1.SetUpICardEffect("Digivolution Cost -4", CanUseCondition1, card);
- activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDiscription1());
- CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect);
- ActivateClass activateClass2 = new ActivateClass();
- Func<EffectTiming, ICardEffect> getCardEffect1 = GetCardEffect1;
- activateClass2.SetUpICardEffect("Remove Effect", CanUseCondition1, card);
- activateClass2.SetUpActivateClass(null, ActivateCoroutine2, -1, false, "");
- activateClass2.SetIsBackgroundProcess(true);
- CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect1);
- string EffectDiscription1()
- {
- return "You may trash 1 Digimon card in your hand of the same color as the digivolving Digimon to reduce the memory cost of the digivolution by 4.";
- }
- bool PermanentCondition(Permanent targetPermanent)
- {
- return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
- }
- bool CanUseCondition1(Hashtable hashtable)
- {
- if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
- hashtable: hashtable,
- permanentCondition: PermanentCondition,
- cardCondition: null))
- {
- return true;
- }
- return false;
- }
- bool CanActivateCondition1(Hashtable hashtable)
- {
- List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
- if (permanents != null)
- {
- bool CanSelectCardCondition(CardSource cardSource)
- {
- if (cardSource.IsDigimon)
- {
- List<CardColor> permanentColors = permanents
- .Map(permanent => permanent.TopCard.CardColors)
- .Flat();
- if (cardSource.CardColors.Some((cardColor) => permanentColors.Contains(cardColor)))
- {
- return true;
- }
- }
- return false;
- }
- if (card.Owner.HandCards.Some(CanSelectCardCondition))
- {
- return true;
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
- {
- List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable1);
- if (permanents != null)
- {
- bool CanSelectCardCondition(CardSource cardSource)
- {
- if (cardSource.IsDigimon)
- {
- List<CardColor> permanentColors = permanents
- .Map(permanent => permanent.TopCard.CardColors)
- .Flat();
- if (cardSource.CardColors.Some((cardColor) => permanentColors.Contains(cardColor)))
- {
- return true;
- }
- }
- return false;
- }
- if (card.Owner.HandCards.Some(CanSelectCardCondition))
- {
- bool discarded = false;
- int discardCount = 1;
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: discardCount,
- canNoSelect: true,
- canEndNotMax: false,
- isShowOpponent: true,
- selectCardCoroutine: null,
- afterSelectCardCoroutine: AfterSelectCardCoroutine,
- mode: SelectHandEffect.Mode.Discard,
- cardEffect: activateClass);
- yield return StartCoroutine(selectHandEffect.Activate());
- IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
- {
- if (cardSources.Count >= 1)
- {
- discarded = true;
- yield return null;
- }
- }
- if (discarded)
- {
- ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
- ChangeCostClass changeCostClass = new ChangeCostClass();
- changeCostClass.SetUpICardEffect("Digivolution Cost -4", CanUseCondition1, card);
- changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
- card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
- bool CanUseCondition1(Hashtable hashtable)
- {
- return true;
- }
- int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
- {
- if (CardSourceCondition(cardSource))
- {
- if (RootCondition(root))
- {
- if (PermanentsCondition(targetPermanents))
- {
- Cost -= 4;
- }
- }
- }
- return Cost;
- }
- bool PermanentsCondition(List<Permanent> targetPermanents)
- {
- if (targetPermanents != null)
- {
- if (targetPermanents.Count(PermanentCondition) >= 1)
- {
- return true;
- }
- }
- return false;
- }
- bool PermanentCondition(Permanent targetPermanent)
- {
- return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent);
- }
- bool CardSourceCondition(CardSource cardSource)
- {
- return true;
- }
- bool RootCondition(SelectCardEffect.Root root)
- {
- return true;
- }
- bool isUpDown()
- {
- return true;
- }
- }
- }
- }
- }
- ICardEffect GetCardEffect(EffectTiming _timing)
- {
- if (_timing == EffectTiming.BeforePayCost)
- {
- return activateClass1;
- }
- return null;
- }
- IEnumerator ActivateCoroutine2(Hashtable _hashtable1)
- {
- if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
- hashtable: _hashtable1,
- permanentCondition: PermanentCondition,
- cardCondition: null))
- {
- card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect);
- card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect1);
- yield return null;
- }
- }
- ICardEffect GetCardEffect1(EffectTiming _timing)
- {
- if (_timing == EffectTiming.AfterPayCost)
- {
- return activateClass2;
- }
- return null;
- }
- }
- }
- if (timing == EffectTiming.SecuritySkill)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
- activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
- activateClass.SetIsSecurityEffect(true);
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[Security] Add this card to its owner's hand.";
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
- }
- }
- return cardEffects;
- }
- }
- }
|