EX3_026.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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_026 : 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.OnEnterFieldAnyone)
  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 Digivolving] You may play 1 blue level 3 Digimon card or 1 Digimon card with [Seadramon] in its name or [Aqua] or [Sea Animal] in one of its traits from one 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.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  27. {
  28. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  29. {
  30. return true;
  31. }
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. if (cardSource.IsDigimon)
  39. {
  40. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  41. {
  42. if (cardSource.Level == 3)
  43. {
  44. if (cardSource.HasLevel)
  45. {
  46. if (cardSource.HasCardColor(CardColor.Blue))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. if (cardSource.HasAquaTraits)
  53. {
  54. return true;
  55. }
  56. if (cardSource.ContainsCardName("Seadramon"))
  57. {
  58. return true;
  59. }
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  67. }
  68. bool CanActivateCondition(Hashtable hashtable)
  69. {
  70. if (CardEffectCommons.IsExistOnBattleArea(card))
  71. {
  72. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  73. {
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  80. {
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon which has digivolution cards.", "The opponent is selecting 1 Digimon which has digivolution cards.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. Permanent selectedPermanent = permanent;
  100. if (selectedPermanent != null)
  101. {
  102. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  103. {
  104. maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  105. List<CardSource> selectedCards = new List<CardSource>();
  106. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  107. selectCardEffect.SetUp(
  108. canTargetCondition: CanSelectCardCondition,
  109. canTargetCondition_ByPreSelecetedList: null,
  110. canEndSelectCondition: null,
  111. canNoSelect: () => true,
  112. selectCardCoroutine: SelectCardCoroutine,
  113. afterSelectCardCoroutine: null,
  114. message: "Select 1 digivolution card to play.",
  115. maxCount: maxCount,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. mode: SelectCardEffect.Mode.Custom,
  119. root: SelectCardEffect.Root.Custom,
  120. customRootCardList: selectedPermanent.DigivolutionCards,
  121. canLookReverseCard: true,
  122. selectPlayer: card.Owner,
  123. cardEffect: activateClass);
  124. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  125. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  126. yield return StartCoroutine(selectCardEffect.Activate());
  127. IEnumerator SelectCardCoroutine(CardSource cardSource)
  128. {
  129. selectedCards.Add(cardSource);
  130. yield return null;
  131. }
  132. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true));
  133. }
  134. }
  135. }
  136. }
  137. }
  138. if (timing == EffectTiming.OnEnterFieldAnyone)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Activate 1 [When Digivolving] effect", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  143. activateClass.SetHashString("Activate_EX3_026");
  144. cardEffects.Add(activateClass);
  145. string EffectDiscription()
  146. {
  147. return "[Opponent's Turn][Once Per Turn] When your opponent plays a Digimon, you may activate 1 of this Digimon's [When Digivolving] effects.";
  148. }
  149. bool PermanentCondition(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  152. }
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. if (CardEffectCommons.IsExistOnBattleArea(card))
  156. {
  157. if (CardEffectCommons.IsOpponentTurn(card))
  158. {
  159. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  160. {
  161. return true;
  162. }
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanActivateCondition(Hashtable hashtable)
  168. {
  169. if (CardEffectCommons.IsExistOnBattleArea(card))
  170. {
  171. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  172. .Clone()
  173. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  174. if (candidateEffects.Count >= 1)
  175. {
  176. return true;
  177. }
  178. }
  179. return false;
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  182. {
  183. if (CardEffectCommons.IsExistOnBattleArea(card))
  184. {
  185. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  186. .Clone()
  187. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  188. if (candidateEffects.Count >= 1)
  189. {
  190. ICardEffect selectedEffect = null;
  191. if (candidateEffects.Count == 1)
  192. {
  193. selectedEffect = candidateEffects[0];
  194. }
  195. else
  196. {
  197. List<SkillInfo> skillInfos = candidateEffects
  198. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  199. List<CardSource> cardSources = candidateEffects
  200. .Map(cardEffect => cardEffect.EffectSourceCard);
  201. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  202. selectCardEffect.SetUp(
  203. canTargetCondition: (cardSource) => true,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. canNoSelect: () => false,
  207. selectCardCoroutine: null,
  208. afterSelectCardCoroutine: null,
  209. message: "Select 1 effect to activate.",
  210. maxCount: 1,
  211. canEndNotMax: false,
  212. isShowOpponent: false,
  213. mode: SelectCardEffect.Mode.Custom,
  214. root: SelectCardEffect.Root.Custom,
  215. customRootCardList: cardSources,
  216. canLookReverseCard: true,
  217. selectPlayer: card.Owner,
  218. cardEffect: activateClass);
  219. selectCardEffect.SetNotShowCard();
  220. selectCardEffect.SetUpSkillInfos(skillInfos);
  221. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  222. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  223. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  224. {
  225. if (selectedIndexes.Count == 1)
  226. {
  227. selectedEffect = candidateEffects[selectedIndexes[0]];
  228. yield return null;
  229. }
  230. }
  231. }
  232. if (selectedEffect != null)
  233. {
  234. if (selectedEffect.EffectSourceCard != null)
  235. {
  236. if (selectedEffect.EffectSourceCard.PermanentOfThisCard() != null)
  237. {
  238. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  239. if (selectedEffect.CanUse(effectHashtable))
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  242. }
  243. }
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. return cardEffects;
  251. }
  252. }
  253. }