EX6_014.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX6
  6. {
  7. public class EX6_014 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play/ When Digivolving
  13. // On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  19. EffectDescription());
  20. cardEffects.Add(activateClass);
  21. string EffectDescription()
  22. {
  23. return
  24. "[On Play] You may play 1 level 3 blue Digimon card from one of your blue Digimon's digivolution cards without paying the cost.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  31. {
  32. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (cardSource.IsDigimon)
  43. {
  44. if (cardSource.HasCardColor(CardColor.Blue))
  45. {
  46. if (cardSource.IsLevel3)
  47. {
  48. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  49. cardEffect: activateClass))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable hashtable)
  74. {
  75. // If there is a blue Digimon in the owner Battle Area
  76. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  77. {
  78. int maxCount = Math.Min(1,
  79. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  80. SelectPermanentEffect selectPermanentEffect =
  81. GManager.instance.GetComponent<SelectPermanentEffect>();
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectPermanentCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: maxCount,
  88. canNoSelect: true,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectPermanentCoroutine,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage(
  95. "Select 1 Digimon which has digivolution cards.",
  96. "The opponent is selecting 1 Digimon which has digivolution cards.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  99. {
  100. Permanent selectedPermanent = permanent;
  101. // If the selected Digimon has a level 3 blue Digimon as a Digivolution card
  102. if (selectedPermanent != null)
  103. {
  104. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  105. {
  106. maxCount = Math.Min(1,
  107. selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  108. List<CardSource> selectedCards = new List<CardSource>();
  109. SelectCardEffect selectCardEffect =
  110. GManager.instance.GetComponent<SelectCardEffect>();
  111. selectCardEffect.SetUp(
  112. canTargetCondition: CanSelectCardCondition,
  113. canTargetCondition_ByPreSelecetedList: null,
  114. canEndSelectCondition: null,
  115. canNoSelect: () => true,
  116. selectCardCoroutine: SelectCardCoroutine,
  117. afterSelectCardCoroutine: null,
  118. message: "Select 1 digivolution card to play.",
  119. maxCount: maxCount,
  120. canEndNotMax: false,
  121. isShowOpponent: true,
  122. mode: SelectCardEffect.Mode.Custom,
  123. root: SelectCardEffect.Root.Custom,
  124. customRootCardList: selectedPermanent.DigivolutionCards,
  125. canLookReverseCard: true,
  126. selectPlayer: card.Owner,
  127. cardEffect: activateClass);
  128. selectCardEffect.SetUpCustomMessage(
  129. "Select 1 digivolution card to play.",
  130. "The opponent is selecting 1 digivolution card to play.");
  131. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  132. yield return StartCoroutine(selectCardEffect.Activate());
  133. IEnumerator SelectCardCoroutine(CardSource cardSource)
  134. {
  135. selectedCards.Add(cardSource);
  136. yield return null;
  137. }
  138. // Play the selected Digivolution card
  139. yield return ContinuousController.instance.StartCoroutine(
  140. CardEffectCommons.PlayPermanentCards(
  141. cardSources: selectedCards,
  142. activateClass: activateClass,
  143. payCost: false,
  144. isTapped: false,
  145. root: SelectCardEffect.Root.DigivolutionCards,
  146. activateETB: true));
  147. }
  148. }
  149. }
  150. }
  151. }
  152. }
  153. // When Digivolving
  154. if (timing == EffectTiming.OnEnterFieldAnyone)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  159. EffectDescription());
  160. cardEffects.Add(activateClass);
  161. string EffectDescription()
  162. {
  163. return
  164. "[When Digivolving] You may play 1 level 3 blue Digimon card from one of your blue Digimon's digivolution cards without paying the cost.";
  165. }
  166. bool CanSelectPermanentCondition(Permanent permanent)
  167. {
  168. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  169. {
  170. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  171. {
  172. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  173. {
  174. return true;
  175. }
  176. }
  177. }
  178. return false;
  179. }
  180. bool CanSelectCardCondition(CardSource cardSource)
  181. {
  182. if (cardSource.IsDigimon)
  183. {
  184. if (cardSource.HasCardColor(CardColor.Blue))
  185. {
  186. if (cardSource.IsLevel3)
  187. {
  188. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  189. cardEffect: activateClass))
  190. {
  191. return true;
  192. }
  193. }
  194. }
  195. }
  196. return false;
  197. }
  198. bool CanUseCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  201. }
  202. bool CanActivateCondition(Hashtable hashtable)
  203. {
  204. if (CardEffectCommons.IsExistOnBattleArea(card))
  205. {
  206. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  207. {
  208. return true;
  209. }
  210. }
  211. return false;
  212. }
  213. IEnumerator ActivateCoroutine(Hashtable hashtable)
  214. {
  215. // If there is a blue Digimon in the owner Battle Area
  216. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  217. {
  218. int maxCount = Math.Min(1,
  219. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  220. SelectPermanentEffect selectPermanentEffect =
  221. GManager.instance.GetComponent<SelectPermanentEffect>();
  222. selectPermanentEffect.SetUp(
  223. selectPlayer: card.Owner,
  224. canTargetCondition: CanSelectPermanentCondition,
  225. canTargetCondition_ByPreSelecetedList: null,
  226. canEndSelectCondition: null,
  227. maxCount: maxCount,
  228. canNoSelect: true,
  229. canEndNotMax: false,
  230. selectPermanentCoroutine: SelectPermanentCoroutine,
  231. afterSelectPermanentCoroutine: null,
  232. mode: SelectPermanentEffect.Mode.Custom,
  233. cardEffect: activateClass);
  234. selectPermanentEffect.SetUpCustomMessage(
  235. "Select 1 Digimon which has digivolution cards.",
  236. "The opponent is selecting 1 Digimon which has digivolution cards.");
  237. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  238. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  239. {
  240. Permanent selectedPermanent = permanent;
  241. // If the selected Digimon has a level 3 blue Digimon as a Digivolution card
  242. if (selectedPermanent != null)
  243. {
  244. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  245. {
  246. maxCount = Math.Min(1,
  247. selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  248. List<CardSource> selectedCards = new List<CardSource>();
  249. SelectCardEffect selectCardEffect =
  250. GManager.instance.GetComponent<SelectCardEffect>();
  251. selectCardEffect.SetUp(
  252. canTargetCondition: CanSelectCardCondition,
  253. canTargetCondition_ByPreSelecetedList: null,
  254. canEndSelectCondition: null,
  255. canNoSelect: () => true,
  256. selectCardCoroutine: SelectCardCoroutine,
  257. afterSelectCardCoroutine: null,
  258. message: "Select 1 digivolution card to play.",
  259. maxCount: maxCount,
  260. canEndNotMax: false,
  261. isShowOpponent: true,
  262. mode: SelectCardEffect.Mode.Custom,
  263. root: SelectCardEffect.Root.Custom,
  264. customRootCardList: selectedPermanent.DigivolutionCards,
  265. canLookReverseCard: true,
  266. selectPlayer: card.Owner,
  267. cardEffect: activateClass);
  268. selectCardEffect.SetUpCustomMessage(
  269. "Select 1 digivolution card to play.",
  270. "The opponent is selecting 1 digivolution card to play.");
  271. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  272. yield return StartCoroutine(selectCardEffect.Activate());
  273. IEnumerator SelectCardCoroutine(CardSource cardSource)
  274. {
  275. selectedCards.Add(cardSource);
  276. yield return null;
  277. }
  278. // Play the selected Digivolution card
  279. yield return ContinuousController.instance.StartCoroutine(
  280. CardEffectCommons.PlayPermanentCards(
  281. cardSources: selectedCards,
  282. activateClass: activateClass,
  283. payCost: false,
  284. isTapped: false,
  285. root: SelectCardEffect.Root.DigivolutionCards,
  286. activateETB: true));
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. #endregion
  294. #region Inherited Effect
  295. if (timing == EffectTiming.OnAllyAttack)
  296. {
  297. ActivateClass activateClass = new ActivateClass();
  298. activateClass.SetUpICardEffect(
  299. "Place 1 of your other blue Digimon as this Digimon's bottom digivolution card to unsuspend this Digimon.",
  300. CanUseCondition, card);
  301. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  302. EffectDescription());
  303. activateClass.SetIsInheritedEffect(true);
  304. activateClass.SetHashString("Attacking_EX6_014");
  305. cardEffects.Add(activateClass);
  306. string EffectDescription()
  307. {
  308. return
  309. "[When Attacking][Once Per Turn] By placing 1 of your other blue Digimon as this Digimon's bottom digivolution card, unsuspend this Digimon.";
  310. }
  311. bool CanSelectPermanentCondition(Permanent permanent)
  312. {
  313. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  314. {
  315. if (permanent != card.PermanentOfThisCard())
  316. {
  317. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  318. {
  319. if (!permanent.TopCard.Equals(card))
  320. return true;
  321. }
  322. }
  323. }
  324. return false;
  325. }
  326. bool CanUseCondition(Hashtable hashtable)
  327. {
  328. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  329. }
  330. bool CanActivateCondition(Hashtable hashtable)
  331. {
  332. if (CardEffectCommons.IsExistOnBattleArea(card))
  333. {
  334. if (!card.PermanentOfThisCard().IsToken)
  335. {
  336. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  337. {
  338. return true;
  339. }
  340. }
  341. }
  342. return false;
  343. }
  344. IEnumerator ActivateCoroutine(Hashtable hashtable)
  345. {
  346. if (CardEffectCommons.IsExistOnBattleArea(card))
  347. {
  348. List<CardSource> selectedCards = new List<CardSource>();
  349. // If there is another blue Digimon in owner Battle Area
  350. int maxCount = Math.Min(1,
  351. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  352. SelectPermanentEffect selectPermanentEffect =
  353. GManager.instance.GetComponent<SelectPermanentEffect>();
  354. selectPermanentEffect.SetUp(
  355. selectPlayer: card.Owner,
  356. canTargetCondition: CanSelectPermanentCondition,
  357. canTargetCondition_ByPreSelecetedList: null,
  358. canEndSelectCondition: null,
  359. maxCount: maxCount,
  360. canNoSelect: true,
  361. canEndNotMax: false,
  362. selectPermanentCoroutine: SelectPermanentCoroutine,
  363. afterSelectPermanentCoroutine: null,
  364. mode: SelectPermanentEffect.Mode.Custom,
  365. cardEffect: activateClass);
  366. selectPermanentEffect.SetUpCustomMessage(
  367. "Select 1 card to place on bottom of digivolution cards.",
  368. "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  369. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  370. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  371. {
  372. selectedCards.Add(permanent.TopCard);
  373. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  374. new List<Permanent[]>() { new Permanent[] { permanent, card.PermanentOfThisCard() } },
  375. false,
  376. activateClass).PlacePermanentToDigivolutionCards());
  377. }
  378. if (selectedCards.Count >= 1)
  379. {
  380. yield return ContinuousController.instance.StartCoroutine(
  381. new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() },
  382. activateClass).Unsuspend());
  383. }
  384. }
  385. }
  386. }
  387. #endregion
  388. return cardEffects;
  389. }
  390. }
  391. }