DexDoruGreymon_BT17_067.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class DexDoruGreymon_BT17_067 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("DoruGreymon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false,
  20. card: card, condition: null));
  21. }
  22. #endregion
  23. #region Trash - All Turns
  24. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect(
  28. "Digivolve into [DoruGreymon] into [DexDoruGreymon] from your trash to prevent deletion",
  29. CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  31. activateClass.SetHashString("DigivolveIntoDex_BT17_067");
  32. cardEffects.Add(activateClass);
  33. string EffectDescription()
  34. {
  35. return
  36. "[All Turns] When one of your [DoruGreymon] would be deleted, by digivolving it into this card without paying the cost, prevent that deletion.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnTrash(card) &&
  41. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition);
  42. }
  43. bool IsOwnerPermanentCondition(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  46. permanent.TopCard.EqualsCardName("DoruGreymon") &&
  47. card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash);
  48. }
  49. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  50. {
  51. return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField;
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnTrash(card) &&
  56. CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentCondition);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  61. {
  62. Permanent selectedPermanent = null;
  63. int maxCount = Math.Min(1,
  64. CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
  65. SelectPermanentEffect selectPermanentEffect =
  66. GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: true,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: SelectPermanentCoroutine,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectPermanentEffect.SetUpCustomMessage(
  80. "Select 1 Digimon to digivolve.",
  81. "The opponent is selecting 1 Digimon to digivolve.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. selectedPermanent = permanent;
  86. yield return null;
  87. }
  88. if (selectedPermanent != null)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  91. targetPermanent: selectedPermanent,
  92. cardCondition: null,
  93. payCost: false,
  94. reduceCostTuple: null,
  95. fixedCostTuple: null,
  96. ignoreDigivolutionRequirementFixedCost: -1,
  97. isHand: false,
  98. activateClass: activateClass,
  99. successProcess: null,
  100. ignoreSelection: true));
  101. selectedPermanent.willBeRemoveField = false;
  102. selectedPermanent.HideDeleteEffect();
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region When Digivolving
  109. if (timing == EffectTiming.OnEnterFieldAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Trash 1, Draw 1 and delete opponent's Digimon with play cost of 6 or less", CanUseCondition,
  113. card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  115. cardEffects.Add(activateClass);
  116. string EffectDescription()
  117. {
  118. return
  119. "[When Digivolving] Trash 1 card in your hand. Then, <Draw 1>. If [DoruGreymon] is in this Digimon's digivolution cards or this digivolved from the trash, delete 1 of your opponent's Digimon with a play cost of 6 or less instead.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. bool IsDoruCardCondition(CardSource cardSource)
  126. {
  127. return cardSource.IsDigimon &&
  128. cardSource.EqualsCardName("DoruGreymon");
  129. }
  130. bool TrashRootCondition(SelectCardEffect.Root root)
  131. {
  132. return root == SelectCardEffect.Root.Trash;
  133. }
  134. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  137. permanent.TopCard.HasPlayCost &&
  138. permanent.TopCard.GetCostItself <= 6;
  139. }
  140. bool CanActivateCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card) &&
  143. (card.Owner.HandCards.Count >= 1 ||
  144. card.Owner.LibraryCards.Count >= 1 ||
  145. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition));
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable hashtable)
  148. {
  149. if (card.Owner.HandCards.Count >= 1)
  150. {
  151. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  152. selectHandEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: _ => true,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: 1,
  158. canNoSelect: false,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. selectCardCoroutine: null,
  162. afterSelectCardCoroutine: null,
  163. mode: SelectHandEffect.Mode.Discard,
  164. cardEffect: activateClass);
  165. yield return StartCoroutine(selectHandEffect.Activate());
  166. }
  167. if (card.PermanentOfThisCard().DigivolutionCards.Some(IsDoruCardCondition) || CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card, TrashRootCondition))
  168. {
  169. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  170. {
  171. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectOpponentPermanentCondition));
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: CanSelectOpponentPermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: maxCount,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: null,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Destroy,
  184. cardEffect: activateClass);
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. }
  187. }
  188. else
  189. {
  190. if (card.Owner.LibraryCards.Count >= 1)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(
  193. new DrawClass(card.Owner, 1, activateClass).Draw());
  194. }
  195. }
  196. }
  197. }
  198. #endregion
  199. #region End of Attack - ESS
  200. if (timing == EffectTiming.OnEndAttack)
  201. {
  202. ActivateClass activateClass = new ActivateClass();
  203. activateClass.SetUpICardEffect("Delete own Digimon to delete opponent's Digimon with as high or lower a level",
  204. CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  206. activateClass.SetIsInheritedEffect(true);
  207. activateClass.SetHashString("DeleteDigimon_BT17_067");
  208. cardEffects.Add(activateClass);
  209. string EffectDescription()
  210. {
  211. return
  212. "[End of Attack][Once per turn] You may choose 1 of your Digimon. Delete 1 of your chosen Digimon and 1 of your opponent's Digimon with as high or lower a level as that Digimon.";
  213. }
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  217. }
  218. bool CanSelectOwnPermanentCondition(Permanent permanent)
  219. {
  220. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.IsExistOnBattleArea(card) &&
  225. CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectOwnPermanentCondition);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable hashtable)
  228. {
  229. List<Permanent> chosenPermanents = new List<Permanent>();
  230. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  231. {
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. selectPermanentEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: CanSelectOwnPermanentCondition,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: 1,
  239. canNoSelect: true,
  240. canEndNotMax: false,
  241. selectPermanentCoroutine: SelectPermanentCoroutine,
  242. afterSelectPermanentCoroutine: AfterSelectPermanent,
  243. mode: SelectPermanentEffect.Mode.Custom,
  244. cardEffect: activateClass);
  245. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  246. "The opponent is selecting 1 Digimon to delete.");
  247. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  248. IEnumerator SelectPermanentCoroutine(Permanent chosenPermanent)
  249. {
  250. chosenPermanents.Add(chosenPermanent);
  251. yield return null;
  252. }
  253. IEnumerator AfterSelectPermanent(List<Permanent> chosenPermanent)
  254. {
  255. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  256. {
  257. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  258. permanent.TopCard.HasLevel &&
  259. permanent.Level <= chosenPermanents[0].Level;
  260. }
  261. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  262. {
  263. selectPermanentEffect.SetUp(
  264. selectPlayer: card.Owner,
  265. canTargetCondition: CanSelectOpponentPermanentCondition,
  266. canTargetCondition_ByPreSelecetedList: null,
  267. canEndSelectCondition: null,
  268. maxCount: 1,
  269. canNoSelect: false,
  270. canEndNotMax: false,
  271. selectPermanentCoroutine: SelectPermanentCoroutine,
  272. afterSelectPermanentCoroutine: null,
  273. mode: SelectPermanentEffect.Mode.Custom,
  274. cardEffect: activateClass);
  275. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  276. }
  277. yield return ContinuousController.instance.StartCoroutine(
  278. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  279. targetPermanents: chosenPermanents, activateClass: activateClass,
  280. successProcess: null, failureProcess: null));
  281. }
  282. }
  283. }
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }