BT15_029.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_029 : 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.TopCard.CardColors.Contains(CardColor.Blue))
  18. {
  19. if (!permanent.TopCard.Equals(card))
  20. return true;
  21. }
  22. }
  23. return false;
  24. }
  25. bool CanSelectPermanentCondition(Permanent permanent)
  26. {
  27. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  28. {
  29. if (permanent.Level <= card.PermanentOfThisCard().cardSources.Last().Level)
  30. return true;
  31. }
  32. return false;
  33. }
  34. bool CanActivateSharedCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (card.Owner.GetBattleAreaDigimons().Count > 1)
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. #endregion
  46. #region On Play
  47. if (timing == EffectTiming.OnEnterFieldAnyone)
  48. {
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("Place 1 Digimon card to digivolution cards to return 1 of your opponent's Digimon whose level is less than or equal to the placed card's level to the bottom of the deck.", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  52. cardEffects.Add(activateClass);
  53. string EffectSharedDiscription()
  54. {
  55. return "[On Play] By placing 1 of your other blue Digimon as this Digimon's bottom digivolution card, return 1 of your opponent's Digimon whose level is less than or equal to the placed card's level to the bottom of the deck.";
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  62. {
  63. if (CanActivateSharedCondition(_hashtable))
  64. {
  65. List<CardSource> selectedCards = new List<CardSource>();
  66. int maxCount = 1;
  67. SelectPermanentEffect selectPermanentSourcecEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentSourcecEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectSharedOwnPermanentCondition,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: maxCount,
  74. canNoSelect: true,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentSourceCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentSourcecEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  81. yield return StartCoroutine(selectPermanentSourcecEffect.Activate());
  82. IEnumerator SelectPermanentSourceCoroutine(Permanent permanent)
  83. {
  84. selectedCards.Add(permanent.TopCard);
  85. yield return null;
  86. }
  87. if (selectedCards.Count >= 1)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  90. selectedCards,
  91. activateClass));
  92. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  93. {
  94. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  95. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  96. selectPermanentEffect.SetUp(
  97. selectPlayer: card.Owner,
  98. canTargetCondition: CanSelectPermanentCondition,
  99. canTargetCondition_ByPreSelecetedList: null,
  100. canEndSelectCondition: null,
  101. maxCount: maxCount,
  102. canNoSelect: false,
  103. canEndNotMax: false,
  104. selectPermanentCoroutine: SelectPermanentCoroutine,
  105. afterSelectPermanentCoroutine: null,
  106. mode: SelectPermanentEffect.Mode.Custom,
  107. cardEffect: activateClass);
  108. selectPermanentEffect.SetUpCustomMessage(
  109. "Select 1 Digimon to return to bottom of deck.",
  110. "The opponent is selecting 1 Digimon to return to bottom of deck.");
  111. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  112. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  113. {
  114. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(new List<Permanent> { permanent }, _hashtable).DeckBounce());
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. #endregion
  122. #region When Digivolving
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Place 1 Digimon card to digivolution cards to return 1 of your opponent's Digimon whose level is less than or equal to the placed card's level to the bottom of the deck.", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, true, EffectSharedDiscription());
  128. cardEffects.Add(activateClass);
  129. string EffectSharedDiscription()
  130. {
  131. return "[When Digivolving] By placing 1 of your other blue Digimon as this Digimon's bottom digivolution card, return 1 of your opponent's Digimon whose level is less than or equal to the placed card's level to the bottom of the deck.";
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  136. }
  137. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  138. {
  139. if (CanActivateSharedCondition(_hashtable))
  140. {
  141. List<CardSource> selectedCards = new List<CardSource>();
  142. int maxCount = 1;
  143. SelectPermanentEffect selectPermanentSourcecEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentSourcecEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: CanSelectSharedOwnPermanentCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: maxCount,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentSourceCoroutine,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectPermanentSourcecEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  157. yield return StartCoroutine(selectPermanentSourcecEffect.Activate());
  158. IEnumerator SelectPermanentSourceCoroutine(Permanent permanent)
  159. {
  160. selectedCards.Add(permanent.TopCard);
  161. yield return null;
  162. }
  163. if (selectedCards.Count >= 1)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  166. selectedCards,
  167. activateClass));
  168. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  169. {
  170. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: CanSelectPermanentCondition,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: maxCount,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: SelectPermanentCoroutine,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Custom,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage(
  185. "Select 1 Digimon to return to bottom of deck.",
  186. "The opponent is selecting 1 Digimon to return to bottom of deck.");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(new List<Permanent> { permanent }, _hashtable).DeckBounce());
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. #endregion
  198. #region Inherited Effect
  199. if (timing == EffectTiming.OnAllyAttack)
  200. {
  201. ActivateClass activateClass = new ActivateClass();
  202. activateClass.SetUpICardEffect("Unsuspend this Digimon, by placing 1 blue Digimon as bottom source", CanUseCondition, card);
  203. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  204. activateClass.SetIsInheritedEffect(true);
  205. activateClass.SetHashString("Unsuspend_BT15_020");
  206. cardEffects.Add(activateClass);
  207. string EffectDiscription()
  208. {
  209. return "[When Attacking] [Once Per Turn] By placing 1 of your other blue Digimon as this Digimon's bottom digivolution card, unsuspend this Digimon.";
  210. }
  211. bool CanSelectOwnPermanentCondition(Permanent permanent)
  212. {
  213. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  214. {
  215. if (permanent != card.PermanentOfThisCard())
  216. {
  217. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  218. {
  219. if (!permanent.TopCard.Equals(card))
  220. return true;
  221. }
  222. }
  223. }
  224. return false;
  225. }
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  229. }
  230. bool CanActivateCondition(Hashtable hashtable)
  231. {
  232. if (CardEffectCommons.IsExistOnBattleArea(card))
  233. {
  234. return true;
  235. }
  236. return false;
  237. }
  238. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  239. {
  240. if (CanActivateCondition(_hashtable))
  241. {
  242. List<CardSource> selectedCards = new List<CardSource>();
  243. int maxCount = 1;
  244. SelectPermanentEffect selectPermanentSourcecEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  245. selectPermanentSourcecEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectOwnPermanentCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: maxCount,
  251. canNoSelect: false,
  252. canEndNotMax: false,
  253. selectPermanentCoroutine: SelectPermanentSourceCoroutine,
  254. afterSelectPermanentCoroutine: null,
  255. mode: SelectPermanentEffect.Mode.Custom,
  256. cardEffect: activateClass);
  257. selectPermanentSourcecEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  258. yield return StartCoroutine(selectPermanentSourcecEffect.Activate());
  259. IEnumerator SelectPermanentSourceCoroutine(Permanent permanent)
  260. {
  261. selectedCards.Add(permanent.TopCard);
  262. yield return null;
  263. }
  264. if (selectedCards.Count >= 1)
  265. {
  266. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  267. selectedCards,
  268. activateClass));
  269. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  270. }
  271. }
  272. }
  273. }
  274. #endregion
  275. return cardEffects;
  276. }
  277. }
  278. }