using Photon.Pun; using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; namespace DCGO.CardEffects.EX3 { public class EX3_008 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Select Effects", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription()); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] Activate 1 of the effects below. - You may digivolve 1 of your other Digimon into a level 4 purple Digimon card with [Free] in its traits from your trash for the cost. - You may DNA digivolve this Digimon and one of your other Digimon in play into a Digimon card in your hand for the cost."; } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)) { if (permanent != card.PermanentOfThisCard()) { foreach (CardSource cardSource in permanent.TopCard.Owner.TrashCards) { if (CanSelectCardCondition(cardSource)) { if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash)) { return true; } } } } } return false; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource.IsDigimon) { if (cardSource.Level == 4) { if (cardSource.HasLevel) { if (cardSource.HasCardColor(CardColor.Purple)) { if (cardSource.CardTraits.Contains("Free")) { return true; } } } } } return false; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { return true; } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { List> selectionElements = new List>() { new SelectionElement(message: $"Digivolve into trash Digimon", value : true, spriteIndex: 0), new SelectionElement(message: $"DNA Digivolve", value : false, spriteIndex: 1), }; string selectPlayerMessage = "Which effect will you activate?"; string notSelectPlayerMessage = "The opponent is choosing which effect to activate."; GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage); yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect()); bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue; if (fromTrash) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { Permanent selectedPermanent = null; int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition)); SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent(); selectPermanentEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectPermanentCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount, canNoSelect: false, canEndNotMax: false, selectPermanentCoroutine: SelectPermanentCoroutine, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Custom, cardEffect: activateClass); selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve."); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); IEnumerator SelectPermanentCoroutine(Permanent permanent) { selectedPermanent = permanent; yield return null; } if (selectedPermanent != null) { yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard( targetPermanent: selectedPermanent, cardCondition: CanSelectCardCondition, payCost: true, reduceCostTuple: null, fixedCostTuple: null, ignoreDigivolutionRequirementFixedCost: -1, isHand: false, activateClass: activateClass, successProcess: null)); } } } else { if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard())) { yield return ContinuousController.instance.StartCoroutine( CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard( CanSelectCardCondition, payCost: true, isHand: true, activateClass, permanentConditions: new Func[] { (permanent) => permanent == card.PermanentOfThisCard() } )); } } } } if (timing == EffectTiming.OnEndTurn) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetIsInheritedEffect(true); cardEffects.Add(activateClass); string EffectDiscription() { return "[End of Your Turn] You may DNA digivolve this Digimon and one of your other Digimon in play into a Digimon card in your hand by paying its DNA digivolve cost."; } bool CanSelectCardCondition(CardSource cardSource) { if (cardSource != null) { if (cardSource.IsDigimon) { if (cardSource.Owner == card.Owner) { if (cardSource.CanPlayJogress(true)) { if (isExistOnField(card)) { if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true)) { return true; } } } } } } return false; } bool CanUseCondition(Hashtable hashtable) { if (isExistOnField(card)) { return true; } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { if (card.Owner.HandCards.Count >= 1) { if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard())) { return true; } } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (isExistOnField(card)) { yield return ContinuousController.instance.StartCoroutine( CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard( CanSelectCardCondition, payCost: true, isHand: true, activateClass, permanentConditions: new Func[] { (permanent) => permanent == card.PermanentOfThisCard() } )); } } } return cardEffects; } } }