BT12_032.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_032 : 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 Digimon card with a [Hybrid], [Aqua], or [Sea Animal] trait from 1 of your blue Digimon's digivolution cards without paying its 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.HasCardColor(CardColor.Blue))
  41. {
  42. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  43. {
  44. if (cardSource.CardTraits.Contains("Hybrid"))
  45. {
  46. return true;
  47. }
  48. if (cardSource.HasAquaTraits)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.IsExistOnBattleArea(card))
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  73. {
  74. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  75. {
  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(
  91. "Select 1 Digimon which has digivolution cards.",
  92. "The opponent is selecting 1 Digimon which has digivolution cards.");
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  95. {
  96. Permanent selectedPermanent = permanent;
  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(
  122. "Select 1 digivolution card to play.",
  123. "The opponent is selecting 1 digivolution card to play.");
  124. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  125. yield return StartCoroutine(selectCardEffect.Activate());
  126. IEnumerator SelectCardCoroutine(CardSource cardSource)
  127. {
  128. selectedCards.Add(cardSource);
  129. yield return null;
  130. }
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  132. cardSources: selectedCards,
  133. activateClass: activateClass,
  134. payCost: false,
  135. isTapped: false,
  136. root: SelectCardEffect.Root.DigivolutionCards,
  137. activateETB: true));
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. if (timing == EffectTiming.OnDestroyedAnyone)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  149. cardEffects.Add(activateClass);
  150. string EffectDiscription()
  151. {
  152. return "[On Deletion] You may play 1 blue level 4 or lower Digimon card with [Hybrid] in its form from your hand without paying its memory cost.";
  153. }
  154. bool CanSelectCardCondition(CardSource cardSource)
  155. {
  156. if (cardSource.IsDigimon)
  157. {
  158. if (cardSource.HasCardColor(CardColor.Blue))
  159. {
  160. if (cardSource.Level <= 4)
  161. {
  162. if (cardSource.CardTraits.Contains("Hybrid"))
  163. {
  164. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  165. {
  166. if (cardSource.HasLevel)
  167. {
  168. return true;
  169. }
  170. }
  171. }
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  180. }
  181. bool CanActivateCondition(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.IsExistOnTrash(card))
  184. {
  185. if (card.Owner.HandCards.Count >= 1)
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  193. {
  194. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  195. {
  196. List<CardSource> selectedCards = new List<CardSource>();
  197. int maxCount = 1;
  198. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  199. selectHandEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectCardCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: maxCount,
  205. canNoSelect: true,
  206. canEndNotMax: false,
  207. isShowOpponent: true,
  208. selectCardCoroutine: SelectCardCoroutine,
  209. afterSelectCardCoroutine: null,
  210. mode: SelectHandEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  213. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  214. yield return StartCoroutine(selectHandEffect.Activate());
  215. IEnumerator SelectCardCoroutine(CardSource cardSource)
  216. {
  217. selectedCards.Add(cardSource);
  218. yield return null;
  219. }
  220. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  221. cardSources: selectedCards,
  222. activateClass: activateClass,
  223. payCost: false,
  224. isTapped: false,
  225. root: SelectCardEffect.Root.Hand,
  226. activateETB: true));
  227. }
  228. }
  229. }
  230. return cardEffects;
  231. }
  232. }
  233. }