EX5_023.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_023 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.None)
  11. {
  12. bool PermanentCondition(Permanent targetPermanent)
  13. {
  14. return targetPermanent.TopCard.CardNames.Contains("WereGarurumon");
  15. }
  16. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Trash 2 cards from hand to unsuspend this Digimon and return 1 card from trash to hand", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  23. cardEffects.Add(activateClass);
  24. string EffectDiscription()
  25. {
  26. return "[When Digivolving] By trashing 2 cards in your hand, unsuspend this Digimon. Then, if [WereGarurumon] or [X Antibody] is in this Digimon's digivolution cards, you may return 1 Digimon card with [Garurumon]/[X Antibody] in its name from your trash to the hand.";
  27. }
  28. bool CanSelectCardCondition(CardSource cardSource)
  29. {
  30. if (cardSource.IsDigimon)
  31. {
  32. if (cardSource.HasGarurumonName)
  33. {
  34. return true;
  35. }
  36. if (cardSource.HasXAntiBodyName)
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. if (card.Owner.HandCards.Count >= 2)
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  59. {
  60. if (card.Owner.HandCards.Count >= 2)
  61. {
  62. bool discarded = false;
  63. int discardCount = 2;
  64. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  65. selectHandEffect.SetUp(
  66. selectPlayer: card.Owner,
  67. canTargetCondition: cardSource => true,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. maxCount: discardCount,
  71. canNoSelect: true,
  72. canEndNotMax: false,
  73. isShowOpponent: true,
  74. selectCardCoroutine: null,
  75. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  76. mode: SelectHandEffect.Mode.Discard,
  77. cardEffect: activateClass);
  78. yield return StartCoroutine(selectHandEffect.Activate());
  79. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  80. {
  81. if (cardSources.Count == 2)
  82. {
  83. discarded = true;
  84. yield return null;
  85. }
  86. }
  87. if (discarded)
  88. {
  89. Permanent selectedPermanent = card.PermanentOfThisCard();
  90. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  91. new List<Permanent>() { selectedPermanent },
  92. activateClass).Unsuspend());
  93. if (CardEffectCommons.IsExistOnBattleArea(card))
  94. {
  95. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("WereGarurumon") || cardSource.CardNames.Contains("X Antibody") || cardSource.CardNames.Contains("XAntibody")) >= 1)
  96. {
  97. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  98. {
  99. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  100. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  101. selectCardEffect.SetUp(
  102. canTargetCondition: CanSelectCardCondition,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. canNoSelect: () => true,
  106. selectCardCoroutine: null,
  107. afterSelectCardCoroutine: null,
  108. message: "Select 1 card to add to your hand.",
  109. maxCount: maxCount,
  110. canEndNotMax: false,
  111. isShowOpponent: true,
  112. mode: SelectCardEffect.Mode.AddHand,
  113. root: SelectCardEffect.Root.Trash,
  114. customRootCardList: null,
  115. canLookReverseCard: true,
  116. selectPlayer: card.Owner,
  117. cardEffect: activateClass);
  118. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. }
  126. if (timing == EffectTiming.OnAllyAttack)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("Trash 1 card from hand to unsuspend this Digimon", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  131. activateClass.SetHashString("Unsuspend_EX5_023");
  132. activateClass.SetIsInheritedEffect(true);
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[When Attacking] [Once Per Turn] If this Digimon has [Garurumon]/[Omnimon] in its name, by trashing 1 card in your hand, unsuspend this Digimon.";
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.IsExistOnBattleArea(card))
  145. {
  146. if (card.Owner.HandCards.Count >= 1)
  147. {
  148. if (card.PermanentOfThisCard().TopCard.HasGarurumonName)
  149. {
  150. return true;
  151. }
  152. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon"))
  153. {
  154. return true;
  155. }
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. if (card.Owner.HandCards.Count >= 1)
  163. {
  164. bool discarded = false;
  165. int discardCount = 1;
  166. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  167. selectHandEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: cardSource => true,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: discardCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. isShowOpponent: true,
  176. selectCardCoroutine: null,
  177. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  178. mode: SelectHandEffect.Mode.Discard,
  179. cardEffect: activateClass);
  180. yield return StartCoroutine(selectHandEffect.Activate());
  181. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  182. {
  183. if (cardSources.Count == 1)
  184. {
  185. discarded = true;
  186. yield return null;
  187. }
  188. }
  189. if (discarded)
  190. {
  191. Permanent selectedPermanent = card.PermanentOfThisCard();
  192. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  193. new List<Permanent>() { selectedPermanent },
  194. activateClass).Unsuspend());
  195. }
  196. }
  197. }
  198. }
  199. return cardEffects;
  200. }
  201. }