EX12_003.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Kapurimon
  5. namespace DCGO.CardEffects.EX12
  6. {
  7. public class EX12_003 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Inherit
  13. if (timing == EffectTiming.WhenRemoveField)
  14. {
  15. List<Permanent> allowedPermanents = null;
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("May DNA 1 of the leaving Digimon and another Digimon into an [ME] in hand", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  19. activateClass.SetIsInheritedEffect(true);
  20. activateClass.SetIsSkippable(true);
  21. cardEffects.Add(activateClass);
  22. string EffectDescription()
  23. {
  24. return "[All Turns] When any of your [ME] trait Digimon would leave the battle area other than by your effects, 1 of them and any of your other Digimon may DNA digivolve into an [ME] trait Digimon card in the hand.";
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  29. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
  30. && !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  31. }
  32. bool CanActivateCondition(Hashtable hashtable)
  33. {
  34. allowedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(PermanentCondition);
  35. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
  36. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectDNACondition)
  37. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard());
  38. }
  39. bool PermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  42. && permanent.TopCard.EqualsTraits("ME");
  43. }
  44. bool CanSelectDNACondition(CardSource cardSource)
  45. {
  46. foreach (Permanent permanent in allowedPermanents)
  47. {
  48. return cardSource.EqualsTraits("ME")
  49. && cardSource.CanJogressFromTargetPermanent(permanent, true);
  50. }
  51. return false;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable hashtable)
  54. {
  55. List<Permanent> allowedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(PermanentCondition);
  56. Func<Permanent, bool>[] permanentConditions = new Func<Permanent, bool>[] { allowedPermanents.Contains };//one of the 2 must be a to be removed digimon
  57. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  58. canSelectDNACardCondition: CanSelectDNACondition,
  59. payCost: true,
  60. isHand: true,
  61. activateClass,
  62. permanentConditions
  63. ));
  64. }
  65. }
  66. #endregion
  67. return cardEffects;
  68. }
  69. }
  70. }