using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace DCGO.CardEffects.BT17 { public class BT17_051 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Alternate Digivolution if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsCardName("Argomon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region On Play/When Digivolving Shared int maxLevel() { int max = 4; max += (int)Mathf.Floor(card.PermanentOfThisCard().DigivolutionCards.Count((source) => source.EqualsCardName("Argomon")) / 2); return max; } bool IsLevel5orLowerArgomon(CardSource source) { if (source.IsDigimon || source.IsDigiEgg) { if (source.HasLevel && source.Level <= 5) { if (source.EqualsCardName("Argomon")) { return true; } } } return false; } bool CanSelectOpponentsDigimon(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { if (permanent.TopCard.Level <= maxLevel()) { if (permanent.TopCard.HasLevel) { return true; } } } return false; } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Place up to 4, Then delete up to 4 levels total digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Play] You may place up to 4 level 5 or lower [Argomon] from your trash as this Digimon's bottom digivolution cards. Then, delete up to 4 levels' total worth of your opponent’s Digimon. For every 2 [Argomon] in this Digimon's digivolution cards, add 1 to the maximum total level you may choose with this effect."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsLevel5orLowerArgomon)) { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: IsLevel5orLowerArgomon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectCardCoroutine, message: "Select cards to place as the bottom digivolution sources", maxCount: 4, canEndNotMax: true, isShowOpponent: false, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator AfterSelectCardCoroutine(List cardSources) { if (cardSources.Count > 0) { yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card)); yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(cardSources, activateClass)); } } } if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon) >= 1) { int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectOpponentsDigimon, canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList, canEndSelectCondition: CanEndSelectCondition, maxCount: maxCount, canNoSelect: false, canEndNotMax: true, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); bool CanEndSelectCondition(List permanents) { if (permanents.Count <= 0) { return false; } int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.Level; } if (sumCost > maxLevel()) { return false; } return true; } bool CanTargetCondition_ByPreSelecetedList(List permanents, Permanent permanent) { int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.Level; } sumCost += permanent.TopCard.Level; if (sumCost > maxLevel()) { return false; } return true; } } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Place up to 4, Then delete up to 4 levels total digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] You may place up to 4 level 5 or lower [Argomon] from your trash as this Digimon's bottom digivolution cards. Then, delete up to 4 levels' total worth of your opponent’s Digimon. For every 2 [Argomon] in this Digimon's digivolution cards, add 1 to the maximum total level you may choose with this effect."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsLevel5orLowerArgomon)) { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: IsLevel5orLowerArgomon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectCardCoroutine, message: "Select cards to place as the bottom digivolution sources", maxCount: 4, canEndNotMax: true, isShowOpponent: false, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); IEnumerator AfterSelectCardCoroutine(List cardSources) { if (cardSources.Count > 0) { yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card)); yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(cardSources, activateClass)); } } } if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon) >= 1) { int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectOpponentsDigimon, canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList, canEndSelectCondition: CanEndSelectCondition, maxCount: maxCount, canNoSelect: false, canEndNotMax: true, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); bool CanEndSelectCondition(List permanents) { if (permanents.Count <= 0) { return false; } int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.Level; } if (sumCost > maxLevel()) { return false; } return true; } bool CanTargetCondition_ByPreSelecetedList(List permanents, Permanent permanent) { int sumCost = 0; foreach (Permanent permanent1 in permanents) { sumCost += permanent1.TopCard.Level; } sumCost += permanent.TopCard.Level; if (sumCost > maxLevel()) { return false; } return true; } } } } #endregion #region All Turns if (timing == EffectTiming.None) { int count() { return (int)Mathf.Floor(card.PermanentOfThisCard().DigivolutionCards.Count((source) => source.EqualsCardName("Argomon")) / 2); } bool Condition() { if (count() >= 1) return true; return false; } cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect>( changeValue: () => 1000 * count(), isInheritedEffect: false, card: card, condition: Condition)); } #endregion #region Opponent's Turn if (timing == EffectTiming.None) { bool PermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card)) { if (permanent.IsTamer) { return true; } } return false; } bool CanUseCondition() { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (!CardEffectCommons.IsOwnerTurn(card)) return true; } return false; } string effectName = "[Opponent's Turn] None of your opponent's Tamers can unsuspend."; cardEffects.Add(CardEffectFactory.CantUnsuspendStaticEffect( permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition, effectName: effectName)); } #endregion return cardEffects; } } }