using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace DCGO.CardEffects.BT16 { public class BT16_031 : CEntity_Effect { public override List CardEffects(EffectTiming timing, CardSource card) { List cardEffects = new List(); #region Barrier if (timing == EffectTiming.WhenPermanentWouldBeDeleted) { cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null)); } #endregion #region Digivolution Condition if (timing == EffectTiming.None) { static bool PermanentCondition(Permanent targetPermanent) { if (targetPermanent.TopCard.CardNames.Contains("Salamon")) { return true; } return false; } cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null)); } #endregion #region On Play if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1 card to return 1 card back to you hand.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetHashString("OnPlay_BT16_031"); cardEffects.Add(activateClass); string EffectDiscription() { return "[On Play] By trashing 1 card in your hand, return 1 level 6 of lower 2-color Digimon card with red or purple from your trash to your hand."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerOnPlay(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.HandCards.Count >= 1) { return true; } } return false; } bool CanSelectCardToTrash(CardSource card) { if (card.Owner.HandCards.Count >= 1) { return true; } return false; } bool CanSelectCardToReturnToHand(CardSource cardSource) { if (cardSource.CardColors.Count == 2 && (cardSource.HasCardColor(CardColor.Red) || cardSource.HasCardColor(CardColor.Purple))) { if (cardSource.HasLevel && cardSource.Level <= 6) { return true; } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (card.Owner.HandCards.Count(CanSelectCardToTrash) >= 1) { bool discarded = false; int discardCount = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardToTrash, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: discardCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectCardCoroutine, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator AfterSelectCardCoroutine(List cardSources) { if (cardSources.Count >= 1) { discarded = true; yield return null; } } if (discarded) { int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardToReturnToHand)); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardToReturnToHand, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: null, afterSelectCardCoroutine: null, message: "Select 1 card to add to your hand.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.AddHand, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); } } } } #endregion #region When Digivolving if (timing == EffectTiming.OnEnterFieldAnyone) { ActivateClass activateClass = new ActivateClass(); activateClass.SetUpICardEffect("Trash 1 card to return 1 card back to you hand.", CanUseCondition, card); activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription()); activateClass.SetHashString("Digivolving_BT16_031"); cardEffects.Add(activateClass); string EffectDiscription() { return "[When Digivolving] By trashing 1 card in your hand, return 1 level 6 of lower 2-color Digimon card with red or purple from your trash to your hand."; } bool CanUseCondition(Hashtable hashtable) { return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card); } bool CanActivateCondition(Hashtable hashtable) { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (card.Owner.HandCards.Count >= 1) { return true; } } return false; } bool CanSelectCardToTrash(CardSource card) { if (card.Owner.HandCards.Count >= 1) { return true; } return false; } bool CanSelectCardToReturnToHand(CardSource cardSource) { if (cardSource.CardColors.Count == 2 && (cardSource.HasCardColor(CardColor.Red) || cardSource.HasCardColor(CardColor.Purple))) { if (cardSource.HasLevel && cardSource.Level <= 6) { if (cardSource.IsDigimon) { return true; } } } return false; } IEnumerator ActivateCoroutine(Hashtable hashtable) { if (card.Owner.HandCards.Count(CanSelectCardToTrash) >= 1) { bool discarded = false; int discardCount = 1; SelectHandEffect selectHandEffect = GManager.instance.GetComponent(); selectHandEffect.SetUp( selectPlayer: card.Owner, canTargetCondition: CanSelectCardToTrash, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, maxCount: discardCount, canNoSelect: true, canEndNotMax: false, isShowOpponent: true, selectCardCoroutine: null, afterSelectCardCoroutine: AfterSelectCardCoroutine, mode: SelectHandEffect.Mode.Discard, cardEffect: activateClass); yield return StartCoroutine(selectHandEffect.Activate()); IEnumerator AfterSelectCardCoroutine(List cardSources) { if (cardSources.Count >= 1) { discarded = true; yield return null; } } if (discarded) { int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardToReturnToHand)); SelectCardEffect selectCardEffect = GManager.instance.GetComponent(); selectCardEffect.SetUp( canTargetCondition: CanSelectCardToReturnToHand, canTargetCondition_ByPreSelecetedList: null, canEndSelectCondition: null, canNoSelect: () => false, selectCardCoroutine: null, afterSelectCardCoroutine: null, message: "Select 1 card to add to your hand.", maxCount: maxCount, canEndNotMax: false, isShowOpponent: true, mode: SelectCardEffect.Mode.AddHand, root: SelectCardEffect.Root.Trash, customRootCardList: null, canLookReverseCard: true, selectPlayer: card.Owner, cardEffect: activateClass); yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate()); } } } } #endregion #region Inherit if (timing == EffectTiming.None) { bool CardCondition(CardSource cardSource) { return cardSource.Owner == card.Owner.Enemy; } bool Condition() { if (CardEffectCommons.IsExistOnBattleArea(card)) { if (CardEffectCommons.IsOwnerTurn(card)) { return true; } } return false; } cardEffects.Add(CardEffectFactory.ChangeSecurityDigimonCardDPStaticEffect( cardCondition: CardCondition, changeValue: -3000, isInheritedEffect: true, card: card, condition: Condition, effectName: "Opponent's Security Digimon gains DP -3000")); } #endregion return cardEffects; } } }