BT13_108.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_108 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Main] Until the end of your opponent's turn, 1 of your Digimon gains \"[Opponent's Turn] When this Digimon becomes suspended, delete all of your opponent's Digimon with a play cost less than or equal to this Digimon's\" and \"[Opponent's Turn] This Digimon isn't affected by your opponent's Option cards.\" ";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  25. }
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  29. }
  30. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  31. {
  32. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  33. {
  34. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  35. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  36. selectPermanentEffect.SetUp(
  37. selectPlayer: card.Owner,
  38. canTargetCondition: CanSelectPermanentCondition,
  39. canTargetCondition_ByPreSelecetedList: null,
  40. canEndSelectCondition: null,
  41. maxCount: maxCount,
  42. canNoSelect: false,
  43. canEndNotMax: false,
  44. selectPermanentCoroutine: SelectPermanentCoroutine,
  45. afterSelectPermanentCoroutine: null,
  46. mode: SelectPermanentEffect.Mode.Custom,
  47. cardEffect: activateClass);
  48. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  49. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  50. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  51. {
  52. Permanent selectedPermanent = permanent;
  53. if (selectedPermanent != null)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  56. }
  57. if (selectedPermanent != null)
  58. {
  59. ActivateClass activateClass1 = new ActivateClass();
  60. activateClass1.SetUpICardEffect("Delete opponent's Digimon", CanUseCondition2, selectedPermanent.TopCard);
  61. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  62. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  63. selectedPermanent.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  64. string EffectDiscription1()
  65. {
  66. return "[Opponent's Turn] When this Digimon becomes suspended, delete all of your opponent's Digimon with a play cost less than or equal to this Digimon's";
  67. }
  68. bool CanUseCondition2(Hashtable hashtable1)
  69. {
  70. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  71. {
  72. if (CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable1, (permanent) => permanent == selectedPermanent))
  73. {
  74. if (CardEffectCommons.IsOpponentTurn(selectedPermanent.TopCard))
  75. {
  76. return true;
  77. }
  78. }
  79. }
  80. return false;
  81. }
  82. bool CanActivateCondition1(Hashtable hashtable1)
  83. {
  84. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  85. {
  86. if (selectedPermanent.TopCard.HasPlayCost)
  87. {
  88. int maxCost = selectedPermanent.TopCard.GetCostItself;
  89. bool PermanentCondition(Permanent permanent)
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, selectedPermanent.TopCard))
  92. {
  93. if (permanent.TopCard.GetCostItself <= maxCost)
  94. {
  95. if (permanent.TopCard.HasPlayCost)
  96. {
  97. if (permanent.CanBeDestroyedBySkill(activateClass1))
  98. {
  99. if (!permanent.TopCard.CanNotBeAffected(activateClass1))
  100. {
  101. return true;
  102. }
  103. }
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. if (selectedPermanent.TopCard.Owner.Enemy.GetBattleAreaDigimons().Count(PermanentCondition) >= 1)
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  118. {
  119. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  120. {
  121. if (selectedPermanent.TopCard.HasPlayCost)
  122. {
  123. int maxCost = selectedPermanent.TopCard.GetCostItself;
  124. bool PermanentCondition(Permanent permanent)
  125. {
  126. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, selectedPermanent.TopCard))
  127. {
  128. if (permanent.TopCard.GetCostItself <= maxCost)
  129. {
  130. if (permanent.TopCard.HasPlayCost)
  131. {
  132. if (permanent.CanBeDestroyedBySkill(activateClass1))
  133. {
  134. if (!permanent.TopCard.CanNotBeAffected(activateClass1))
  135. {
  136. return true;
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return false;
  143. }
  144. List<Permanent> destroyTargetPermanents = selectedPermanent.TopCard.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  145. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  146. }
  147. }
  148. }
  149. ICardEffect GetCardEffect(EffectTiming _timing)
  150. {
  151. if (_timing == EffectTiming.OnTappedAnyone)
  152. {
  153. return activateClass1;
  154. }
  155. return null;
  156. }
  157. }
  158. if (selectedPermanent != null)
  159. {
  160. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  161. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's option", CanUseCondition1, card);
  162. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  163. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  164. bool CanUseCondition1(Hashtable hashtable)
  165. {
  166. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  167. }
  168. bool CardCondition(CardSource cardSource)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  171. {
  172. if (cardSource == selectedPermanent.TopCard)
  173. {
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. bool SkillCondition(ICardEffect cardEffect)
  180. {
  181. if (cardEffect != null)
  182. {
  183. if (cardEffect.EffectSourceCard != null)
  184. {
  185. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  186. {
  187. if (cardEffect.EffectSourceCard.IsOption)
  188. {
  189. return true;
  190. }
  191. }
  192. }
  193. }
  194. return false;
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. if (timing == EffectTiming.SecuritySkill)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect($"Delete 1 Digimon", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  206. activateClass.SetIsSecurityEffect(true);
  207. cardEffects.Add(activateClass);
  208. string EffectDiscription()
  209. {
  210. return "[Security] Delete 1 of your opponent's Digimon with the lowest play cost.";
  211. }
  212. bool CanSelectPermanentCondition(Permanent permanent)
  213. {
  214. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  215. {
  216. if (CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true))
  217. {
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  228. {
  229. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  230. {
  231. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. selectPermanentEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: CanSelectPermanentCondition,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: maxCount,
  239. canNoSelect: false,
  240. canEndNotMax: false,
  241. selectPermanentCoroutine: null,
  242. afterSelectPermanentCoroutine: null,
  243. mode: SelectPermanentEffect.Mode.Destroy,
  244. cardEffect: activateClass);
  245. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  246. }
  247. }
  248. }
  249. return cardEffects;
  250. }
  251. }
  252. }