BT16_081.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT16
  4. {
  5. public class BT16_081 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region When Digivolving
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect(
  15. "Delete your Digimon or Tamer to delete an opponent's unsuspended Digimon. Otherwise delete 1 of your opponent's tamers.",
  16. CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[When Digivolving] By deleting one of your Digimon or Tamers, delete 1 of your opponent's unsuspended Digimon. If no Digimon is deleted by this effect, delete one of your opponent's tamers.";
  23. }
  24. bool CanSelectPermanentCondition(Permanent permanent)
  25. {
  26. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  27. {
  28. if (permanent.IsDigimon || permanent.IsTamer)
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanSelectOpponentUnsuspendedDigimon(Permanent permanent)
  36. {
  37. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  38. {
  39. if (permanent.IsDigimon && !permanent.IsSuspended)
  40. {
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46. bool CanSelectOpponentTamer(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  49. {
  50. if (permanent.IsTamer)
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable hashtable)
  73. {
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: 1,
  81. canNoSelect: true,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine1,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  88. "The opponent is selecting 1 Digimon to delete.");
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(
  93. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  94. targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass,
  95. successProcess: _ => SuccessProcess(), failureProcess: null));
  96. }
  97. IEnumerator SuccessProcess()
  98. {
  99. List<Permanent> targetPermanents = new List<Permanent>();
  100. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentUnsuspendedDigimon))
  101. {
  102. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectOpponentUnsuspendedDigimon,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: 1,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: SelectPermanentCoroutine2,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  116. "The opponent is selecting 1 Digimon to delete.");
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. IEnumerator SelectPermanentCoroutine2(Permanent permanent)
  119. {
  120. targetPermanents.Add(permanent);
  121. yield return null;
  122. }
  123. }
  124. yield return ContinuousController.instance.StartCoroutine(
  125. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: targetPermanents,
  126. activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  127. IEnumerator FailureProcess()
  128. {
  129. targetPermanents.Clear();
  130. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentTamer))
  131. {
  132. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  133. selectPermanentEffect.SetUp(
  134. selectPlayer: card.Owner,
  135. canTargetCondition: CanSelectOpponentTamer,
  136. canTargetCondition_ByPreSelecetedList: null,
  137. canEndSelectCondition: null,
  138. maxCount: 1,
  139. canNoSelect: false,
  140. canEndNotMax: false,
  141. selectPermanentCoroutine: null,
  142. afterSelectPermanentCoroutine: null,
  143. mode: SelectPermanentEffect.Mode.Destroy,
  144. cardEffect: activateClass);
  145. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to delete.",
  146. "The opponent is selecting 1 Tamer to delete.");
  147. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  148. }
  149. }
  150. }
  151. }
  152. }
  153. #endregion
  154. #region When Attacking
  155. if (timing == EffectTiming.OnAllyAttack)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect(
  159. "Delete your Digimon or Tamer to delete an opponent's unsuspended Digimon. Otherwise delete 1 of your opponent's tamers.",
  160. CanUseCondition, card);
  161. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  162. cardEffects.Add(activateClass);
  163. string EffectDescription()
  164. {
  165. return
  166. "[When Attacking] By deleting one of your Digimon or Tamers, delete 1 of your opponent's unsuspended Digimon. If no Digimon is deleted by this effect, delete one of your opponent's tamers.";
  167. }
  168. bool CanSelectPermanentCondition(Permanent permanent)
  169. {
  170. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  171. {
  172. if (permanent.IsDigimon || permanent.IsTamer)
  173. {
  174. return true;
  175. }
  176. }
  177. return false;
  178. }
  179. bool CanSelectOpponentUnsuspendedDigimon(Permanent permanent)
  180. {
  181. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  182. {
  183. if (permanent.IsDigimon && !permanent.IsSuspended)
  184. {
  185. return true;
  186. }
  187. }
  188. return false;
  189. }
  190. bool CanSelectOpponentTamer(Permanent permanent)
  191. {
  192. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  193. {
  194. if (permanent.IsTamer)
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  208. {
  209. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  210. {
  211. return true;
  212. }
  213. }
  214. return false;
  215. }
  216. IEnumerator ActivateCoroutine(Hashtable hashtable)
  217. {
  218. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  219. selectPermanentEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: CanSelectPermanentCondition,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: 1,
  225. canNoSelect: true,
  226. canEndNotMax: false,
  227. selectPermanentCoroutine: SelectPermanentCoroutine1,
  228. afterSelectPermanentCoroutine: null,
  229. mode: SelectPermanentEffect.Mode.Custom,
  230. cardEffect: activateClass);
  231. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  232. "The opponent is selecting 1 Digimon to delete.");
  233. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  234. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  235. {
  236. yield return ContinuousController.instance.StartCoroutine(
  237. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  238. targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass,
  239. successProcess: _ => SuccessProcess(), failureProcess: null));
  240. }
  241. IEnumerator SuccessProcess()
  242. {
  243. List<Permanent> targetPermanents = new List<Permanent>();
  244. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentUnsuspendedDigimon))
  245. {
  246. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  247. selectPermanentEffect.SetUp(
  248. selectPlayer: card.Owner,
  249. canTargetCondition: CanSelectOpponentUnsuspendedDigimon,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. maxCount: 1,
  253. canNoSelect: false,
  254. canEndNotMax: false,
  255. selectPermanentCoroutine: SelectPermanentCoroutine2,
  256. afterSelectPermanentCoroutine: null,
  257. mode: SelectPermanentEffect.Mode.Custom,
  258. cardEffect: activateClass);
  259. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  260. "The opponent is selecting 1 Digimon to delete.");
  261. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  262. IEnumerator SelectPermanentCoroutine2(Permanent permanent)
  263. {
  264. targetPermanents.Add(permanent);
  265. yield return null;
  266. }
  267. }
  268. yield return ContinuousController.instance.StartCoroutine(
  269. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: targetPermanents,
  270. activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  271. IEnumerator FailureProcess()
  272. {
  273. targetPermanents.Clear();
  274. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentTamer))
  275. {
  276. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  277. selectPermanentEffect.SetUp(
  278. selectPlayer: card.Owner,
  279. canTargetCondition: CanSelectOpponentTamer,
  280. canTargetCondition_ByPreSelecetedList: null,
  281. canEndSelectCondition: null,
  282. maxCount: 1,
  283. canNoSelect: false,
  284. canEndNotMax: false,
  285. selectPermanentCoroutine: null,
  286. afterSelectPermanentCoroutine: null,
  287. mode: SelectPermanentEffect.Mode.Destroy,
  288. cardEffect: activateClass);
  289. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to delete.",
  290. "The opponent is selecting 1 Tamer to delete.");
  291. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  292. }
  293. }
  294. }
  295. }
  296. }
  297. #endregion
  298. #region All Turns
  299. if (timing == EffectTiming.OnDestroyedAnyone)
  300. {
  301. ActivateClass activateClass = new ActivateClass();
  302. activateClass.SetUpICardEffect(
  303. "When one of your Digimon or Tamers are deleted by an effect, trash the top card of your opponent's security.",
  304. CanUseCondition, card);
  305. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  306. activateClass.SetHashString("TrashSecurity_BT16_081");
  307. cardEffects.Add(activateClass);
  308. string EffectDiscription()
  309. {
  310. return
  311. "[All Turns] [Once Per Turn] When one of your Digimon or Tamers is deleted by an effect, trash the top card of your opponent's security stack.";
  312. }
  313. bool PermanentCondition(Permanent permanent)
  314. {
  315. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  316. {
  317. if (permanent.IsDigimon || permanent.IsTamer)
  318. {
  319. return true;
  320. }
  321. }
  322. return false;
  323. }
  324. bool CanUseCondition(Hashtable hashtable)
  325. {
  326. if (CardEffectCommons.IsExistOnBattleArea(card))
  327. {
  328. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  329. {
  330. if (CardEffectCommons.IsByEffect(hashtable, null))
  331. {
  332. return true;
  333. }
  334. }
  335. }
  336. return false;
  337. }
  338. bool CanActivateCondition(Hashtable hashtable)
  339. {
  340. if (CardEffectCommons.IsExistOnBattleArea(card))
  341. {
  342. return true;
  343. }
  344. return false;
  345. }
  346. IEnumerator ActivateCoroutine(Hashtable hashtable)
  347. {
  348. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  349. card.Owner.Enemy,
  350. 1,
  351. activateClass,
  352. true).DestroySecurity());
  353. }
  354. }
  355. #endregion
  356. return cardEffects;
  357. }
  358. }
  359. }