EX6_015.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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_015 : 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 Shared
  13. bool CanSelectSharedOwnPermanentCondition(Permanent permanent)
  14. {
  15. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  16. {
  17. if (permanent != card.PermanentOfThisCard())
  18. {
  19. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  20. {
  21. if (!permanent.TopCard.Equals(card))
  22. return true;
  23. }
  24. }
  25. }
  26. return false;
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect(
  34. "Place digivolution cards and activate effects", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  36. EffectDescription());
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. {
  40. return "[On Play] You may place up to 3 of your other blue Digimon as this Digimon's bottom digivolution cards. Then, return all other level 4 or lower Digimon to the hand. For each card placed in this Digimon's digivolution cards, add 1 to the level this effect may return.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  45. }
  46. bool CanActivateCondition(Hashtable hashtable)
  47. {
  48. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  49. }
  50. IEnumerator ActivateCoroutine(Hashtable hashtable)
  51. {
  52. List<CardSource> selectedCards = new List<CardSource>();
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectSharedOwnPermanentCondition))
  54. {
  55. // If there is other blue Digimon in owner Battle Area
  56. int maxCount = Math.Min(3,
  57. CardEffectCommons.MatchConditionPermanentCount(CanSelectSharedOwnPermanentCondition));
  58. SelectPermanentEffect selectPermanentEffect =
  59. GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectSharedOwnPermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: CanEndSelectCondition,
  65. maxCount: maxCount,
  66. canNoSelect: true,
  67. canEndNotMax: true,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. selectPermanentEffect.SetUpCustomMessage(
  73. "Select up to 3 Digimon to place on bottom of digivolution cards.",
  74. "The opponent is selecting up to 3 Digimon to place on bottom of digivolution cards.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. bool CanEndSelectCondition(List<Permanent> permanents)
  77. {
  78. if (CardEffectCommons.HasNoElement(permanents))
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. IEnumerator SelectPermanentCoroutine(Permanent selectedPermanent)
  85. {
  86. selectedCards.Add(selectedPermanent.TopCard);
  87. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  88. new List<Permanent[]>() { new Permanent[] { selectedPermanent, card.PermanentOfThisCard() } },
  89. false,
  90. activateClass).PlacePermanentToDigivolutionCards());
  91. yield return null;
  92. }
  93. }
  94. bool BouncePermanentCondition(Permanent permanent)
  95. {
  96. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  97. {
  98. if(permanent != card.PermanentOfThisCard())
  99. {
  100. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  101. {
  102. return permanent.TopCard.HasLevel && permanent.Level <= 4 + selectedCards.Count;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. // Return all Digimon with a level lower or equal to 4 plus the number of chosen Digimon
  109. List<Permanent> bounceTargetPermanents = new List<Permanent>();
  110. bounceTargetPermanents.AddRange(card.Owner.Enemy.GetBattleAreaDigimons().Filter(BouncePermanentCondition));
  111. bounceTargetPermanents.AddRange(card.Owner.GetBattleAreaDigimons().Filter(BouncePermanentCondition));
  112. yield return ContinuousController.instance.StartCoroutine(
  113. new HandBounceClaass(bounceTargetPermanents,
  114. CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  115. }
  116. }
  117. #endregion
  118. #region When Digivolving
  119. if (timing == EffectTiming.OnEnterFieldAnyone)
  120. {
  121. ActivateClass activateClass = new ActivateClass();
  122. activateClass.SetUpICardEffect(
  123. "Place digivolution cards and activate effects", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false,
  125. EffectDescription());
  126. cardEffects.Add(activateClass);
  127. string EffectDescription()
  128. {
  129. return "[When Digivolving] You may place up to 3 of your other blue Digimon as this Digimon's bottom digivolution cards. Then, return all other level 4 or lower Digimon to the hand. For each card placed in this Digimon's digivolution cards, add 1 to the level this effect may return.";
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable hashtable)
  140. {
  141. List<CardSource> selectedCards = new List<CardSource>();
  142. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectSharedOwnPermanentCondition))
  143. {
  144. // If there is other blue Digimon in owner Battle Area
  145. int maxCount = Math.Min(3,
  146. CardEffectCommons.MatchConditionPermanentCount(CanSelectSharedOwnPermanentCondition));
  147. SelectPermanentEffect selectPermanentEffect =
  148. GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectSharedOwnPermanentCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: CanEndSelectCondition,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: true,
  157. selectPermanentCoroutine: SelectPermanentCoroutine,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Custom,
  160. cardEffect: activateClass);
  161. selectPermanentEffect.SetUpCustomMessage(
  162. "Select up to 3 Digimon to place on bottom of digivolution cards.",
  163. "The opponent is selecting up to 3 Digimon to place on bottom of digivolution cards.");
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. bool CanEndSelectCondition(List<Permanent> permanents)
  166. {
  167. if (CardEffectCommons.HasNoElement(permanents))
  168. {
  169. return false;
  170. }
  171. return true;
  172. }
  173. IEnumerator SelectPermanentCoroutine(Permanent selectedPermanent)
  174. {
  175. selectedCards.Add(selectedPermanent.TopCard);
  176. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(
  177. new List<Permanent[]>() { new Permanent[] { selectedPermanent, card.PermanentOfThisCard() } },
  178. false,
  179. activateClass).PlacePermanentToDigivolutionCards());
  180. yield return null;
  181. }
  182. }
  183. bool BouncePermanentCondition(Permanent permanent)
  184. {
  185. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  186. {
  187. if (permanent != card.PermanentOfThisCard())
  188. {
  189. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  190. {
  191. return permanent.TopCard.HasLevel && permanent.Level <= 4 + selectedCards.Count;
  192. }
  193. }
  194. }
  195. return false;
  196. }
  197. // Return all Digimon with a level lower or equal to 4 plus the number of chosen Digimon
  198. List<Permanent> bounceTargetPermanents = new List<Permanent>();
  199. bounceTargetPermanents.AddRange(card.Owner.Enemy.GetBattleAreaDigimons().Filter(BouncePermanentCondition));
  200. bounceTargetPermanents.AddRange(card.Owner.GetBattleAreaDigimons().Filter(BouncePermanentCondition));
  201. yield return ContinuousController.instance.StartCoroutine(
  202. new HandBounceClaass(bounceTargetPermanents,
  203. CardEffectCommons.CardEffectHashtable(activateClass)).Bounce());
  204. }
  205. }
  206. #endregion
  207. #region All Turns
  208. if (timing == EffectTiming.OnAddDigivolutionCards)
  209. {
  210. ActivateClass activateClass = new ActivateClass();
  211. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  212. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  213. activateClass.SetHashString("Play1DigivolutionCard_EX6_015");
  214. cardEffects.Add(activateClass);
  215. string EffectDescription()
  216. {
  217. return "[Your Turn] [Once Per Turn] When an effect places a digivolution card under this Digimon, you may play 1 level 5 or lower Digimon card with [Aqua]/[Sea Animal] in one of its traits from this Digimon's digivolution cards without paying the cost.";
  218. }
  219. bool CanSelectCardCondition(CardSource cardSource)
  220. {
  221. if (cardSource.IsDigimon)
  222. {
  223. if (cardSource.Level <= 5)
  224. {
  225. if (cardSource.HasAquaTraits)
  226. {
  227. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false,
  228. cardEffect: activateClass))
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. }
  235. return false;
  236. }
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  240. {
  241. if (CardEffectCommons.IsOwnerTurn(card))
  242. {
  243. if (CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  244. hashtable: hashtable,
  245. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  246. cardEffectCondition: cardEffect => cardEffect != null,
  247. cardCondition: null))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. return false;
  254. }
  255. bool CanActivateCondition(Hashtable hashtable)
  256. {
  257. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable hashtable)
  260. {
  261. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  262. {
  263. int maxCount = Math.Min(1,card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition));
  264. List<CardSource> selectedCards = new List<CardSource>();
  265. SelectCardEffect selectCardEffect =
  266. GManager.instance.GetComponent<SelectCardEffect>();
  267. selectCardEffect.SetUp(
  268. canTargetCondition: CanSelectCardCondition,
  269. canTargetCondition_ByPreSelecetedList: null,
  270. canEndSelectCondition: null,
  271. canNoSelect: () => true,
  272. selectCardCoroutine: SelectCardCoroutine,
  273. afterSelectCardCoroutine: null,
  274. message: "Select 1 digivolution card to play.",
  275. maxCount: maxCount,
  276. canEndNotMax: false,
  277. isShowOpponent: true,
  278. mode: SelectCardEffect.Mode.Custom,
  279. root: SelectCardEffect.Root.Custom,
  280. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  281. canLookReverseCard: true,
  282. selectPlayer: card.Owner,
  283. cardEffect: activateClass);
  284. selectCardEffect.SetUpCustomMessage(
  285. "Select 1 digivolution card to play.",
  286. "The opponent is selecting 1 digivolution card to play.");
  287. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  288. yield return StartCoroutine(selectCardEffect.Activate());
  289. IEnumerator SelectCardCoroutine(CardSource cardSource)
  290. {
  291. selectedCards.Add(cardSource);
  292. yield return null;
  293. }
  294. // Play the selected Digivolution card
  295. yield return ContinuousController.instance.StartCoroutine(
  296. CardEffectCommons.PlayPermanentCards(
  297. cardSources: selectedCards,
  298. activateClass: activateClass,
  299. payCost: false,
  300. isTapped: false,
  301. root: SelectCardEffect.Root.DigivolutionCards,
  302. activateETB: true));
  303. }
  304. }
  305. }
  306. #endregion
  307. return cardEffects;
  308. }
  309. }
  310. }