using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT17 { public class BT17_058 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Piercing if (timing == EffectTiming.OnDetermineDoSecurityCheck) { cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #region On Play/When Digivolving Shared bool IsSelectableSource(CardSource source) { if (source.IsDigimon) { if (source.HasCardColor(CardColor.Black)) { if (source.HasLevel && source.Level <= 5) return true; } } return false; } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Reveal 3, Place 1 black level 5 or lower Digimon as bottom digivolution source", 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. Place 1 level 5 or lower black Digimon card among them as this Digimon's bottom digivolution card. Trash the rest."; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } return false; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect( revealCount: 3, simplifiedSelectCardConditions: new SimplifiedSelectCardConditionClass[] { new SimplifiedSelectCardConditionClass( canTargetCondition:IsSelectableSource, message: "Select 1 Black Level 5 or lower Digimon.", mode: SelectCardEffect.Mode.Custom, maxCount: 1, selectCardCoroutine: SelectedCardToSources), }, remainingCardsPlace: RemainingCardsPlace.Trash, activateClass: activateClass, canNoSelect: false )); IEnumerator SelectedCardToSources(CardSource source) { if (source != null) yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List { source }, activateClass)); } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Reveal 3, Place 1 black level 5 or lower Digimon as bottom digivolution source", 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. Place 1 level 5 or lower black Digimon card among them as this Digimon's bottom digivolution card. Trash the rest."; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } return false; } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleAreaDigimon(card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect( revealCount: 3, simplifiedSelectCardConditions: new SimplifiedSelectCardConditionClass[] { new SimplifiedSelectCardConditionClass( canTargetCondition:IsSelectableSource, message: "Select 1 Black Level 5 or lower Digimon.", mode: SelectCardEffect.Mode.Custom, maxCount: 1, selectCardCoroutine: SelectedCardToSources), }, remainingCardsPlace: RemainingCardsPlace.Trash, activateClass: activateClass, canNoSelect: false )); IEnumerator SelectedCardToSources(CardSource source) { if (source != null) yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(new List { source }, activateClass)); } } } #endregion #region End Of Attack if (timing == EffectTiming.OnEndAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 level 5 or lower digimon with [Machine] trait", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("EndOfAttack_BT17_058"); cardEffects.Add(activateClass); string EffectDiscription() { return "[End of Attack] [Once Per Turn] You may play 1 level 5 or lower Digimon card with the [Machine] trait from this Digimon's digivolution cards without paying the cost."; } bool CanSelectSourceCard(CardSource source) { if (source.IsDigimon) { if(source.HasLevel && source.Level <= 5) { if (source.CardTraits.Contains("Machine")) { if (CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass)) { return true; } } } } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if (CardEffectCommons.CanTriggerOnEndAttack(hashtable, card)) return true; } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleAreaDigimon(card)) { if(card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectSourceCard) > 0) return true; } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent permanent = card.PermanentOfThisCard(); if (permanent.DigivolutionCards.Count(CanSelectSourceCard) >= 1) { List selectedCards = new List(); int maxCount = 1; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectSourceCard, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to play.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: permanent.DigivolutionCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage( "Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play."); selectCardEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectCardEffect.Activate()); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true)); } } } #endregion return cardEffects; } } }