EX3_022.cs 15 KB

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