using Photon.Pun; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace DCGO.CardEffects.BT16 { public class BT16_065 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); bool HasBossTraitInPlay(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)) { if (permanent.IsDigimon) { if (permanent.TopCard.CardTraits.Contains("Boss")) { return true; } } } return false; } bool CanSelectDBrigadeCondition(CardSource cardSource) { return cardSource.CardTraits.Contains("D-Brigade"); } #region Before Pay Cost - Condition Effect if (timing == EffectTiming.BeforePayCost) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Return 6 [D-Brigade] to get Play Cost -6", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); activateClass.SetHashString("PlayCost-12_BT16_065"); cardEffects.Add(activateClass); string EffectDiscription() { return "When this card would be played, if there is a Digimon with the [Boss] trait, reduce the play cost by 6. By returning 6 cards with the [D-Brigade] trait from your trash to the top of the deck, reduce the play cost by 6."; } bool CardCondition(CardSource cardSource) { if (cardSource == card) { if (CardEffectCommons.IsExistOnHand(cardSource)) { return true; } } return false; } bool CanNoSelect(CardSource cardSource) { if (cardSource != null) { if (cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false) > cardSource.Owner.MaxMemoryCost) { return false; } } return true; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnHand(card)) { if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6) { return true; } if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay)) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { List selectedCards = new List(); if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6) { bool noSelect = CanNoSelect(CardEffectCommons.GetCardFromHashtable(_hashtable)); int maxCount = 6; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectDBrigadeCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => noSelect, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select cards to add to the top your deck\n(cards will be placed back to the top of the deck so that cards with lower numbers are on top).", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, 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 SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (selectedCards.Count == 6) { selectedCards.Reverse(); yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryTopCards(selectedCards)); } } if (card.Owner.CanReduceCost(null, 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); 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)) { int targetCost = 0; if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay)) targetCost += 6; if (selectedCards.Count >= 6) targetCost += 6; Cost -= targetCost; } } } 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) { return cardSource == card; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable)); } } #endregion #region Reduce Play 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.HandCards.Contains(card)) { ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "Return 6 [D-Brigade] to get Play Cost -6"); if (activateClass != null) { if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition) >= 6) { return true; } if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay)) { return true; } } } return false; } int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List targetPermanents) { if (CardSourceCondition(cardSource)) { if (RootCondition(root)) { if (PermanentsCondition(targetPermanents)) { int trashCount = CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectDBrigadeCondition); int targetCount = 0; if (trashCount >= 6) targetCount += 6; if (CardEffectCommons.HasMatchConditionPermanent(HasBossTraitInPlay)) targetCount += 6; Cost -= targetCount; } } } 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 == card) { return true; } } return false; } bool RootCondition(SelectCardEffect.Root root) { return true; } bool isUpDown() { return true; } } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Reveal top 3, then delete 1 digimon.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Play] Reveal the top 3 cards of your deck. Delete 1 of your opponent's Digimon with play cost less than or equal to the play cost of 1 of the cards among them. Trash the revealed cards."; } bool RevealSelectCardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (cardSource.HasPlayCost) { return true; } } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (card.Owner.LibraryCards.Count >= 1) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { int costDeletion = 0; yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect( revealCount: 3, simplifiedSelectCardConditions: new SimplifiedSelectCardConditionClass[] { new SimplifiedSelectCardConditionClass( canTargetCondition:RevealSelectCardCondition, message: "Select Play cost to use", mode: SelectCardEffect.Mode.Custom, maxCount: 1, selectCardCoroutine: SelectCardCoroutine) }, remainingCardsPlace: RemainingCardsPlace.Trash, activateClass: activateClass, isSendAllCardsToSamePlace: true )); IEnumerator SelectCardCoroutine(CardSource cardSource) { costDeletion = cardSource.GetCostItself; yield return null; } if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { if (permanent.TopCard.HasPlayCost) { if (permanent.TopCard.GetCostItself <= costDeletion) { return true; } } } return false; } yield return null; } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Reveal top 3, then delete 1 digimon.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] Reveal the top 3 cards of your deck. Delete 1 of your opponent's Digimon with play cost less than or equal to the play cost of 1 of the cards among them. Trash the revealed cards."; } bool RevealSelectCardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (cardSource.HasPlayCost) { return true; } } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (card.Owner.LibraryCards.Count >= 1) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { int costDeletion = 0; yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect( revealCount: 3, simplifiedSelectCardConditions: new SimplifiedSelectCardConditionClass[] { new SimplifiedSelectCardConditionClass( canTargetCondition:RevealSelectCardCondition, message: "Select Play cost to use", mode: SelectCardEffect.Mode.Custom, maxCount: 1, selectCardCoroutine: SelectCardCoroutine) }, remainingCardsPlace: RemainingCardsPlace.Trash, activateClass: activateClass, isSendAllCardsToSamePlace: true )); IEnumerator SelectCardCoroutine(CardSource cardSource) { costDeletion = cardSource.GetCostItself; yield return null; } if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition)) { SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { if (permanent.TopCard.HasPlayCost) { if (permanent.TopCard.GetCostItself <= costDeletion) { return true; } } } return false; } yield return null; } } #endregion #region End of Turn if (timing == EffectTiming.OnEndTurn) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("DNA digivolve into [Chaosmon]", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[End of Your Turn] 2 of your Digimon may DNA digivolve into a [Chaosmon] in your hand."; } bool CanSelectDNACardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (cardSource.CanPlayJogress(true)) { if (cardSource.CardNames.Contains("Chaosmon")) { return true; } } } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } bool CanActivateCondition(Hashtable hashtable) { if (!CardEffectCommons.IsOwnerTurn(card)) return false; if (card.Owner.GetBattleAreaDigimons().Count < 2) return false; if (card.Owner.HandCards.Count(CanSelectDNACardCondition) < 1) return false; return true; } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine( CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard( CanSelectDNACardCondition, payCost: true, isHand: true, activateClass )); } } #endregion return cardEffects; } } }