| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- namespace DCGO.CardEffects.BT18
- {
- public class BT18_017 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region When Digivolving
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Delete all opponent's digimon with the lowest DP.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
- cardEffects.Add(activateClass);
- string EffectDescription()
- {
- return "[When Digivolving] Delete all of your opponent's Digimon with the lowest DP.";
- }
- bool PermanentCondition(Permanent permanent)
- {
- return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
- return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleArea(card);
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
- yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
- }
- }
- #endregion
- #region On Play
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Delete all opponent's digimon with the lowest DP.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[On Play] Delete all of your opponent's Digimon with the lowest DP.";
- }
- bool PermanentCondition(Permanent permanent)
- {
- return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
- return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleArea(card);
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
- yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
- }
- }
- #endregion
- #region All Turns
- if (timing == EffectTiming.WhenRemoveField)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Return a Digimon to the hand or play a Digimon from the digivolution sources.", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns] When this Digimon would leave the battle area, you may return to the hand or play 1 level 4 or lower red Digimon card from this Digimon's digivolution cards without paying the cost.";
- }
- bool CanSelectCardCondition(CardSource cardSource)
- {
- if (cardSource != null)
- {
- if (cardSource.Owner == card.Owner)
- {
- if (cardSource.IsDigimon)
- {
- if (cardSource.Level <= 4)
- {
- if (cardSource.HasCardColor(CardColor.Red))
- {
- if (cardSource.HasLevel)
- {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
- {
- if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
- {
- return true;
- }
- }
- return false;
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
- {
- if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
- {
- return true;
- }
- }
- return false;
- }
- IEnumerator ActivateCoroutine(Hashtable _hashtable)
- {
- bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
- && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
- if (canSelectDigivolutionCards)
- {
- if (canSelectDigivolutionCards)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"Return to hand", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"Play a Digimon", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "Do you want to return to hand or play 1 level 4 or lower Digimon from its digivolution sources";
- string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- }
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
- List<CardSource> selectedCards = new List<CardSource>();
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCards.Add(cardSource);
- yield return null;
- }
- if (toHand)
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 card to return to hand.",
- maxCount: 1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.AddHand,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- yield return StartCoroutine(selectCardEffect.Activate());
- }
- else
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanSelectCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 card to play.",
- maxCount: 1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Custom,
- customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
- yield return StartCoroutine(selectCardEffect.Activate());
- }
- SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
- if (!toHand)
- {
- root = SelectCardEffect.Root.DigivolutionCards;
- if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedCards[0], payCost: false, cardEffect: activateClass))
- {
- yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
- cardSources: selectedCards,
- activateClass: activateClass,
- payCost: false,
- isTapped: false,
- root: root,
- activateETB: true));
- }
- }
- }
- }
- }
- #endregion
- #region DigiXros
- if (timing == EffectTiming.None)
- {
- AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
- addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
- addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
- addDigiXrosConditionClass.SetNotShowUI(true);
- cardEffects.Add(addDigiXrosConditionClass);
- bool CanUseCondition(Hashtable hashtable)
- {
- return true;
- }
- DigiXrosCondition GetDigiXros(CardSource cardSource)
- {
- if (cardSource == card)
- {
- DigiXrosConditionElement elementGrumblemon =
- new DigiXrosConditionElement(CanSelectCardCondition, "Grumblemon");
- bool CanSelectCardCondition(CardSource conditionCardSource)
- {
- if (conditionCardSource != null)
- {
- if (conditionCardSource.Owner == card.Owner)
- {
- if (conditionCardSource.IsDigimon)
- {
- if (conditionCardSource.CardNames_DigiXros.Contains("Grumblemon"))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- DigiXrosConditionElement elementGigasmon =
- new DigiXrosConditionElement(CanSelectCardCondition1, "Gigasmon");
- bool CanSelectCardCondition1(CardSource conditionCardSource)
- {
- if (conditionCardSource != null)
- {
- if (conditionCardSource.Owner == card.Owner)
- {
- if (conditionCardSource.IsDigimon)
- {
- if (conditionCardSource.CardNames_DigiXros.Contains("Gigasmon"))
- {
- return true;
- }
- }
- }
- }
- return false;
- }
- List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
- { elementGrumblemon, elementGigasmon };
- DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
- return digiXrosCondition;
- }
- return null;
- }
- }
- #endregion
- return cardEffects;
- }
- }
- }
|