EX6_048.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.EX6
  9. {
  10. public class EX6_048 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region On Play
  16. if (timing == EffectTiming.OnEnterFieldAnyone)
  17. {
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Trash 1 card in your hand to give effects.", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[On Play] By trashing 1 card in your hand, until the end of your opponent's turn, 1 of your opponent's Digimon gains [End of Attack] Delete this Digimon.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  33. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  34. return false;
  35. }
  36. bool CanActivateCondition(Hashtable hashtable)
  37. {
  38. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  39. {
  40. if (card.Owner.HandCards.Count >= 1)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. IEnumerator ActivateCoroutine(Hashtable hashtable)
  48. {
  49. bool discarded = false;
  50. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  51. selectHandEffect.SetUp(
  52. selectPlayer: card.Owner,
  53. canTargetCondition: (cardSource) => true,
  54. canTargetCondition_ByPreSelecetedList: null,
  55. canEndSelectCondition: null,
  56. maxCount: 1,
  57. canNoSelect: true,
  58. canEndNotMax: false,
  59. isShowOpponent: true,
  60. selectCardCoroutine: null,
  61. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  62. mode: SelectHandEffect.Mode.Discard,
  63. cardEffect: activateClass);
  64. yield return StartCoroutine(selectHandEffect.Activate());
  65. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  66. {
  67. if (cardSources.Count >= 1)
  68. {
  69. discarded = true;
  70. yield return null;
  71. }
  72. }
  73. if (discarded)
  74. {
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  76. {
  77. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: maxCount,
  85. canNoSelect: false,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectPermanentEffect.SetUpCustomMessage(
  92. "Select 1 Digimon that will get [End of Attack] Delete this Digimon.",
  93. "The opponent is selecting 1 Digimon that will get [End of Attack] Delete this Digimon.");
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  96. {
  97. if (permanent != null)
  98. {
  99. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  100. ActivateClass activateClass1 = new ActivateClass();
  101. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, permanent.TopCard);
  102. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  103. activateClass1.SetEffectSourcePermanent(permanent);
  104. permanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  105. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  108. }
  109. string EffectDiscription1()
  110. {
  111. return "[End of Attack] Delete this Digimon.";
  112. }
  113. bool CanUseCondition1(Hashtable hashtable1)
  114. {
  115. if (CardEffectCommons.IsOpponentTurn(card))
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, permanent.TopCard))
  118. {
  119. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable1, permanent.TopCard))
  120. {
  121. return true;
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanActivateCondition1(Hashtable hashtable1)
  128. {
  129. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  130. {
  131. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  132. {
  133. return true;
  134. }
  135. }
  136. return false;
  137. }
  138. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  139. {
  140. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  141. {
  142. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  143. new List<Permanent>() { permanent },
  144. CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  145. }
  146. }
  147. ICardEffect GetCardEffect(EffectTiming _timing)
  148. {
  149. if (_timing == EffectTiming.OnEndAttack)
  150. {
  151. return activateClass1;
  152. }
  153. return null;
  154. }
  155. }
  156. }
  157. }
  158. }
  159. }
  160. }
  161. #endregion
  162. #region When Digivolving
  163. if (timing == EffectTiming.OnEnterFieldAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Trash 1 card in your hand to give effects.", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  168. cardEffects.Add(activateClass);
  169. string EffectDiscription()
  170. {
  171. return "[When Digivolving] By trashing 1 card in your hand, until the end of your opponent's turn, 1 of your opponent's Digimon gains [End of Attack] Delete this Digimon.";
  172. }
  173. bool CanSelectPermanentCondition(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  180. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  181. return false;
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.IsExistOnBattleArea(card))
  186. {
  187. if (card.Owner.HandCards.Count >= 1)
  188. {
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. bool discarded = false;
  197. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  198. selectHandEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: (cardSource) => true,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: 1,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. isShowOpponent: true,
  207. selectCardCoroutine: null,
  208. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  209. mode: SelectHandEffect.Mode.Discard,
  210. cardEffect: activateClass);
  211. yield return StartCoroutine(selectHandEffect.Activate());
  212. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  213. {
  214. if (cardSources.Count >= 1)
  215. {
  216. discarded = true;
  217. yield return null;
  218. }
  219. }
  220. if (discarded)
  221. {
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  223. {
  224. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: SelectPermanentCoroutine,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Custom,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage(
  239. "Select 1 Digimon that will get [End of Attack] Delete this Digimon.",
  240. "The opponent is selecting 1 Digimon that will get [End of Attack] Delete this Digimon.");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  243. {
  244. if (permanent != null)
  245. {
  246. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  247. ActivateClass activateClass1 = new ActivateClass();
  248. activateClass1.SetUpICardEffect("Delete this Digimon", CanUseCondition1, permanent.TopCard);
  249. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  250. activateClass1.SetEffectSourcePermanent(permanent);
  251. permanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  252. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  253. {
  254. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(permanent));
  255. }
  256. string EffectDiscription1()
  257. {
  258. return "[End of Attack] Delete this Digimon.";
  259. }
  260. bool CanUseCondition1(Hashtable hashtable1)
  261. {
  262. if (CardEffectCommons.IsOpponentTurn(card))
  263. {
  264. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, permanent.TopCard))
  265. {
  266. if (CardEffectCommons.CanTriggerOnEndAttack(hashtable1, permanent.TopCard))
  267. {
  268. return true;
  269. }
  270. }
  271. }
  272. return false;
  273. }
  274. bool CanActivateCondition1(Hashtable hashtable1)
  275. {
  276. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  277. {
  278. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  279. {
  280. return true;
  281. }
  282. }
  283. return false;
  284. }
  285. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  286. {
  287. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  288. {
  289. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  290. new List<Permanent>() { permanent },
  291. CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  292. }
  293. }
  294. ICardEffect GetCardEffect(EffectTiming _timing)
  295. {
  296. if (_timing == EffectTiming.OnEndAttack)
  297. {
  298. return activateClass1;
  299. }
  300. return null;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. }
  307. }
  308. #endregion
  309. #region Inherit
  310. if (timing == EffectTiming.OnAllyAttack)
  311. {
  312. ActivateClass activateClass = new ActivateClass();
  313. activateClass.SetUpICardEffect("End the attack by deleting 1 of your Digimon", CanUseCondition, card);
  314. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  315. activateClass.SetHashString("StopAttack_EX6-048");
  316. activateClass.SetIsInheritedEffect(true);
  317. cardEffects.Add(activateClass);
  318. string EffectDiscription()
  319. {
  320. return "[Opponent's Turn][Once Per Turn] When an opponent's Digimon attacks, by deleting 1 of your other Digimon, end the attack.";
  321. }
  322. bool CanUseCondition(Hashtable hashtable)
  323. {
  324. if (CardEffectCommons.IsExistOnBattleArea(card))
  325. {
  326. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => true))
  327. {
  328. if (CardEffectCommons.IsOpponentTurn(card))
  329. {
  330. return true;
  331. }
  332. }
  333. }
  334. return false;
  335. }
  336. bool CanActivateCondition(Hashtable hashtable)
  337. {
  338. if (CardEffectCommons.IsExistOnBattleArea(card))
  339. {
  340. if (CardEffectCommons.IsOpponentTurn(card))
  341. {
  342. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  343. {
  344. return true;
  345. }
  346. }
  347. }
  348. return false;
  349. }
  350. bool CanSelectPermanentCondition(Permanent permanent)
  351. {
  352. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  353. {
  354. if (permanent != card.PermanentOfThisCard())
  355. {
  356. return true;
  357. }
  358. }
  359. return false;
  360. }
  361. IEnumerator ActivateCoroutine(Hashtable hashtable)
  362. {
  363. if (CardEffectCommons.IsExistOnBattleArea(card))
  364. {
  365. int maxCount = 1;
  366. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  367. selectPermanentEffect.SetUp(
  368. selectPlayer: card.Owner,
  369. canTargetCondition: CanSelectPermanentCondition,
  370. canTargetCondition_ByPreSelecetedList: null,
  371. canEndSelectCondition: null,
  372. maxCount: maxCount,
  373. canNoSelect: false,
  374. canEndNotMax: false,
  375. selectPermanentCoroutine: SelectPermanentCoroutine,
  376. afterSelectPermanentCoroutine: null,
  377. mode: SelectPermanentEffect.Mode.Custom,
  378. cardEffect: activateClass);
  379. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  380. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  381. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  382. {
  383. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  384. IEnumerator SuccessProcess()
  385. {
  386. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.EndAttack());
  387. }
  388. }
  389. }
  390. }
  391. }
  392. #endregion
  393. return cardEffects;
  394. }
  395. }
  396. }