EX9_024.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Hanimon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_024 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Cost
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. if (targetPermanent.TopCard.IsLevel2)
  19. {
  20. if (targetPermanent.TopCard.EqualsCardName("Kyaromon"))
  21. {
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition,
  29. digivolutionCost: 0,
  30. ignoreDigivolutionRequirement: false,
  31. card: card,
  32. condition: null)
  33. );
  34. }
  35. #endregion
  36. #region On Play
  37. if (timing == EffectTiming.OnEnterFieldAnyone)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("Trash 1, return 1 [Puppet] digimon from trash to hand", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[On Play] By trashing 1 card in your hand, you may return 1 Digimon card with the [Puppet] trait from your trash to the hand.";
  46. }
  47. bool CanUseCondition(Hashtable hashtable) => CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  51. {
  52. if (card.Owner.HandCards.Count >= 1)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanSelectCardCondition(CardSource cardSource)
  60. {
  61. if (cardSource.IsDigimon)
  62. {
  63. if (cardSource.EqualsTraits("Puppet"))
  64. {
  65. return true;
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. bool cardDiscarded = false;
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: (cardSource) => true,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: null,
  84. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  85. mode: SelectHandEffect.Mode.Discard,
  86. cardEffect: activateClass);
  87. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.", "The opponent is selecting 1 card to discard.");
  88. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded card");
  89. yield return StartCoroutine(selectHandEffect.Activate());
  90. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSource)
  91. {
  92. if (cardSource.Any()) cardDiscarded = true;
  93. yield return null;
  94. }
  95. if (cardDiscarded)
  96. {
  97. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  98. selectCardEffect.SetUp(
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. canNoSelect: () => true,
  103. selectCardCoroutine: null,
  104. afterSelectCardCoroutine: null,
  105. message: "Select 1 card to return to hand",
  106. maxCount: 1,
  107. canEndNotMax: true,
  108. isShowOpponent: true,
  109. mode: SelectCardEffect.Mode.AddHand,
  110. root: SelectCardEffect.Root.Trash,
  111. customRootCardList: null,
  112. canLookReverseCard: true,
  113. selectPlayer: card.Owner,
  114. cardEffect: activateClass);
  115. selectCardEffect.SetUpCustomMessage("Select 1 card to return to hand.", "The opponent is selecting 1 card to return to hand.");
  116. selectCardEffect.SetUpCustomMessage_ShowCard("Returned Card");
  117. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  118. }
  119. }
  120. }
  121. #endregion
  122. #region Inherit
  123. if (timing == EffectTiming.OnAllyAttack)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("End the attack by deleting 1 of your Digimon", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  128. activateClass.SetHashString("StopAttack_EX9-024");
  129. activateClass.SetIsInheritedEffect(true);
  130. cardEffects.Add(activateClass);
  131. string EffectDiscription()
  132. {
  133. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, by deleting 1 of your other Digimon, end the attack.";
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => true))
  140. {
  141. if (CardEffectCommons.IsOpponentTurn(card))
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. return false;
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleArea(card))
  152. {
  153. if (CardEffectCommons.IsOpponentTurn(card))
  154. {
  155. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  156. {
  157. return true;
  158. }
  159. }
  160. }
  161. return false;
  162. }
  163. bool CanSelectPermanentCondition(Permanent permanent)
  164. {
  165. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  166. {
  167. if (permanent != card.PermanentOfThisCard())
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. IEnumerator ActivateCoroutine(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleArea(card))
  177. {
  178. int maxCount = 1;
  179. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  180. selectPermanentEffect.SetUp(
  181. selectPlayer: card.Owner,
  182. canTargetCondition: CanSelectPermanentCondition,
  183. canTargetCondition_ByPreSelecetedList: null,
  184. canEndSelectCondition: null,
  185. maxCount: maxCount,
  186. canNoSelect: false,
  187. canEndNotMax: false,
  188. selectPermanentCoroutine: SelectPermanentCoroutine,
  189. afterSelectPermanentCoroutine: null,
  190. mode: SelectPermanentEffect.Mode.Custom,
  191. cardEffect: activateClass);
  192. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  193. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  194. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  195. {
  196. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  197. IEnumerator SuccessProcess()
  198. {
  199. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  200. }
  201. }
  202. }
  203. }
  204. }
  205. #endregion
  206. return cardEffects;
  207. }
  208. }
  209. }