using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT16 { public class BT16_079 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Digivolution Condition if (timing == EffectTiming.None) { bool PermanentCondition(Permanent targetPermanent) { return targetPermanent.TopCard.CardNames.Contains("Cherubimon"); } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region Alliance if (timing == EffectTiming.OnAllyAttack) { cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #region When Attacking if (timing == EffectTiming.OnAllyAttack) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play a level 4 or lower Digimon from your hand or trash.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("PlayDigimon_BT16_079"); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Attacking] [Once Per Turn] You may play 1 level 4 or lower yellow or green Digimon from your hand or trash without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnAttack(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { return true; } return false; } bool CanSelectCardCondition(CardSource cardSource) { if (CardEffectCommons.IsExistOnHand(cardSource)) { if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon) { return true; } if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon) { return true; } } return false; } bool CanSelectCardCondition1(CardSource cardSource) { if (CardEffectCommons.IsExistOnTrash(cardSource)) { if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon) { return true; } if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1; bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition1) >= 1; if (canSelectHand || canSelectTrash) { 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 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; List selectedCards = new List(); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (fromHand) { int maxCount1 = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectHandEffect.Activate()); } else { int maxCount1 = 1; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition1, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to play.", maxCount: maxCount1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: card.Owner.TrashCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play."); selectCardEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectCardEffect.Activate()); } SelectCardEffect.Root root = SelectCardEffect.Root.Hand; if (!fromHand) { 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 When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Play a level 4 or lower Digimon from your hand or trash.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("PlayDigimon_BT16_079"); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] [Once Per Turn] You may play 1 level 4 or lower yellow or green Digimon from your hand or trash without paying the cost."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { return true; } return false; } bool CanSelectCardCondition(CardSource cardSource) { if (CardEffectCommons.IsExistOnHand(cardSource)) { if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon) { return true; } if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon) { return true; } } return false; } bool CanSelectCardCondition1(CardSource cardSource) { if (CardEffectCommons.IsExistOnTrash(cardSource)) { if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Yellow) && cardSource.IsDigimon) { return true; } if (cardSource.Level <= 4 && cardSource.HasCardColor(CardColor.Green) && cardSource.IsDigimon) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1; bool canSelectTrash = card.Owner.TrashCards.Count(CanSelectCardCondition1) >= 1; if (canSelectHand || canSelectTrash) { 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 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; List selectedCards = new List(); IEnumerator SelectCardCoroutine(CardSource cardSource) { selectedCards.Add(cardSource); yield return null; } if (fromHand) { int maxCount1 = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardCondition, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: maxCount1, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, mode: SelectHandEffect.Mode.Custom, cardEffect: activateClass); selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play."); selectHandEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectHandEffect.Activate()); } else { int maxCount1 = 1; SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardCondition1, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => true, selectCardCoroutine: SelectCardCoroutine, afterSelectCardCoroutine: null, message: "Select 1 card to play.", maxCount: maxCount1, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.Custom, root: SelectCardEffect.Root.Custom, customRootCardList: card.Owner.TrashCards, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play."); selectCardEffect.SetUpCustomMessage_ShowCard("Played Card"); yield return StartCoroutine(selectCardEffect.Activate()); } SelectCardEffect.Root root = SelectCardEffect.Root.Hand; if (!fromHand) { 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 End of Your Turn if (timing == EffectTiming.OnEndTurn) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription()); activateClass.SetHashString("DeleteDigimon_BT16_079"); cardEffects.Add(activateClass); string EffectDiscription() { return "[End of Your Turn] [Once Per Turn] If [Cherubimon] or [X-Antibody] is in this Digimon's digivolution cards, delete 1 of your opponent's level 4 or lower Digimon. For each of your other Digimon, add 1 to the maximum level this effect can choose."; } bool CanSelectPermanentCondition(Permanent permanent) { if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)) { int maxCost = 4; maxCost += 1 * card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard()); if (permanent.TopCard.Level <= maxCost) { if (permanent.TopCard.HasLevel) { return true; } } } return false; } bool CanUseCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { return true; } } return false; } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Cherubimon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable _hashtable) { if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)) { 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: null, afterSelectPermanentCoroutine: null, mode: SelectPermanentEffect.Mode.Destroy, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate()); } } } #endregion return cardEffects; } } }