BT15_029.cs 16 KB

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