EX5_060.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. public class EX5_060 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. if (timing == EffectTiming.OnEnterFieldAnyone)
  11. {
  12. ActivateClass activateClass = new ActivateClass();
  13. activateClass.SetUpICardEffect("Opponent plays 1 Digimon from trash", CanUseCondition, card);
  14. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  15. cardEffects.Add(activateClass);
  16. string EffectDiscription()
  17. {
  18. return "[On Play] Your opponent plays 1 level 4 or lower Digimon card from their trash suspended without paying the cost. [On Play] effects on Digimon played by this effect don't activate.";
  19. }
  20. bool CanSelectCardCondition(CardSource cardSource)
  21. {
  22. if (cardSource.IsDigimon)
  23. {
  24. if (cardSource.Level <= 4)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.HasLevel)
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  55. {
  56. List<CardSource> selectedCards = new List<CardSource>();
  57. int maxCount = Math.Min(1, card.Owner.Enemy.TrashCards.Count(CanSelectCardCondition));
  58. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  59. selectCardEffect.SetUp(
  60. canTargetCondition: CanSelectCardCondition,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. canNoSelect: () => false,
  64. selectCardCoroutine: SelectCardCoroutine,
  65. afterSelectCardCoroutine: null,
  66. message: "Select 1 card to play.",
  67. maxCount: maxCount,
  68. canEndNotMax: false,
  69. isShowOpponent: true,
  70. mode: SelectCardEffect.Mode.Custom,
  71. root: SelectCardEffect.Root.Trash,
  72. customRootCardList: null,
  73. canLookReverseCard: true,
  74. selectPlayer: card.Owner.Enemy,
  75. cardEffect: activateClass);
  76. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  77. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  78. yield return StartCoroutine(selectCardEffect.Activate());
  79. IEnumerator SelectCardCoroutine(CardSource cardSource)
  80. {
  81. selectedCards.Add(cardSource);
  82. yield return null;
  83. }
  84. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  85. cardSources: selectedCards,
  86. activateClass: activateClass,
  87. payCost: false,
  88. isTapped: true,
  89. root: SelectCardEffect.Root.Trash,
  90. activateETB: false));
  91. }
  92. }
  93. }
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Opponent plays1 Digimon from trash", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  99. cardEffects.Add(activateClass);
  100. string EffectDiscription()
  101. {
  102. return "[When Digivolving] Your opponent plays 1 level 4 or lower Digimon card from their trash suspended without paying the cost. [On Play] effects on Digimon played by this effect don't activate.";
  103. }
  104. bool CanSelectCardCondition(CardSource cardSource)
  105. {
  106. if (cardSource.IsDigimon)
  107. {
  108. if (cardSource.Level <= 4)
  109. {
  110. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  111. {
  112. if (cardSource.HasLevel)
  113. {
  114. return true;
  115. }
  116. }
  117. }
  118. }
  119. return false;
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleArea(card))
  128. {
  129. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  137. {
  138. if (CardEffectCommons.HasMatchConditionOpponentsCardInTrash(card, CanSelectCardCondition))
  139. {
  140. List<CardSource> selectedCards = new List<CardSource>();
  141. int maxCount = Math.Min(1, card.Owner.Enemy.TrashCards.Count(CanSelectCardCondition));
  142. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  143. selectCardEffect.SetUp(
  144. canTargetCondition: CanSelectCardCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. canNoSelect: () => false,
  148. selectCardCoroutine: SelectCardCoroutine,
  149. afterSelectCardCoroutine: null,
  150. message: "Select 1 card to play.",
  151. maxCount: maxCount,
  152. canEndNotMax: false,
  153. isShowOpponent: true,
  154. mode: SelectCardEffect.Mode.Custom,
  155. root: SelectCardEffect.Root.Trash,
  156. customRootCardList: null,
  157. canLookReverseCard: true,
  158. selectPlayer: card.Owner.Enemy,
  159. cardEffect: activateClass);
  160. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  161. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  162. yield return StartCoroutine(selectCardEffect.Activate());
  163. IEnumerator SelectCardCoroutine(CardSource cardSource)
  164. {
  165. selectedCards.Add(cardSource);
  166. yield return null;
  167. }
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  169. cardSources: selectedCards,
  170. activateClass: activateClass,
  171. payCost: false,
  172. isTapped: true,
  173. root: SelectCardEffect.Root.Trash,
  174. activateETB: false));
  175. }
  176. }
  177. }
  178. if (timing == EffectTiming.OnEnterFieldAnyone)
  179. {
  180. ActivateClass activateClass = new ActivateClass();
  181. activateClass.SetUpICardEffect("Play 1 Digimon from trash", CanUseCondition, card);
  182. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  183. activateClass.SetHashString("PlayDigimon_EX5_060");
  184. cardEffects.Add(activateClass);
  185. string EffectDiscription()
  186. {
  187. return "[All Turns] [Once Per Turn] When an effect plays an opponent's Digimon, you may play 1 purple Digimon card with a level less than or equal to it from your trash without paying the cost.";
  188. }
  189. bool PermanentCondition(Permanent permanent)
  190. {
  191. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  192. }
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. if (CardEffectCommons.IsExistOnBattleArea(card))
  196. {
  197. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  198. {
  199. if (CardEffectCommons.IsByEffect(hashtable, null))
  200. {
  201. return true;
  202. }
  203. }
  204. }
  205. return false;
  206. }
  207. bool CanActivateCondition(Hashtable hashtable)
  208. {
  209. if (CardEffectCommons.IsExistOnBattleArea(card))
  210. {
  211. int maxLevel = -1;
  212. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  213. hashtable: hashtable,
  214. rootCondition: null);
  215. if (permanents != null)
  216. {
  217. List<int> levels = permanents
  218. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  219. .Map(permanent => permanent.LevelJustAfterPlayed);
  220. if (levels.Count >= 1)
  221. {
  222. maxLevel = levels.Max();
  223. }
  224. }
  225. bool CanSelectCardCondition(CardSource cardSource)
  226. {
  227. if (cardSource.IsDigimon)
  228. {
  229. if (cardSource.HasCardColor(CardColor.Purple))
  230. {
  231. if (cardSource.Level <= maxLevel)
  232. {
  233. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  234. {
  235. if (cardSource.HasLevel)
  236. {
  237. return true;
  238. }
  239. }
  240. }
  241. }
  242. }
  243. return false;
  244. }
  245. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  246. {
  247. return true;
  248. }
  249. }
  250. return false;
  251. }
  252. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  253. {
  254. int maxLevel = -1;
  255. List<Permanent> permanents = CardEffectCommons.GetPlayedPermanentsFromEnterFieldHashtable(
  256. hashtable: _hashtable,
  257. rootCondition: null);
  258. if (permanents != null)
  259. {
  260. List<int> levels = permanents
  261. .Filter(permanent => permanent != null && permanent.LevelJustAfterPlayed >= 0)
  262. .Map(permanent => permanent.LevelJustAfterPlayed);
  263. if (levels.Count >= 1)
  264. {
  265. maxLevel = levels.Max();
  266. }
  267. }
  268. bool CanSelectCardCondition(CardSource cardSource)
  269. {
  270. if (cardSource.IsDigimon)
  271. {
  272. if (cardSource.HasCardColor(CardColor.Purple))
  273. {
  274. if (cardSource.Level <= maxLevel)
  275. {
  276. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  277. {
  278. if (cardSource.HasLevel)
  279. {
  280. return true;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. return false;
  287. }
  288. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  289. {
  290. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  291. List<CardSource> selectedCards = new List<CardSource>();
  292. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  293. selectCardEffect.SetUp(
  294. canTargetCondition: CanSelectCardCondition,
  295. canTargetCondition_ByPreSelecetedList: null,
  296. canEndSelectCondition: null,
  297. canNoSelect: () => true,
  298. selectCardCoroutine: SelectCardCoroutine,
  299. afterSelectCardCoroutine: null,
  300. message: "Select 1 card to play.",
  301. maxCount: maxCount,
  302. canEndNotMax: false,
  303. isShowOpponent: true,
  304. mode: SelectCardEffect.Mode.Custom,
  305. root: SelectCardEffect.Root.Trash,
  306. customRootCardList: null,
  307. canLookReverseCard: true,
  308. selectPlayer: card.Owner,
  309. cardEffect: activateClass);
  310. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  311. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  312. yield return StartCoroutine(selectCardEffect.Activate());
  313. IEnumerator SelectCardCoroutine(CardSource cardSource)
  314. {
  315. selectedCards.Add(cardSource);
  316. yield return null;
  317. }
  318. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  319. cardSources: selectedCards,
  320. activateClass: activateClass,
  321. payCost: false,
  322. isTapped: false,
  323. root: SelectCardEffect.Root.Trash,
  324. activateETB: true));
  325. }
  326. }
  327. }
  328. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  329. {
  330. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  331. }
  332. return cardEffects;
  333. }
  334. }