BT19_013.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_013 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region All Turns
  13. if (timing == EffectTiming.WhenRemoveField)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Save up to 3 Digimon cards with the [Xros Heart] trait.", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[All Turns] When this Digimon would leave the battle area, you may place up to 3 Digimon cards with the [Xros Heart] trait from this Digimon's digivolution cards under 1 of your Tamers.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  27. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  28. }
  29. bool CanSelectCardCondition(CardSource cardSource)
  30. {
  31. return cardSource.IsDigimon && cardSource.EqualsTraits("Xros Heart");
  32. }
  33. bool CanSelectSaveTamerPermanentCondition(Permanent permanent)
  34. {
  35. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  36. && permanent.IsTamer;
  37. }
  38. bool CanActivateCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  41. card.PermanentOfThisCard().DigivolutionCards.Some(CanSelectCardCondition);
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable hashtable)
  44. {
  45. List<CardSource> selectedCards = new List<CardSource>();
  46. int maxCount = Math.Min(3, card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition));
  47. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  48. selectCardEffect.SetUp(
  49. canTargetCondition: CanSelectCardCondition,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. canNoSelect: () => true,
  53. selectCardCoroutine: SelectCardCoroutine,
  54. afterSelectCardCoroutine: null,
  55. message: "Select digivolution cards to place under 1 of your Tamers.",
  56. maxCount: maxCount,
  57. canEndNotMax: false,
  58. isShowOpponent: true,
  59. mode: SelectCardEffect.Mode.Custom,
  60. root: SelectCardEffect.Root.Custom,
  61. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  62. canLookReverseCard: true,
  63. selectPlayer: card.Owner,
  64. cardEffect: activateClass);
  65. selectCardEffect.SetUpCustomMessage(
  66. "Select digivolution cards to place under 1 of your Tamers.",
  67. "The opponent is selecting digivolution cards to place under 1 of your Tamers.");
  68. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  69. yield return StartCoroutine(selectCardEffect.Activate());
  70. IEnumerator SelectCardCoroutine(CardSource cardSource)
  71. {
  72. selectedCards.Add(cardSource);
  73. yield return null;
  74. }
  75. if (selectedCards.Count >= 1)
  76. {
  77. Permanent selectedPermanent = null;
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectSaveTamerPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: 1,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to place the chosen cards under.",
  92. "The opponent is selecting 1 Tamer to place the chosen cards under.");
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  95. {
  96. selectedPermanent = permanent;
  97. yield return null;
  98. }
  99. if (selectedPermanent != null)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(
  102. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region On Deletion
  109. if (timing == EffectTiming.OnDestroyedAnyone)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Play 1 play cost 4 or lower [Xros Heart] Digimon", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  114. cardEffects.Add(activateClass);
  115. string EffectDescription()
  116. {
  117. return
  118. "[On Deletion] You may play 1 play cost 4 or lower Digimon card with the [Xros Heart] trait from under your Tamers without paying the cost.";
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  123. }
  124. bool HasXrosHeartTraitCondition(CardSource cardSource)
  125. {
  126. return cardSource.IsDigimon && cardSource.EqualsTraits("Xros Heart") &&
  127. cardSource.HasPlayCost && cardSource.GetCostItself <= 4 &&
  128. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  129. }
  130. bool TamerHasDigimonCondition(Permanent permanent)
  131. {
  132. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  133. permanent.IsTamer && permanent.DigivolutionCards.Count(HasXrosHeartTraitCondition) >= 1;
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  138. CardEffectCommons.HasMatchConditionPermanent(TamerHasDigimonCondition);
  139. }
  140. IEnumerator ActivateCoroutine(Hashtable hashtable)
  141. {
  142. Permanent selectedPermanent = null;
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: TamerHasDigimonCondition,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: true,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: SelectPermanentCoroutine,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Custom,
  155. cardEffect: activateClass);
  156. selectPermanentEffect.SetUpCustomMessage("Select a Tamer.", "The opponent is selecting a Tamer.");
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  159. {
  160. selectedPermanent = permanent;
  161. yield return null;
  162. }
  163. if (selectedPermanent != null)
  164. {
  165. List<CardSource> selectedCards = new List<CardSource>();
  166. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  167. selectCardEffect.SetUp(
  168. canTargetCondition: HasXrosHeartTraitCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. canNoSelect: () => true,
  172. selectCardCoroutine: SelectCardCoroutine,
  173. afterSelectCardCoroutine: null,
  174. message: "Select 1 digivolution card to play.",
  175. maxCount: 1,
  176. canEndNotMax: false,
  177. isShowOpponent: true,
  178. mode: SelectCardEffect.Mode.Custom,
  179. root: SelectCardEffect.Root.Custom,
  180. customRootCardList: selectedPermanent.DigivolutionCards,
  181. canLookReverseCard: true,
  182. selectPlayer: card.Owner,
  183. cardEffect: activateClass);
  184. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  185. "The opponent is selecting 1 digivolution card to play.");
  186. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  187. yield return StartCoroutine(selectCardEffect.Activate());
  188. IEnumerator SelectCardCoroutine(CardSource cardSource)
  189. {
  190. selectedCards.Add(cardSource);
  191. yield return null;
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  194. cardSources: selectedCards,
  195. activateClass: activateClass,
  196. payCost: false,
  197. isTapped: false,
  198. root: SelectCardEffect.Root.DigivolutionCards,
  199. activateETB: true));
  200. }
  201. }
  202. }
  203. #endregion
  204. #region DigiXros
  205. if (timing == EffectTiming.None)
  206. {
  207. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  208. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  209. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  210. addDigiXrosConditionClass.SetNotShowUI(true);
  211. cardEffects.Add(addDigiXrosConditionClass);
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return true;
  215. }
  216. DigiXrosCondition GetDigiXros(CardSource cardSource)
  217. {
  218. if (cardSource == card)
  219. {
  220. DigiXrosConditionElement elementA = new DigiXrosConditionElement(CanSelectCardConditionA, "Shoutmon");
  221. bool CanSelectCardConditionA(CardSource conditionCardSource)
  222. {
  223. if (conditionCardSource)
  224. {
  225. if (conditionCardSource.Owner == card.Owner)
  226. {
  227. if (conditionCardSource.IsDigimon)
  228. {
  229. if (conditionCardSource.CardNames_DigiXros.Contains("Shoutmon"))
  230. {
  231. return true;
  232. }
  233. }
  234. }
  235. }
  236. return false;
  237. }
  238. DigiXrosConditionElement elementB = new DigiXrosConditionElement(CanSelectCardConditionB, "Ballistamon");
  239. bool CanSelectCardConditionB(CardSource conditionCardSource)
  240. {
  241. if (conditionCardSource)
  242. {
  243. if (conditionCardSource.Owner == card.Owner)
  244. {
  245. if (conditionCardSource.IsDigimon)
  246. {
  247. if (conditionCardSource.CardNames_DigiXros.Contains("Ballistamon"))
  248. {
  249. return true;
  250. }
  251. }
  252. }
  253. }
  254. return false;
  255. }
  256. DigiXrosConditionElement elementC = new DigiXrosConditionElement(CanSelectCardConditionC, "Dorulumon");
  257. bool CanSelectCardConditionC(CardSource conditionCardSource)
  258. {
  259. if (conditionCardSource)
  260. {
  261. if (conditionCardSource.Owner == card.Owner)
  262. {
  263. if (conditionCardSource.IsDigimon)
  264. {
  265. if (conditionCardSource.CardNames_DigiXros.Contains("Dorulumon"))
  266. {
  267. return true;
  268. }
  269. }
  270. }
  271. }
  272. return false;
  273. }
  274. DigiXrosConditionElement elementD = new DigiXrosConditionElement(CanSelectCardConditionD, "Starmons");
  275. bool CanSelectCardConditionD(CardSource conditionCardSource)
  276. {
  277. if (conditionCardSource)
  278. {
  279. if (conditionCardSource.Owner == card.Owner)
  280. {
  281. if (conditionCardSource.IsDigimon)
  282. {
  283. if (conditionCardSource.CardNames_DigiXros.Contains("Starmons"))
  284. {
  285. return true;
  286. }
  287. }
  288. }
  289. }
  290. return false;
  291. }
  292. DigiXrosConditionElement elementE = new DigiXrosConditionElement(CanSelectCardConditionE, "Sparrowmon");
  293. bool CanSelectCardConditionE(CardSource conditionCardSource)
  294. {
  295. if (conditionCardSource)
  296. {
  297. if (conditionCardSource.Owner == card.Owner)
  298. {
  299. if (conditionCardSource.IsDigimon)
  300. {
  301. if (conditionCardSource.CardNames_DigiXros.Contains("Sparrowmon"))
  302. {
  303. return true;
  304. }
  305. }
  306. }
  307. }
  308. return false;
  309. }
  310. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  311. { elementA, elementB, elementC, elementD, elementE };
  312. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  313. return digiXrosCondition;
  314. }
  315. return null;
  316. }
  317. }
  318. #endregion
  319. return cardEffects;
  320. }
  321. }
  322. }