EX8_059.cs 22 KB

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