using System.Collections; using System.Collections.Generic; using System; using System.Linq; namespace DCGO.CardEffects.P { public class P_156 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Ignore Color Requirements if (timing == EffectTiming.None) { IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass(); ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card); ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition); cardEffects.Add(ignoreColorConditionClass); bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer); } bool CardCondition(CardSource cardSource) { return (cardSource == card); } } #endregion #region Main if (timing == EffectTiming.OptionSkill) { List tamerColors = new List(); ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 Digimon, 3 cost or less", CanUseCondition, card); activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[Main] Choose 1 Tamer. You may play 1 Digimon card with the same color as that Tamer and with a play cost of 3 or less from your hand or trash without paying the cost."; } bool HasTamer(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)) return permanent.IsTamer; return false; } bool SelectDigimonCondition(CardSource source) { if (source.IsDigimon) { if (CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass)) { if(source.GetCostItself <= 3) { foreach (CardColor color in source.CardColors) { if (tamerColors.Contains(color)) return true; } } } } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card)) return CardEffectCommons.HasMatchConditionPermanent(HasTamer); return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { Permanent selectedPermanent = null; if (CardEffectCommons.HasMatchConditionPermanent(HasTamer)) { int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasTamer)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: HasTamer, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: TamerSelected, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer.", "The opponent is selecting 1 Tamer."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } IEnumerator TamerSelected(Permanent permanent) { selectedPermanent = permanent; yield return null; } if(selectedPermanent != null) { tamerColors = selectedPermanent.TopCard.CardColors; bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, SelectDigimonCondition); bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SelectDigimonCondition); if (canSelectHand || canSelectTrash) { if (canSelectHand && canSelectTrash) { List> selectionElements = new List> { new(message: "From hand", value: true, spriteIndex: 0), new(message: "From trash", value: false, spriteIndex: 1), }; string selectPlayerMessage = "From which area do you play a card?"; string notSelectPlayerMessage = "The opponent is choosing from which area to play a card."; GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); } else { GManager.instance.userSelectionManager.SetBool(canSelectHand); } yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager .WaitForEndSelect()); bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue; if (fromHand) { SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: SelectDigimonCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: DigimonSelected, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played card"); yield return StartCoroutine(selectHandEffect.Activate()); } else { SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: SelectDigimonCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: null, afterSelectCardCoroutine: DigimonSelected, message: "Select Digimon to play.", maxCount: 1, canEndNotMax: true, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 Digimon to play.", "The opponent is selecting 1 Digimon to play."); yield return StartCoroutine(selectCardEffect.Activate()); } } } IEnumerator DigimonSelected(List selectedCards) { SelectCardEffect.Root root = SelectCardEffect.Root.Hand; if (card.Owner.TrashCards.Contains(selectedCards[0])) root = SelectCardEffect.Root.Trash; yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root, activateETB: true)); } } } #endregion #region Security if (timing == EffectTiming.SecuritySkill) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 tamer, then add this card to hand", CanUseCondition, card); activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription()); activateClass.SetIsSecurityEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[Security] You may play 1 tamer card from your hand without paying the cost. Then, add this card to the hand."; } bool HasTamer(CardSource source) { if (CardEffectCommons.CanPlayAsNewPermanent(source, false,activateClass)) return source.IsTamer; return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasTamer)) { SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: HasTamer, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: SelectCardCoroutine, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage( "Select 1 tamer to play.", "The opponent is selecting 1 tamer to play."); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator SelectCardCoroutine(List cardSources) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards( cardSources: cardSources, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true)); } } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass)); } } #endregion return cardEffects; } } }