using System; using System.Collections; using System.Collections.Generic; using System.Linq; // WarGreymon namespace DCGO.CardEffects.AD1 { public class AD1_004 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Raid and Piercing if (timing == EffectTiming.OnAllyAttack) { cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null)); } if (timing == EffectTiming.OnDetermineDoSecurityCheck) { cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #region Alternative Digivolution Condition if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { if (targetPermanent.TopCard.ContainsCardName("Greymon") || targetPermanent.TopCard.EqualsTraits("ADVENTURE") || targetPermanent.TopCard.EqualsTraits("HERO")) { return true; } return false; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null) ); } #endregion #region Shared OP/WD string SharedEffectName() => "Delete 1 enemy Digimon"; string SharedEffectDescription(string tag) => $"[{tag}] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon."; bool SharedCanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } bool SharedCanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP; } IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass) { if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedCanSelectPermanentCondition)) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SharedCanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, 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(SharedCanActivateCondition, 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(SharedCanActivateCondition, 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.None) { int count() { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { List cards = card.Owner.GetBattleAreaPermanents() .Map(card => card.TopCard) .Where(x => x.IsTamer).ToList(); var colourCount = Combinations.GetDifferenetColorCardCount(cards); var newDP = colourCount * 1000; return newDP; } return 0; } bool Condition() { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && card.PermanentOfThisCard().TopCard == card; } cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect>( changeValue: count, isInheritedEffect: false, card: card, condition: Condition)); } if (timing == EffectTiming.None) { int count() { if (CardEffectCommons.IsExistOnBattleArea(card)) { List cards = card.Owner.GetBattleAreaPermanents() .Map(card => card.TopCard) .Where(x => x.IsTamer).ToList(); var colourCount = Combinations.GetDifferenetColorCardCount(cards); return colourCount / 3; } return 0; } bool Condition() { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (count() >= 1) { return true; } } return false; } cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect>(changeValue: count, isInheritedEffect: false, card: card, condition: Condition)); } #endregion #region End of Turn if (timing == EffectTiming.OnEndTurn) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("May attack", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription()); cardEffects.Add(activateClass); string EffectDescription() { return "[End of Your Turn] 1 of your Digimon may attack."; } bool IsYourDigimon(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) && permanent.CanAttack(activateClass); } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent selectedPermanent = null; if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon)) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsYourDigimon)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsYourDigimon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } } if (selectedPermanent != null) { if (selectedPermanent.CanAttack(activateClass)) { SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent(); selectAttackEffect.SetUp( attacker: selectedPermanent, canAttackPlayerCondition: () => true, defenderCondition: (permanent) => true, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate()); } } } } #endregion #region When Attacking - ESS if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon with as much or less DP than this Digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription()); activateClass.SetIsInheritedEffect(true); activateClass.SetHashString("ESS_AD01_004"); cardEffects.Add(activateClass); string EffectDescription() { return "[When Attacking][Once Per Turn] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon with [Greymon] or [Omnimon] in it's name."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnAttack(hashtable, card) && CardEffectCommons.IsExistOnBattleAreaDigimon(card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } bool CanSelectPermanentCondition(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.HasDP && permanent.DP <= card.PermanentOfThisCard().DP; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if ((card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon") || card.PermanentOfThisCard().TopCard.ContainsCardName("Greymon")) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, 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.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } } } #endregion return cardEffects; } } }