BT16_078.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_078 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Delete 1 level 4 or lower Digimon.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[On Play] Delete 1 level 4 or lower Digimon.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  25. {
  26. if (permanent.Level <= 4)
  27. {
  28. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  29. {
  30. if (permanent.CanBeDestroyedBySkill(activateClass))
  31. {
  32. return true;
  33. }
  34. }
  35. }
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectPermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: true,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  73. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  74. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  75. {
  76. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  77. IEnumerator SuccessProcess()
  78. {
  79. yield return null;
  80. }
  81. }
  82. }
  83. }
  84. }
  85. #endregion
  86. #region When Digivolving
  87. if (timing == EffectTiming.OnEnterFieldAnyone)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Delete 1 level 4 or lower Digimon.", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  92. cardEffects.Add(activateClass);
  93. string EffectDiscription()
  94. {
  95. return "[When Digivolving] Delete 1 level 4 or lower Digimon.";
  96. }
  97. bool CanSelectPermanentCondition(Permanent permanent)
  98. {
  99. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  100. {
  101. if (permanent.Level <= 4)
  102. {
  103. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  104. {
  105. if (permanent.CanBeDestroyedBySkill(activateClass))
  106. {
  107. return true;
  108. }
  109. }
  110. }
  111. }
  112. return false;
  113. }
  114. bool CanUseCondition(Hashtable hashtable)
  115. {
  116. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. if (CardEffectCommons.IsExistOnBattleArea(card))
  121. {
  122. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  123. {
  124. return true;
  125. }
  126. }
  127. return false;
  128. }
  129. IEnumerator ActivateCoroutine(Hashtable hashtable)
  130. {
  131. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  132. {
  133. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  134. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  135. selectPermanentEffect.SetUp(
  136. selectPlayer: card.Owner,
  137. canTargetCondition: CanSelectPermanentCondition,
  138. canTargetCondition_ByPreSelecetedList: null,
  139. canEndSelectCondition: null,
  140. maxCount: maxCount,
  141. canNoSelect: true,
  142. canEndNotMax: false,
  143. selectPermanentCoroutine: SelectPermanentCoroutine,
  144. afterSelectPermanentCoroutine: null,
  145. mode: SelectPermanentEffect.Mode.Custom,
  146. cardEffect: activateClass);
  147. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  150. {
  151. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  152. IEnumerator SuccessProcess()
  153. {
  154. yield return null;
  155. }
  156. }
  157. }
  158. }
  159. }
  160. #endregion
  161. #region Your Turn - Once Per Turn
  162. if (timing == EffectTiming.OnDestroyedAnyone)
  163. {
  164. ActivateClass activateClass = new ActivateClass();
  165. activateClass.SetUpICardEffect("Play a level 5 or lower Digimon with the [Undead] or [Dark Animal] trait.", CanUseCondition, card);
  166. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  167. activateClass.SetHashString("PlayLevel5_BT16_078");
  168. cardEffects.Add(activateClass);
  169. string EffectDiscription()
  170. {
  171. return "[Your Turn] When an effect deletes another Digimon, you may play 1 level 5 or lower Digimon card with the [Undead] or [Dark Animal] trait from your trash without paying the cost.";
  172. }
  173. bool PermanentCondition(Permanent permanent)
  174. {
  175. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  176. {
  177. if (permanent != card.PermanentOfThisCard())
  178. {
  179. if (permanent.IsDigimon)
  180. {
  181. return true;
  182. }
  183. }
  184. }
  185. return false;
  186. }
  187. bool CanSelectCardCondition(CardSource cardSource)
  188. {
  189. if (CardEffectCommons.IsExistOnTrash(cardSource))
  190. {
  191. if (cardSource.Level <= 5 && cardSource.CardTraits.Contains("Undead") && cardSource.IsDigimon)
  192. {
  193. return true;
  194. }
  195. if (cardSource.Level <= 5 && (cardSource.CardTraits.Contains("DarkAnimal") || cardSource.CardTraits.Contains("Dark Animal")) && cardSource.IsDigimon)
  196. {
  197. return true;
  198. }
  199. }
  200. return false;
  201. }
  202. bool CanUseCondition(Hashtable hashtable)
  203. {
  204. if (CardEffectCommons.IsExistOnBattleArea(card))
  205. {
  206. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  207. {
  208. if (CardEffectCommons.IsByEffect(hashtable, null))
  209. {
  210. return true;
  211. }
  212. }
  213. }
  214. return false;
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.IsExistOnBattleArea(card))
  219. {
  220. if (CardEffectCommons.IsOwnerTurn(card))
  221. {
  222. return true;
  223. }
  224. }
  225. return false;
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  228. {
  229. List<CardSource> selectedCards = new List<CardSource>();
  230. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  231. {
  232. int maxCount1 = 1;
  233. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  234. selectCardEffect.SetUp(
  235. canTargetCondition: CanSelectCardCondition,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. canNoSelect: () => true,
  239. selectCardCoroutine: SelectCardCoroutine,
  240. afterSelectCardCoroutine: null,
  241. message: "Select 1 card to play.",
  242. maxCount: maxCount1,
  243. canEndNotMax: false,
  244. isShowOpponent: true,
  245. mode: SelectCardEffect.Mode.Custom,
  246. root: SelectCardEffect.Root.Custom,
  247. customRootCardList: card.Owner.TrashCards,
  248. canLookReverseCard: true,
  249. selectPlayer: card.Owner,
  250. cardEffect: activateClass);
  251. selectCardEffect.SetUpCustomMessage("Select 1 trash card to play.", "The opponent is selecting 1 trash card to play.");
  252. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  253. IEnumerator SelectCardCoroutine(CardSource cardSource)
  254. {
  255. selectedCards.Add(cardSource);
  256. yield return null;
  257. }
  258. yield return StartCoroutine(selectCardEffect.Activate());
  259. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  260. cardSources: selectedCards,
  261. activateClass: activateClass,
  262. payCost: false,
  263. isTapped: false,
  264. root: SelectCardEffect.Root.Trash,
  265. activateETB: true));
  266. }
  267. }
  268. }
  269. #endregion
  270. return cardEffects;
  271. }
  272. }
  273. }