BT20_073.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_073 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Evolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardNames.Contains("Phantomon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 1,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null));
  24. }
  25. #endregion
  26. #region Blocker
  27. if (timing == EffectTiming.None)
  28. {
  29. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region On Play/ When Digivolving Shared
  33. bool CanSelectOwnerPermanentConditionShared(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  36. }
  37. bool CanSelectLevelOpponentPermanentConditionShared(Permanent permanent)
  38. {
  39. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  40. permanent.IsDigimon &&
  41. permanent.TopCard.HasLevel &&
  42. permanent.Level <= 5;
  43. }
  44. bool CanActivateConditionShared(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  47. CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermanentConditionShared);
  48. }
  49. #endregion
  50. #region On Play
  51. if (timing == EffectTiming.OnEnterFieldAnyone)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Delete 1 of your Digimon to delete your opponent's Digimon", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  56. cardEffects.Add(activateClass);
  57. string EffectDescription()
  58. {
  59. return "[On Play] By deleting 1 of your Digimon, delete 1 of your opponent's level 5 or lower Digimon.";
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. Permanent selectedPermanent = null;
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectOwnerPermanentConditionShared,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: 1,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectPermanentCoroutine,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon to delete.",
  82. "The opponent is selecting 1 of their Digimon to delete.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  85. {
  86. selectedPermanent = permanent;
  87. yield return null;
  88. }
  89. if (selectedPermanent != null)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(
  92. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  93. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  94. successProcess: _ => SuccessProcess(), failureProcess: null));
  95. }
  96. IEnumerator SuccessProcess()
  97. {
  98. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  99. CanSelectLevelOpponentPermanentConditionShared(permanent)))
  100. {
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent),
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: 1,
  107. canNoSelect: false,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: null,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Destroy,
  112. cardEffect: activateClass);
  113. selectPermanentEffect.SetUpCustomMessage("Select 1 of your opponents lvl 5 or lower Digimon to delete.",
  114. "The opponent is selecting 1 of your Digimon to delete.");
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. }
  117. }
  118. }
  119. }
  120. #endregion
  121. #region When Digivolving
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("Delete 1 of your Digimon to delete your opponent's Digimon", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  127. cardEffects.Add(activateClass);
  128. string EffectDescription()
  129. {
  130. return "[When Digivolving] By deleting 1 of your Digimon, delete 1 of your opponent's level 5 or lower Digimon.";
  131. }
  132. bool CanUseCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable hashtable)
  137. {
  138. Permanent selectedPermanent = null;
  139. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  140. selectPermanentEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: CanSelectOwnerPermanentConditionShared,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: 1,
  146. canNoSelect: true,
  147. canEndNotMax: false,
  148. selectPermanentCoroutine: SelectPermanentCoroutine,
  149. afterSelectPermanentCoroutine: null,
  150. mode: SelectPermanentEffect.Mode.Custom,
  151. cardEffect: activateClass);
  152. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon to delete.",
  153. "The opponent is selecting 1 of their Digimon to delete.");
  154. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  155. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  156. {
  157. selectedPermanent = permanent;
  158. yield return null;
  159. }
  160. if (selectedPermanent != null)
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(
  163. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  164. targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass,
  165. successProcess: _ => SuccessProcess(), failureProcess: null));
  166. }
  167. IEnumerator SuccessProcess()
  168. {
  169. if (CardEffectCommons.HasMatchConditionPermanent(permanent =>
  170. CanSelectLevelOpponentPermanentConditionShared(permanent)))
  171. {
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: permanent => CanSelectLevelOpponentPermanentConditionShared(permanent),
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: 1,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: null,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Destroy,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 of your opponents lvl 5 or lower Digimon to delete.",
  185. "The opponent is selecting 1 of your Digimon to delete.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. }
  188. }
  189. }
  190. }
  191. #endregion
  192. #region On Deletion - ESS
  193. if (timing == EffectTiming.OnDestroyedAnyone)
  194. {
  195. ActivateClass activateClass = new ActivateClass();
  196. activateClass.SetUpICardEffect("De-Digivolve 1 on 1 Digimon", CanUseCondition, card);
  197. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  198. activateClass.SetIsInheritedEffect(true);
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return
  203. "[On Deletion] [De-Digivolve] 1 of your opponent's Digimon (Trash up to 1 card from the top of one of your opponent's Digimon. If it has no digivolution cards, or becomes a level 3 Digimon, you can't trash any more cards).";
  204. }
  205. bool CanSelectPermanentCondition(Permanent permanent)
  206. {
  207. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  208. }
  209. bool CanUseCondition(Hashtable hashtable)
  210. {
  211. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  212. }
  213. bool CanActivateCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  216. {
  217. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  225. {
  226. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  227. {
  228. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  229. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  230. selectPermanentEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: CanSelectPermanentCondition,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: maxCount,
  236. canNoSelect: false,
  237. canEndNotMax: false,
  238. selectPermanentCoroutine: SelectPermanentCoroutine,
  239. afterSelectPermanentCoroutine: null,
  240. mode: SelectPermanentEffect.Mode.Custom,
  241. cardEffect: activateClass);
  242. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.",
  243. "The opponent is selecting 1 Digimon to De-Digivolve.");
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  246. {
  247. Permanent selectedPermanent = permanent;
  248. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass)
  249. .Degeneration());
  250. }
  251. }
  252. }
  253. }
  254. #endregion
  255. return cardEffects;
  256. }
  257. }
  258. }