EX2_044.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. namespace DCGO.CardEffects.EX2
  8. {
  9. public class EX2_044 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. if (timing == EffectTiming.OnDiscardLibrary)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play 1 [Impmon] from trash", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "When this card is trashed from your deck, you may play 1 [Impmon] from your trash without paying its memory cost.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.CardNames.Contains("Impmon"))
  29. {
  30. return true;
  31. }
  32. }
  33. return false;
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerWhenSelfDiscardLibrary(hashtable, card);
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. if (CardEffectCommons.IsExistOnTrash(card))
  42. {
  43. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  51. {
  52. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  53. {
  54. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  55. List<CardSource> selectedCards = new List<CardSource>();
  56. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  57. selectCardEffect.SetUp(
  58. canTargetCondition: CanSelectCardCondition,
  59. canTargetCondition_ByPreSelecetedList: null,
  60. canEndSelectCondition: null,
  61. canNoSelect: () => true,
  62. selectCardCoroutine: SelectCardCoroutine,
  63. afterSelectCardCoroutine: null,
  64. message: "Select 1 card to play.",
  65. maxCount: maxCount,
  66. canEndNotMax: false,
  67. isShowOpponent: true,
  68. mode: SelectCardEffect.Mode.Custom,
  69. root: SelectCardEffect.Root.Trash,
  70. customRootCardList: null,
  71. canLookReverseCard: true,
  72. selectPlayer: card.Owner,
  73. cardEffect: activateClass);
  74. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  75. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  76. yield return StartCoroutine(selectCardEffect.Activate());
  77. IEnumerator SelectCardCoroutine(CardSource cardSource)
  78. {
  79. selectedCards.Add(cardSource);
  80. yield return null;
  81. }
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  83. }
  84. }
  85. }
  86. if (timing == EffectTiming.OnEnterFieldAnyone)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Trash 2 cards from deck top and delete 1 Digimon", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[When Digivolving] You may trash the top 2 cards of your deck. Then, delete 1 of your opponent's level 3 or lower Digimon. For every 10 cards in your trash, add 1 to the maximum level of the Digimon you can choose with this effect.";
  95. }
  96. bool CanSelectPermanentCondition(Permanent permanent)
  97. {
  98. if (permanent != null)
  99. {
  100. if (permanent.TopCard != null)
  101. {
  102. if (permanent.IsDigimon)
  103. {
  104. if (permanent.TopCard.Owner == card.Owner.Enemy)
  105. {
  106. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  107. {
  108. int maxLevel = 3 + card.Owner.TrashCards.Count / 10;
  109. if (permanent.Level <= maxLevel)
  110. {
  111. if (permanent.TopCard.HasLevel)
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  126. }
  127. bool CanActivateCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleArea(card))
  130. {
  131. return true;
  132. }
  133. return false;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  136. {
  137. if (isExistOnField(card))
  138. {
  139. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  140. {
  141. if (card.Owner.LibraryCards.Count >= 1)
  142. {
  143. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  144. {
  145. new SelectionElement<bool>(message: $"Trash", value : true, spriteIndex: 0),
  146. new SelectionElement<bool>(message: $"Not trash", value : false, spriteIndex: 1),
  147. };
  148. string selectPlayerMessage = "Will you trash the top cards of your deck?";
  149. string notSelectPlayerMessage = "The opponent is choosing whether to trash the top cards of deck.";
  150. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  151. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  152. bool doTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  153. if (doTrash)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(2, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  156. }
  157. }
  158. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  159. {
  160. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: CanSelectPermanentCondition,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: maxCount,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: null,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Destroy,
  173. cardEffect: activateClass);
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  175. }
  176. }
  177. }
  178. }
  179. }
  180. if (timing == EffectTiming.OnAllyAttack)
  181. {
  182. ActivateClass activateClass = new ActivateClass();
  183. activateClass.SetUpICardEffect("Trash 2 cards from deck top and delete 1 Digimon", CanUseCondition, card);
  184. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  185. cardEffects.Add(activateClass);
  186. string EffectDiscription()
  187. {
  188. return "[When Attacking] You may trash the top 2 cards of your deck. Then, delete 1 of your opponent's level 3 or lower Digimon. For every 10 cards in your trash, add 1 to the maximum level of the Digimon you can choose with this effect.";
  189. }
  190. bool CanSelectPermanentCondition(Permanent permanent)
  191. {
  192. if (permanent != null)
  193. {
  194. if (permanent.TopCard != null)
  195. {
  196. if (permanent.IsDigimon)
  197. {
  198. if (permanent.TopCard.Owner == card.Owner.Enemy)
  199. {
  200. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  201. {
  202. int maxLevel = 3 + card.Owner.TrashCards.Count / 10;
  203. if (permanent.Level <= maxLevel)
  204. {
  205. if (permanent.TopCard.HasLevel)
  206. {
  207. return true;
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. }
  215. return false;
  216. }
  217. bool CanUseCondition(Hashtable hashtable)
  218. {
  219. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  220. }
  221. bool CanActivateCondition(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.IsExistOnBattleArea(card))
  224. {
  225. return true;
  226. }
  227. return false;
  228. }
  229. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  230. {
  231. if (isExistOnField(card))
  232. {
  233. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  234. {
  235. if (card.Owner.LibraryCards.Count >= 1)
  236. {
  237. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  238. {
  239. new SelectionElement<bool>(message: $"Trash", value : true, spriteIndex: 0),
  240. new SelectionElement<bool>(message: $"Not trash", value : false, spriteIndex: 1),
  241. };
  242. string selectPlayerMessage = "Will you trash the top cards of your deck?";
  243. string notSelectPlayerMessage = "The opponent is choosing whether to trash the top cards of deck.";
  244. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  245. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  246. bool doTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  247. if (doTrash)
  248. {
  249. yield return ContinuousController.instance.StartCoroutine(new IAddTrashCardsFromLibraryTop(2, card.Owner, activateClass).AddTrashCardsFromLibraryTop());
  250. }
  251. }
  252. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  253. {
  254. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  255. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  256. selectPermanentEffect.SetUp(
  257. selectPlayer: card.Owner,
  258. canTargetCondition: CanSelectPermanentCondition,
  259. canTargetCondition_ByPreSelecetedList: null,
  260. canEndSelectCondition: null,
  261. maxCount: maxCount,
  262. canNoSelect: false,
  263. canEndNotMax: false,
  264. selectPermanentCoroutine: null,
  265. afterSelectPermanentCoroutine: null,
  266. mode: SelectPermanentEffect.Mode.Destroy,
  267. cardEffect: activateClass);
  268. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  269. }
  270. }
  271. }
  272. }
  273. }
  274. return cardEffects;
  275. }
  276. }
  277. }