BT13_030.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT13
  6. {
  7. public class BT13_030 : 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. int count()
  15. {
  16. return 2 * card.Owner.GetBattleAreaPermanents().Count((permanent) => (permanent.IsDigimon && permanent.TopCard.HasRoyalKnightTraits) || (permanent.TopCard.CardColors.Contains(CardColor.Blue) && permanent.IsTamer)); ;
  17. }
  18. ActivateClass activateClass = new ActivateClass();
  19. activateClass.SetUpICardEffect("Trash digivolution cards", CanUseCondition, card);
  20. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  21. cardEffects.Add(activateClass);
  22. string EffectDiscription()
  23. {
  24. return "[On Play] For each of your Digimon with the [Royal Knight] trait and each of your blue Tamers, trash the top 2 digivolution cards of 1 of your opponent's Digimon.";
  25. }
  26. bool CanSelectPermanentCondition(Permanent permanent)
  27. {
  28. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  29. {
  30. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  46. {
  47. if (count() >= 1)
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: CanSelectPermanentCondition,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: maxCount,
  65. canNoSelect: false,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: SelectPermanentCoroutine,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  74. {
  75. Permanent selectedPermanent = permanent;
  76. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: count(), isFromTop: true, activateClass: activateClass));
  77. }
  78. }
  79. }
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. int count()
  83. {
  84. return 2 * card.Owner.GetBattleAreaPermanents().Count((permanent) => (permanent.IsDigimon && permanent.TopCard.HasRoyalKnightTraits) || (permanent.TopCard.CardColors.Contains(CardColor.Blue) && permanent.IsTamer)); ;
  85. }
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Trash digivolution cards", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  89. cardEffects.Add(activateClass);
  90. string EffectDiscription()
  91. {
  92. return "[When Digivolving] For each of your Digimon with the [Royal Knight] trait and each of your blue Tamers, trash the top 2 digivolution cards of 1 of your opponent's Digimon.";
  93. }
  94. bool CanSelectPermanentCondition(Permanent permanent)
  95. {
  96. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  97. {
  98. if (permanent.DigivolutionCards.Count((cardSource) => !cardSource.CanNotTrashFromDigivolutionCards(activateClass)) >= 1)
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. if (CardEffectCommons.IsExistOnBattleArea(card))
  112. {
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  114. {
  115. if (count() >= 1)
  116. {
  117. return true;
  118. }
  119. }
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermanentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: false,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: SelectPermanentCoroutine,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.Custom,
  138. cardEffect: activateClass);
  139. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will trash digivolution cards.", "The opponent is selecting 1 Digimon that will trash digivolution cards.");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  142. {
  143. Permanent selectedPermanent = permanent;
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: count(), isFromTop: true, activateClass: activateClass));
  145. }
  146. }
  147. }
  148. if (timing == EffectTiming.OnEnterFieldAnyone)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Return 1 Digimon with no digivolution cards to hand", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  153. activateClass.SetHashString("Bounce_BT13_030");
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[Your Turn][Once Per Turn] When you play a Digimon with the [Royal Knight] trait or a blue Tamer, return 1 of your opponent's Digimon with no digivolution cards to the hand.";
  158. }
  159. bool PermanentCondition(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  162. {
  163. if (permanent.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Blue))
  164. {
  165. return true;
  166. }
  167. if (permanent.IsDigimon && permanent.TopCard.HasRoyalKnightTraits)
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool CanSelectPermanentCondition(Permanent permanent)
  175. {
  176. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  177. {
  178. if (permanent.HasNoDigivolutionCards)
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleArea(card))
  188. {
  189. if (CardEffectCommons.IsOwnerTurn(card))
  190. {
  191. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. return false;
  198. }
  199. bool CanActivateCondition(Hashtable hashtable)
  200. {
  201. if (CardEffectCommons.IsExistOnBattleArea(card))
  202. {
  203. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  204. {
  205. return true;
  206. }
  207. }
  208. return false;
  209. }
  210. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  211. {
  212. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  213. {
  214. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  215. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  216. selectPermanentEffect.SetUp(
  217. selectPlayer: card.Owner,
  218. canTargetCondition: CanSelectPermanentCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. maxCount: maxCount,
  222. canNoSelect: false,
  223. canEndNotMax: false,
  224. selectPermanentCoroutine: null,
  225. afterSelectPermanentCoroutine: null,
  226. mode: SelectPermanentEffect.Mode.Bounce,
  227. cardEffect: activateClass);
  228. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  229. }
  230. }
  231. }
  232. return cardEffects;
  233. }
  234. }
  235. }