EX9_027.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kokeshimon
  6. namespace DCGO.CardEffects.EX9
  7. {
  8. public class EX9_027 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool Condition(Permanent permanent)
  17. {
  18. return permanent.TopCard.IsLevel3 && permanent.TopCard.EqualsTraits("Puppet");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(Condition, 2, false, card, null));
  21. }
  22. #endregion
  23. #region When Digivolving
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("By trashing 1 card, give 1 digimon -4k", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[When Digivolving] By trashing 1 card in your hand, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  41. card.Owner.HandCards.Count > 0;
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. bool cardDiscarded = false;
  50. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  51. selectHandEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: (cardSource) => true,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: 1,
  57. canNoSelect: true,
  58. canEndNotMax: false,
  59. isShowOpponent: true,
  60. selectCardCoroutine: null,
  61. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  62. mode: SelectHandEffect.Mode.Discard,
  63. cardEffect: activateClass);
  64. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.", "The opponent is selecting 1 card to discard.");
  65. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded card");
  66. yield return StartCoroutine(selectHandEffect.Activate());
  67. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSource)
  68. {
  69. if (cardSource.Any()) cardDiscarded = true;
  70. yield return null;
  71. }
  72. if (cardDiscarded)
  73. {
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  76. Permanent selectedPermanent = null;
  77. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  78. selectPermanentEffect.SetUp(
  79. selectPlayer: card.Owner,
  80. canTargetCondition: CanSelectPermanentCondition,
  81. canTargetCondition_ByPreSelecetedList: null,
  82. canEndSelectCondition: null,
  83. maxCount: 1,
  84. canNoSelect: false,
  85. canEndNotMax: false,
  86. selectPermanentCoroutine: SelectPermanentCoroutine,
  87. afterSelectPermanentCoroutine: null,
  88. mode: SelectPermanentEffect.Mode.Custom,
  89. cardEffect: activateClass);
  90. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to give -4k DP", $"The opponent is selecting 1 card to give -4k DP");
  91. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  92. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  93. {
  94. selectedPermanent = permanent;
  95. yield return null;
  96. }
  97. if (selectedPermanent != null)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  100. targetPermanent: selectedPermanent,
  101. changeValue: -4000,
  102. effectDuration: EffectDuration.UntilEachTurnEnd,
  103. activateClass: activateClass));
  104. }
  105. }
  106. }
  107. }
  108. }
  109. #endregion
  110. #region On Deletion
  111. if (timing == EffectTiming.OnDestroyedAnyone)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("By trashing 1 card, give 1 digimon -4k", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[On Deletion] By trashing 1 card in your hand, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  128. card.Owner.HandCards.Count > 0;
  129. }
  130. bool CanSelectCardCondition(CardSource source)
  131. {
  132. return true;
  133. }
  134. bool CanSelectPermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  137. }
  138. IEnumerator ActivateCoroutine(Hashtable hashtable)
  139. {
  140. bool cardDiscarded = false;
  141. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  142. selectHandEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectCardCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: 1,
  148. canNoSelect: true,
  149. canEndNotMax: false,
  150. isShowOpponent: true,
  151. selectCardCoroutine: null,
  152. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  153. mode: SelectHandEffect.Mode.Discard,
  154. cardEffect: activateClass);
  155. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.", "The opponent is selecting 1 card to discard.");
  156. selectHandEffect.SetUpCustomMessage_ShowCard("Discarded card");
  157. yield return StartCoroutine(selectHandEffect.Activate());
  158. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSource)
  159. {
  160. if (cardSource.Any()) cardDiscarded = true;
  161. yield return null;
  162. }
  163. if (cardDiscarded)
  164. {
  165. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  166. {
  167. Permanent selectedPermanent = null;
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectPermanentCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: 1,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon to give -4k DP", $"The opponent is selecting 1 card to give -4k DP");
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  184. {
  185. selectedPermanent = permanent;
  186. yield return null;
  187. }
  188. if (selectedPermanent != null)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  191. targetPermanent: selectedPermanent,
  192. changeValue: -4000,
  193. effectDuration: EffectDuration.UntilEachTurnEnd,
  194. activateClass: activateClass));
  195. }
  196. }
  197. }
  198. }
  199. }
  200. #endregion
  201. #region ESS
  202. if (timing == EffectTiming.OnAllyAttack)
  203. {
  204. ActivateClass activateClass = new ActivateClass();
  205. activateClass.SetUpICardEffect("End the attack by deleting 1 of your Digimon", CanUseCondition, card);
  206. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  207. activateClass.SetHashString("StopAttack_EX9-027");
  208. activateClass.SetIsInheritedEffect(true);
  209. cardEffects.Add(activateClass);
  210. string EffectDiscription()
  211. {
  212. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, by deleting 1 of your other Digimon, end the attack.";
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. if (CardEffectCommons.IsExistOnBattleArea(card))
  217. {
  218. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => true))
  219. {
  220. if (CardEffectCommons.IsOpponentTurn(card))
  221. {
  222. return true;
  223. }
  224. }
  225. }
  226. return false;
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnBattleArea(card))
  231. {
  232. if (CardEffectCommons.IsOpponentTurn(card))
  233. {
  234. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  235. {
  236. return true;
  237. }
  238. }
  239. }
  240. return false;
  241. }
  242. bool CanSelectPermanentCondition(Permanent permanent)
  243. {
  244. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  245. {
  246. if (permanent != card.PermanentOfThisCard())
  247. {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable hashtable)
  254. {
  255. if (CardEffectCommons.IsExistOnBattleArea(card))
  256. {
  257. int maxCount = 1;
  258. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  259. selectPermanentEffect.SetUp(
  260. selectPlayer: card.Owner,
  261. canTargetCondition: CanSelectPermanentCondition,
  262. canTargetCondition_ByPreSelecetedList: null,
  263. canEndSelectCondition: null,
  264. maxCount: maxCount,
  265. canNoSelect: false,
  266. canEndNotMax: false,
  267. selectPermanentCoroutine: SelectPermanentCoroutine,
  268. afterSelectPermanentCoroutine: null,
  269. mode: SelectPermanentEffect.Mode.Custom,
  270. cardEffect: activateClass);
  271. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  272. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  273. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  274. {
  275. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  276. IEnumerator SuccessProcess()
  277. {
  278. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  279. }
  280. }
  281. }
  282. }
  283. }
  284. #endregion
  285. return cardEffects;
  286. }
  287. }
  288. }