EX8_048.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX8
  4. {
  5. public class EX8_048 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region When Digivolving
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Play 1 [Close] from your hand", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[When Digivolving] If you have 1 or fewer Tamers, you may play 1 [Close] from your hand without paying the cost.";
  20. }
  21. bool HasTamers(Permanent permanent)
  22. {
  23. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  24. permanent.IsTamer;
  25. }
  26. bool HasClose(CardSource source)
  27. {
  28. return source.EqualsCardName("Close") &&
  29. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass);
  30. }
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  34. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  39. CardEffectCommons.MatchConditionOwnersPermanentCount(card, HasTamers) <= 1;
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable hashtable)
  42. {
  43. List<CardSource> selectedCards = new List<CardSource>();
  44. if (CardEffectCommons.HasMatchConditionOwnersHand(card, HasClose))
  45. {
  46. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  47. selectHandEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: HasClose,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: 1,
  53. canNoSelect: false,
  54. canEndNotMax: false,
  55. isShowOpponent: true,
  56. selectCardCoroutine: SelectCardCoroutine,
  57. afterSelectCardCoroutine: null,
  58. mode: SelectHandEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. yield return StartCoroutine(selectHandEffect.Activate());
  61. }
  62. IEnumerator SelectCardCoroutine(CardSource cardSource)
  63. {
  64. selectedCards.Add(cardSource);
  65. yield return null;
  66. }
  67. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  68. }
  69. }
  70. #endregion
  71. #region ESS
  72. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Delete 4 cost or less Digimon", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  77. activateClass.SetIsInheritedEffect(true);
  78. cardEffects.Add(activateClass);
  79. string EffectDiscription()
  80. {
  81. return "When effects trash this card from a [Mineral] or [Rock] trait Digimon's digivolution cards, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  82. }
  83. bool CanSelectOpponentsDigimon(Permanent permanent)
  84. {
  85. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  86. return permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 4;
  87. return false;
  88. }
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  92. return (trashedPermanent.TopCard.ContainsTraits("Mineral") || trashedPermanent.TopCard.ContainsTraits("Rock")) &&
  93. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnTrash(card);
  98. }
  99. IEnumerator ActivateCoroutine(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentsDigimon))
  102. {
  103. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  104. selectPermanentEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: CanSelectOpponentsDigimon,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: 1,
  110. canNoSelect: false,
  111. canEndNotMax: false,
  112. selectPermanentCoroutine: null,
  113. afterSelectPermanentCoroutine: null,
  114. mode: SelectPermanentEffect.Mode.Destroy,
  115. cardEffect: activateClass);
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. }
  118. }
  119. }
  120. #endregion
  121. return cardEffects;
  122. }
  123. }
  124. }