EX9_032.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Karakurumon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_032 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.EqualsTraits("Puppet");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("By deleting a token or [Puppet] digimon, digivolve into a [Puppet] in hand", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] By deleting 1 of your Tokens or other [Puppet] trait Digimon, this Digimon may digivolve into a Digimon card with the [Puppet] trait in the hand without paying the cost.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  41. }
  42. bool CanSelectPermantentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  45. (permanent.IsToken || (permanent.TopCard.EqualsTraits("Puppet") && permanent.TopCard != card));
  46. }
  47. bool CanSelectCardCondition(CardSource cardSource)
  48. {
  49. return cardSource.IsDigimon && cardSource.EqualsTraits("Puppet") &&
  50. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame,false,activateClass);
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermantentCondition))
  55. {
  56. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  57. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  58. selectPermanentEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectPermantentCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: 1,
  64. canNoSelect: false,
  65. canEndNotMax: false,
  66. selectPermanentCoroutine: null,
  67. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  68. mode: SelectPermanentEffect.Mode.Custom,
  69. cardEffect: activateClass);
  70. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  73. {
  74. deleteTargetPermanents = permanents.Clone();
  75. yield return null;
  76. }
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: SuccessProcess, failureProcess: null));
  78. }
  79. IEnumerator SuccessProcess(List<Permanent> permanents)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  82. targetPermanent: card.PermanentOfThisCard(),
  83. cardCondition: CanSelectCardCondition,
  84. payCost: false,
  85. reduceCostTuple: null,
  86. fixedCostTuple: null,
  87. ignoreDigivolutionRequirementFixedCost: -1,
  88. isHand: true,
  89. activateClass: activateClass,
  90. successProcess: null));
  91. }
  92. }
  93. }
  94. #endregion
  95. #region When Digivolving
  96. if (timing == EffectTiming.OnEnterFieldAnyone)
  97. {
  98. ActivateClass activateClass = new ActivateClass();
  99. activateClass.SetUpICardEffect("By Deleting a token or [Puppet] digimon, digivolve into a [puppet] in hand", CanUseCondition, card);
  100. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  101. cardEffects.Add(activateClass);
  102. string EffectDiscription()
  103. {
  104. return "[When Digivolving] By deleting 1 of your Tokens or other [Puppet] trait Digimon, this Digimon may digivolve into a Digimon card with the [Puppet] trait in the hand without paying the cost.";
  105. }
  106. bool CanUseCondition(Hashtable hashtable)
  107. {
  108. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  113. }
  114. bool CanSelectPermantentCondition(Permanent permanent)
  115. {
  116. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  117. (permanent.IsToken || (permanent.TopCard.EqualsTraits("Puppet") && permanent.TopCard != card));
  118. }
  119. bool CanSelectCardCondition(CardSource cardSource)
  120. {
  121. return cardSource.IsDigimon && cardSource.EqualsTraits("Puppet") &&
  122. cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass);
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermantentCondition))
  127. {
  128. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  129. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  130. selectPermanentEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: CanSelectPermantentCondition,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: 1,
  136. canNoSelect: false,
  137. canEndNotMax: false,
  138. selectPermanentCoroutine: null,
  139. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  140. mode: SelectPermanentEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  145. {
  146. deleteTargetPermanents = permanents.Clone();
  147. yield return null;
  148. }
  149. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: SuccessProcess, failureProcess: null));
  150. }
  151. IEnumerator SuccessProcess(List<Permanent> permanents)
  152. {
  153. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  154. targetPermanent: card.PermanentOfThisCard(),
  155. cardCondition: CanSelectCardCondition,
  156. payCost: false,
  157. reduceCostTuple: null,
  158. fixedCostTuple: null,
  159. ignoreDigivolutionRequirementFixedCost: -1,
  160. isHand: true,
  161. activateClass: activateClass,
  162. successProcess: null));
  163. }
  164. }
  165. }
  166. #endregion
  167. #region ESS
  168. if (timing == EffectTiming.WhenRemoveField)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Delete your 1 other token or [Puppet] Digimon to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  173. activateClass.SetIsInheritedEffect(true);
  174. activateClass.SetHashString("Substitute_EX9_032");
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, by deleting 1 of your Tokens or other [Puppet] trait Digimon, prevent it from leaving.";
  179. }
  180. bool CanSelectPermanentCondition(Permanent permanent)
  181. {
  182. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  183. {
  184. if (permanent != card.PermanentOfThisCard())
  185. {
  186. if (permanent.IsToken || permanent.TopCard.EqualsTraits("Puppet"))
  187. {
  188. return true;
  189. }
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanUseCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  199. {
  200. if (!CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. return false;
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.IsExistOnBattleArea(card))
  211. {
  212. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  220. {
  221. if (CardEffectCommons.IsExistOnBattleArea(card))
  222. {
  223. Permanent thisCardPermanent = card.PermanentOfThisCard();
  224. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  225. {
  226. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  227. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  228. selectPermanentEffect.SetUp(
  229. selectPlayer: card.Owner,
  230. canTargetCondition: CanSelectPermanentCondition,
  231. canTargetCondition_ByPreSelecetedList: null,
  232. canEndSelectCondition: null,
  233. maxCount: maxCount,
  234. canNoSelect: true,
  235. canEndNotMax: false,
  236. selectPermanentCoroutine: SelectPermanentCoroutine,
  237. afterSelectPermanentCoroutine: null,
  238. mode: SelectPermanentEffect.Mode.Custom,
  239. cardEffect: activateClass);
  240. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  243. {
  244. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  245. targetPermanents: new List<Permanent>() { permanent },
  246. activateClass: activateClass,
  247. successProcess: permanents => SuccessProcess(),
  248. failureProcess: null));
  249. IEnumerator SuccessProcess()
  250. {
  251. thisCardPermanent.willBeRemoveField = false;
  252. thisCardPermanent.HideDeleteEffect();
  253. thisCardPermanent.HideHandBounceEffect();
  254. thisCardPermanent.HideDeckBounceEffect();
  255. thisCardPermanent.HideWillRemoveFieldEffect();
  256. yield return null;
  257. }
  258. }
  259. }
  260. }
  261. }
  262. }
  263. #endregion
  264. return cardEffects;
  265. }
  266. }
  267. }