using System; using System.Collections; using System.Collections.Generic; // Unique Emblem: Poseidia Lagoon namespace DCGO.CardEffects.BT22 { public class BT22_096 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Main if (timing == EffectTiming.OptionSkill) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play 1 [Sangomon] or [Yao Qinglan] from hand or trash", CanUseCondition, card); activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[Main] You may play 1 [Sangomon] or [Yao Qinglan] from your hand or trash without paying the cost. Then, place this card in the battle area."; } bool IsYaoQinglanOrSangomon(CardSource cardSource) { return cardSource.EqualsCardName("Sangomon") || cardSource.EqualsCardName("Yao Qinglan"); } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card); } IEnumerator ActivateCoroutine(Hashtable hashtable) { bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsYaoQinglanOrSangomon); bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsYaoQinglanOrSangomon); if (canSelectHand || canSelectTrash) { #region Option Selection if (canSelectHand && canSelectTrash) { List> selectionElements = new List>() { new SelectionElement(message: $"From hand", value : true, spriteIndex: 0), new SelectionElement(message: $"From trash", value : false, spriteIndex: 1), }; string selectPlayerMessage = "From which area do you select a card?"; string notSelectPlayerMessage = "The opponent is choosing from which area to select 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()); #endregion bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue; CardSource selectedCard = null; IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCard = cardSource; yield return null; } if (fromHand) { #region Play from Hand SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsYaoQinglanOrSangomon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: 1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source."); yield return StartCoroutine(selectHandEffect.Activate()); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(new List() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true)); #endregion } if (!fromHand) { #region Play from Trash SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: IsYaoQinglanOrSangomon, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to add as source.", maxCount: 1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source."); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(new List() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true)); #endregion } } yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass)); } } #endregion #region Delay if (timing == EffectTiming.OnTappedAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Digivolve 1 [Aqua]/[Sea Animal] digimon into a [Aquatic]/[Liberator] digimon in your hand for 3 reduced cost", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[Your Turn] When any of your [Yao Qinglan] suspend, (By trashing this card after the placing turn, activate the effect below.). 1 of your Digimon with [Aqua] or [Sea Animal] in any of its traits may digivolve into an [Aquatic] and [LIBERATOR] trait Digimon card in the hand with the digivolution cost reduced by 3."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanDeclareOptionDelayEffect(card) && CardEffectCommons.IsOwnerTurn(card) && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsYaoQinglan); } bool CanActivateCondition(Hashtable hashtable) { return CardEffectCommons.IsExistOnBattleArea(card); } bool IsYaoQinglan(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && permanent.TopCard.EqualsCardName("Yao Qinglan"); } bool IsAquaOrSeaAnimal(Permanent permanent) { return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) && permanent.TopCard.HasAquaTraits; } bool IsAquaticOrLiberator(CardSource cardSource, Permanent permanent) { return CardEffectCommons.IsExistOnHand(cardSource) && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass) && cardSource.HasAquaticTraits && cardSource.HasLiberatorTraits; } IEnumerator ActivateCoroutine(Hashtable hashtable) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null)); IEnumerator SuccessProcess() { if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsAquaOrSeaAnimal)) { Permanent selectedPermanent = null; #region Select [Aqua]/[Sea Animal] Permanent int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsAquaOrSeaAnimal)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: IsAquaOrSeaAnimal, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } selectPermanentEffect.SetUpCustomMessage("Select 1 [Aqua]/[Sea Animal] to digivolve.", "The opponent is selecting 1 [Aqua]/[Sea Animal] to digivolve."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); #endregion if (selectedPermanent != null) { #region Digivolve into [Aquatic/LIBERATOR] Digimon yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( selectedPermanent, digivolvingCard => IsAquaticOrLiberator(digivolvingCard, selectedPermanent), payCost: true, reduceCostTuple: (reduceCost: 3, reduceCostCardCondition: null), fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: true, activateClass: activateClass, successProcess: null )); #endregion } } } } } #endregion #region Security if (timing == EffectTiming.SecuritySkill) { CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Play 1 [Sangomon] or [Yao Qinglan] from hand or trash"); } #endregion return cardEffects; } } }