| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using Unity.Mathematics;
- // Wargrowlmon
- namespace DCGO.CardEffects.AD1
- {
- public class AD1_003 : CEntity_Effect
- {
- public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
- {
- List<ICardEffect> cardEffects = new List<ICardEffect>();
- #region Alternate Digivolution Requirement
- if (timing == EffectTiming.None)
- {
- static bool PermanentCondition(Permanent targetPermanent)
- {
- return targetPermanent.TopCard.ContainsCardName("Growlmon")
- || targetPermanent.TopCard.EqualsTraits("Hero");
- }
- cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
- }
- #endregion
- #region Raid
- if (timing == EffectTiming.OnAllyAttack)
- {
- cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
- }
- #endregion
- #region Shared OP / WD
- string SharedEffectName = "Play 1 [Takato Matsuki] from hand or trash for free, then may delete 1 opponent's Digimon w/ 6000 DP or less";
- string SharedEffectDescription(string tag) => $"[{tag}] You may play 1 [Takato Matsuki] from your hand or trash without paying the cost. Then, you may delete 1 of your opponent's Digimon with 6000 DP or less.";
- bool SharedCanActivateCondition(Hashtable hashtable, ActivateClass activateClass)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && (CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass))
- || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass))
- || CardEffectCommons.HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, activateClass)));
- }
- bool CanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
- {
- return cardSource.EqualsCardName("Takato Matsuki")
- && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
- }
- bool CanSelectPermanentCondition(Permanent permanent, ActivateClass activateClass)
- {
- return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
- && permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass);
- }
- IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
- {
- bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
- bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, cardSource => CanSelectCardCondition(cardSource, activateClass));
- if (canSelectHand || canSelectTrash)
- {
- #region Setup Location Selection
- if (canSelectHand && canSelectTrash)
- {
- List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
- {
- new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
- new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
- };
- string selectPlayerMessage = "From which area do you select a card?";
- string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
- GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
- }
- else
- {
- GManager.instance.userSelectionManager.SetBool(canSelectHand);
- }
- yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
- #endregion
- bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
- CardSource selectedCard = null;
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCard = cardSource;
- yield return null;
- }
- #region Hand/Trash Card Selection & Play
- if (fromHand)
- {
- SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
- selectHandEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- isShowOpponent: true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- mode: SelectHandEffect.Mode.Custom,
- cardEffect: activateClass);
- selectHandEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
- yield return StartCoroutine(selectHandEffect.Activate());
- if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
- CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
- }
- else
- {
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: cardSource => CanSelectCardCondition(cardSource, activateClass),
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 [Takato Matsuki] to play.",
- maxCount: 1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.Trash,
- customRootCardList: null,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect.SetUpCustomMessage("Select 1 [Takato Matsuki] to play.", "The opponent is selecting 1 [Takato Matsuki] to play.");
- yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
- if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
- CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
- }
- #endregion
- }
- if(CardEffectCommons.HasMatchConditionPermanent(permanent => CanSelectPermanentCondition(permanent, activateClass)))
- {
- SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
- selectPermanentEffect.SetUp(
- selectPlayer: card.Owner,
- canTargetCondition: permanent => CanSelectPermanentCondition(permanent, activateClass),
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- maxCount: 1,
- canNoSelect: true,
- canEndNotMax: false,
- selectPermanentCoroutine: null,
- afterSelectPermanentCoroutine: null,
- mode: SelectPermanentEffect.Mode.Destroy,
- cardEffect: activateClass);
- yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
- }
- }
- #endregion
- #region On Play
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
- activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
- cardEffects.Add(activateClass);
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
- }
- }
- #endregion
- #region When Digivolving
- if (timing == EffectTiming.OnEnterFieldAnyone)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
- activateClass.SetUpActivateClass(hash => SharedCanActivateCondition(hash, activateClass), hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
- cardEffects.Add(activateClass);
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
- }
- }
- #endregion
- #region All Turns
- if (timing == EffectTiming.WhenRemoveField)
- {
- ActivateClass activateClass = new ActivateClass();
- activateClass.SetUpICardEffect("Play 1 [Takato Matsuki] and [Guilmon] from source without paying the cost", CanUseCondition, card);
- activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
- activateClass.SetIsInheritedEffect(true);
- cardEffects.Add(activateClass);
- string EffectDiscription()
- {
- return "[All Turns] When this Digimon with [Gallantmon] in its name would leave the battle area other than by your effects, you may play 1 each of [Takato Matsuki] and [Guilmon] from its digivolution cards without paying the cost.";
- }
- bool CanSelectSourceCardCondition(CardSource cardSource)
- {
- return cardSource.EqualsCardName("Takato Matsuki") &&
- CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
- }
- bool CanSelectSourceCardCondition1(CardSource cardSource)
- {
- return cardSource.EqualsCardName("Guilmon") &&
- CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
- }
- bool CanUseCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && card.PermanentOfThisCard().TopCard.ContainsCardName("Gallantmon")
- && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
- && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
- }
- bool CanActivateCondition(Hashtable hashtable)
- {
- return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
- && (card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition)
- || card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectSourceCardCondition1));
- }
- IEnumerator ActivateCoroutine(Hashtable hashtable)
- {
- List<CardSource> selectedCards = new List<CardSource>();
- int maxCount = math.min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition));
- int maxCount1 = math.min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCardCondition1));
- SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect.SetUp(
- canTargetCondition: CanSelectSourceCardCondition,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 [Takato Matsuki] card to play.",
- maxCount: maxCount,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.DigivolutionCards,
- customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect.SetUpCustomMessage(
- "Select 1 [Takato Matsuki] card to play.",
- "The opponent is selecting 1 [Takato Matsuki] card to play.");
- selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
- yield return StartCoroutine(selectCardEffect.Activate());
- SelectCardEffect selectCardEffect1 = GManager.instance.GetComponent<SelectCardEffect>();
- selectCardEffect1.SetUp(
- canTargetCondition: CanSelectSourceCardCondition1,
- canTargetCondition_ByPreSelecetedList: null,
- canEndSelectCondition: null,
- canNoSelect: () => true,
- selectCardCoroutine: SelectCardCoroutine,
- afterSelectCardCoroutine: null,
- message: "Select 1 [Guilmon] card to play.",
- maxCount: maxCount1,
- canEndNotMax: false,
- isShowOpponent: true,
- mode: SelectCardEffect.Mode.Custom,
- root: SelectCardEffect.Root.DigivolutionCards,
- customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
- canLookReverseCard: true,
- selectPlayer: card.Owner,
- cardEffect: activateClass);
- selectCardEffect1.SetUpCustomMessage(
- "Select 1 [Guilmon] card to play.",
- "The opponent is selecting 1 [Guilmon] card to play.");
- selectCardEffect1.SetUpCustomMessage_ShowCard("Played Card");
- yield return StartCoroutine(selectCardEffect1.Activate());
- IEnumerator SelectCardCoroutine(CardSource cardSource)
- {
- selectedCards.Add(cardSource);
- yield return null;
- }
- yield return ContinuousController.instance.StartCoroutine(
- CardEffectCommons.PlayPermanentCards(
- cardSources: selectedCards,
- activateClass: activateClass,
- payCost: false,
- isTapped: false,
- root: SelectCardEffect.Root.DigivolutionCards,
- activateETB: true));
- }
- }
- #endregion
- return cardEffects;
- }
- }
- }
|