using System; using System.Collections; using System.Collections.Generic; using System.Linq; public class EX5_043 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); if (timing == EffectTiming.None) { static bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.ContainsCardName("Leopardmon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 6 && !targetPermanent.TopCard.HasXAntibodyTraits; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null)); } int ReduceCost() { int reduceCost = 4; if (card != null) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.ContainsCardName("Leopardmon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1) { reduceCost += 3; } } } return reduceCost; } if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("PlayDigimon_EX5_043"); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] [Once Per Turn] You may play 1 green Digimon card from your hand with the play cost reduced by 4. If a card with [Leopardmon] in its name or [X Antibody] is in this Digimon's digivolution cards, further reduce it by 3."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass)) { if (cardSource.HasCardColor(CardColor.Green)) { return true; } } } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.HandCards.Count >= 1) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { #region Reduce Cost Effect ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); Func getCardEffect = GetCardEffect; card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect); ICardEffect GetCardEffect(EffectTiming _timing) { if (_timing == EffectTiming.None) { return changeCostClass; } return null; } bool CanUseCondition1(Hashtable hashtable) { return true; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { Cost -= ReduceCost(); } } } return Cost; } bool PermanentsCondition(List targetPermanents) { if (targetPermanents == null) { return true; } else { if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0) { return true; } } return false; } bool CardSourceCondition(CardSource cardSource) { if (cardSource != null) { if (cardSource.Owner == card.Owner) { if (cardSource.HasCardColor(CardColor.Green)) { if (cardSource.IsDigimon) { return true; } } } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } #endregion if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1) { List selectedCards = new List(); int maxCount = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true)); } #region Remove Reduce Cost Effect card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect); #endregion } } if (timing == EffectTiming.OnDeclaration) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card); activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription()); activateClass.SetHashString("PlayDigimon_EX5_043"); cardEffects.Add(activateClass); string EffectDiscription() { return "[Main] [Once Per Turn] You may play 1 green Digimon card from your hand with the play cost reduced by 4. If a card with [Leopardmon] in its name or [X Antibody] is in this Digimon's digivolution cards, further reduce it by 3."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass)) { if (cardSource.HasRoyalKnightTraits) { return true; } if (cardSource.HasCardColor(CardColor.Green)) { return true; } } } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { bool canPlay = false; #region Reduce Cost Effect ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true); Func getCardEffect = GetCardEffect; card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect); ICardEffect GetCardEffect(EffectTiming _timing) { if (_timing == EffectTiming.None) { return changeCostClass; } return null; } bool CanUseCondition1(Hashtable hashtable) { return true; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { Cost -= ReduceCost(); } } } return Cost; } bool PermanentsCondition(List targetPermanents) { if (targetPermanents == null) { return true; } else { if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0) { return true; } } return false; } bool CardSourceCondition(CardSource cardSource) { if (cardSource != null) { if (cardSource.Owner == card.Owner) { if (cardSource.HasCardColor(CardColor.Green)) { if (cardSource.IsDigimon) { return true; } } } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } #endregion if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1) { canPlay = true; } #region Remove Reduce Cost Effect card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect); #endregion if (canPlay) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { #region Reduce Cost Effect ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect("Reduce Play Cost", CanUseCondition1, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); Func getCardEffect = GetCardEffect; card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect); ICardEffect GetCardEffect(EffectTiming _timing) { if (_timing == EffectTiming.None) { return changeCostClass; } return null; } bool CanUseCondition1(Hashtable hashtable) { return true; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { Cost -= ReduceCost(); } } } return Cost; } bool PermanentsCondition(List targetPermanents) { if (targetPermanents == null) { return true; } else { if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0) { return true; } } return false; } bool CardSourceCondition(CardSource cardSource) { if (cardSource != null) { if (cardSource.Owner == card.Owner) { if (cardSource.HasCardColor(CardColor.Green)) { if (cardSource.IsDigimon) { return true; } } } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } #endregion if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1) { List selectedCards = new List(); int maxCount = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: true, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true)); } #region Remove Reduce Cost Effect card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect); #endregion } } if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Return 1 Digimon to hand", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("Bounce_EX5_043"); cardEffects.Add(activateClass); string EffectDiscription() { return "[Your Turn] [Once Per Turn] When one of your Digimon is played, you may return 1 of your opponent's 5000 DP or lower Digimon to the hand. For each of your other Digimon, add 3000 to the maximum DP this effect can choose."; } int maxDP() { int maxDP = 5000; maxDP += 3000 * card.Owner.GetBattleAreaDigimons().Count(permanent => permanent != card.PermanentOfThisCard()); return maxDP; } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { if (permanent.DP <= maxDP()) { return true; } } return false; } bool PermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card); } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)) { if (CardEffectCommons.IsOwnerTurn(card)) { return true; } } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Bounce, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } } } return cardEffects; } }