using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; // Eater (Human Form) namespace DCGO.CardEffects.BT22 { public class BT22_080 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Alternative Digivolution Condition if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.EqualsCardName("Eater (Species Form)"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect( permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null) ); } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Move 1 [Eater (Species Form)] from sources under [Mother Eater] in breeding", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] You may place 1 [Eater (Species Form)] from this Digimon's digivolution cards as the bottom digivolution card of your [Mother Eater] in the breeding area."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, IsMotherEater) && CardEffectCommons.HasMatchConditionPermanentDigivolutionCards(card, isEaterSpeciesForm); } bool IsMotherEater(Permanent permanent) { return permanent.TopCard.EqualsCardName("Mother Eater"); } bool isEaterSpeciesForm(CardSource cardSource) { return cardSource.IsDigimon && cardSource.EqualsCardName("Eater (Species Form)"); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionPermanentDigivolutionCards(card, isEaterSpeciesForm) && CardEffectCommons.HasMatchConditionOwnersBreedingPermanent(card, IsMotherEater)) { Permanent thisPermanent = card.PermanentOfThisCard(); CardSource selectedCard = null; int maxCount = Math.Min(1, thisPermanent.DigivolutionCards.Count(isEaterSpeciesForm)); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: isEaterSpeciesForm, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 digivolution card to move under Mother Eater.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: thisPermanent.DigivolutionCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCard = cardSource; yield return null; } selectCardEffect.SetUpCustomMessage("Select 1 [Eater (Species Form)] to move under Mother Eater.", "The opponent is selecting 1 [Eater (Species Form)] to move under Mother Eater."); selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card"); yield return StartCoroutine(selectCardEffect.Activate()); if (selectedCard != null && card.Owner.GetBreedingAreaPermanents().FirstOrDefault(IsMotherEater) != null) { Permanent motherEater = card.Owner.GetBreedingAreaPermanents().FirstOrDefault(IsMotherEater); yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddExecutingCard(selectedCard)); yield return ContinuousController.instance.StartCoroutine(motherEater.AddDigivolutionCardsBottom(new List() { selectedCard }, activateClass)); } } } } #endregion #region On Security Check if (timing == EffectTiming.OnSecurityCheck) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 [CS] Tamer", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("BT22_080_Play_Tamer"); cardEffects.Add(activateClass); string EffectDiscription() { return "[Your Turn] [Once Per Turn] When this Digimon checks your opponent's security stack, you may play 1 Tamer card with the [CS] trait from your hand without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnAttack(hashtable, card) && CardEffectCommons.IsOwnerTurn(card); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.HasMatchConditionOwnersHand(card, IsCSTamer); } bool IsCSTamer(CardSource cardSource) { return cardSource.IsTamer && cardSource.HasCSTraits && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsCSTamer)) { CardSource selectedCard = null; int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsCSTamer)); SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsCSTamer, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCard = cardSource; yield return null; } 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()); if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true)); } } } #endregion #region ESS #region Reduce Cost Effect ActivateClass activateClass2 = new ActivateClass(); activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card); activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, 1, true, EffectDiscription2()); activateClass2.SetHashString("Reduce_BT22_080"); activateClass2.SetIsInheritedEffect(true); string EffectDiscription2() { return "[Breeding] [Your Turn] [Once Per Turn] When any of your Digimon cards with the [Eater] trait would be played, you may reduce the play costs by 1."; } bool CardCondition(CardSource cardSource) { if (cardSource.Owner == card.Owner) { if (cardSource.IsDigimon) { if (cardSource.HasEaterTraits) { return true; } } } return false; } bool CanUseCondition2(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBreedingArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition)) { return true; } } } return false; } bool CanActivateCondition2(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBreedingArea(card)) { PlayCardClass playCardClass = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable); if (playCardClass != null) { if (playCardClass.PayCost) { return true; } } } return false; } IEnumerator ActivateCoroutine2(Hashtable _hashtable) { if (CardEffectCommons.IsExistOnBreedingArea(card)) { ContinuousController.instance.PlaySE(GManager.instance.GetComponent().BuffSE); ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition1, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass); yield return new WaitForSeconds(0.4f); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable)); 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 -= 1; } } } 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) { CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable); if (Card != null) { if (cardSource == Card) { return true; } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } } } #endregion #region Before Pay Cost if (timing == EffectTiming.BeforePayCost) { cardEffects.Add(activateClass2); } #endregion #region Before Pay Cost (Not Shown) if (timing == EffectTiming.None) { ChangeCostClass changeCostClass = new ChangeCostClass(); changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card); changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true); changeCostClass.SetNotShowUI(true); cardEffects.Add(changeCostClass); bool CanUseCondition(Hashtable hashtable) { if (!card.Owner.isYou && GManager.instance.IsAI) { return false; } if (CardEffectCommons.IsExistOnBreedingArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (activateClass2 != null) { if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn)) { return true; } } } } return false; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { Cost -= 1; } } } 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.IsDigimon) { if (cardSource.HasEaterTraits) { return true; } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } } #endregion #endregion return cardEffects; } } }