BT11_031.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT11
  5. {
  6. public class BT11_031 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.CardNames.Contains("MetalGreymon");
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  18. }
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Unsuspend this Digimon and gain Memory +2", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  24. cardEffects.Add(activateClass);
  25. string EffectDiscription()
  26. {
  27. return "[When Digivolving] Unsuspend this Digimon. Then, if a card with [Blue Flare] or [Xros Heart] in its traits is in this Digimon's digivolution cards and your opponent has 2 or more Digimon in play, gain 2 memory.";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  32. }
  33. bool CanActivateCondition(Hashtable hashtable)
  34. {
  35. if (isExistOnField(card))
  36. {
  37. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  38. {
  39. if (CardEffectCommons.CanUnsuspend(card.PermanentOfThisCard()))
  40. {
  41. return true;
  42. }
  43. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardTraits.Contains("Blue Flare") || cardSource.CardTraits.Contains("BlueFlare") || cardSource.CardTraits.Contains("Xros Heart") || cardSource.CardTraits.Contains("XrosHeart")) >= 1)
  44. {
  45. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 2)
  46. {
  47. if (card.Owner.CanAddMemory(activateClass))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  58. {
  59. if (isExistOnField(card))
  60. {
  61. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  62. {
  63. Permanent selectedPermanent = card.PermanentOfThisCard();
  64. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  65. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardTraits.Contains("Blue Flare") || cardSource.CardTraits.Contains("BlueFlare") || cardSource.CardTraits.Contains("Xros Heart") || cardSource.CardTraits.Contains("XrosHeart")) >= 1)
  66. {
  67. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 2)
  68. {
  69. if (card.Owner.CanAddMemory(activateClass))
  70. {
  71. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(2, activateClass));
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }
  79. if (timing == EffectTiming.OnDestroyedAnyone)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Save and place cards to digivolution cards from trash", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  84. cardEffects.Add(activateClass);
  85. string EffectDiscription()
  86. {
  87. return "[On Deletion] <Save>. (You may place this card under one of your Tamers.) Then, place 1 blue [Greymon] and 1 blue [MailBirdramon] from your trash under 1 of your Tamers with [General] in its traits.";
  88. }
  89. bool CanSelectPermanentCondition(Permanent permanent)
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  92. {
  93. if (permanent.IsTamer)
  94. {
  95. if (!permanent.IsToken)
  96. {
  97. return true;
  98. }
  99. }
  100. }
  101. return false;
  102. }
  103. bool CanSelectCardCondition(CardSource cardSource)
  104. {
  105. if (cardSource != null)
  106. {
  107. if (cardSource.HasCardColor(CardColor.Blue))
  108. {
  109. if (cardSource.Owner == card.Owner)
  110. {
  111. if (cardSource.CardNames.Contains("Greymon"))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanSelectCardCondition1(CardSource cardSource)
  121. {
  122. if (cardSource != null)
  123. {
  124. if (cardSource.HasCardColor(CardColor.Blue))
  125. {
  126. if (cardSource.Owner == card.Owner)
  127. {
  128. if (cardSource.CardNames.Contains("MailBirdramon"))
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. }
  135. return false;
  136. }
  137. bool CanSelectPermanentCondition1(Permanent permanent)
  138. {
  139. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  140. {
  141. if (permanent.IsTamer)
  142. {
  143. if (!permanent.IsToken)
  144. {
  145. if (permanent.TopCard.CardTraits.Contains("General"))
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. if (CardEffectCommons.CanActivateSave(hashtable, CanSelectPermanentCondition))
  161. {
  162. return true;
  163. }
  164. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  165. {
  166. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  167. {
  168. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  169. {
  170. return true;
  171. }
  172. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  173. {
  174. return true;
  175. }
  176. }
  177. }
  178. return false;
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SaveProcess(_hashtable, activateClass, card, CanSelectPermanentCondition));
  183. if (card.Owner.GetBattleAreaPermanents().Count(CanSelectPermanentCondition1) >= 1)
  184. {
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. List<CardSource> digivolutionCards = new List<CardSource>();
  187. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  188. {
  189. int maxCount = 1;
  190. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  191. selectCardEffect.SetUp(
  192. canTargetCondition: CanSelectCardCondition,
  193. canTargetCondition_ByPreSelecetedList: null,
  194. canEndSelectCondition: null,
  195. canNoSelect: () => false,
  196. selectCardCoroutine: SelectCardCoroutine,
  197. afterSelectCardCoroutine: null,
  198. message: "Select 1 blue [Greymon] from trash.",
  199. maxCount: maxCount,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. mode: SelectCardEffect.Mode.Custom,
  203. root: SelectCardEffect.Root.Trash,
  204. customRootCardList: null,
  205. canLookReverseCard: true,
  206. selectPlayer: card.Owner,
  207. cardEffect: activateClass);
  208. selectCardEffect.SetUpCustomMessage("Select 1 blue [Greymon] from trash.", "The opponent is selecting 1 blue [Greymon] from trash.");
  209. yield return StartCoroutine(selectCardEffect.Activate());
  210. IEnumerator SelectCardCoroutine(CardSource cardSource)
  211. {
  212. selectedCards.Add(cardSource);
  213. yield return null;
  214. }
  215. }
  216. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1))
  217. {
  218. int maxCount = 1;
  219. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  220. selectCardEffect.SetUp(
  221. canTargetCondition: CanSelectCardCondition1,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. canNoSelect: () => false,
  225. selectCardCoroutine: SelectCardCoroutine,
  226. afterSelectCardCoroutine: null,
  227. message: "Select 1 blue [MailBirdramon] from trash.",
  228. maxCount: maxCount,
  229. canEndNotMax: false,
  230. isShowOpponent: true,
  231. mode: SelectCardEffect.Mode.Custom,
  232. root: SelectCardEffect.Root.Trash,
  233. customRootCardList: null,
  234. canLookReverseCard: true,
  235. selectPlayer: card.Owner,
  236. cardEffect: activateClass);
  237. selectCardEffect.SetUpCustomMessage("Select 1 blue [MailBirdramon] from trash.", "The opponent is selecting 1 blue [MailBirdramon] from trash.");
  238. yield return StartCoroutine(selectCardEffect.Activate());
  239. IEnumerator SelectCardCoroutine(CardSource cardSource)
  240. {
  241. selectedCards.Add(cardSource);
  242. yield return null;
  243. }
  244. }
  245. if (selectedCards.Count >= 1)
  246. {
  247. if (selectedCards.Count == 1)
  248. {
  249. foreach (CardSource cardSource in selectedCards)
  250. {
  251. digivolutionCards.Add(cardSource);
  252. }
  253. }
  254. else
  255. {
  256. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  257. selectCardEffect.SetUp(
  258. canTargetCondition: (cardSource) => true,
  259. canTargetCondition_ByPreSelecetedList: null,
  260. canEndSelectCondition: null,
  261. canNoSelect: () => false,
  262. selectCardCoroutine: null,
  263. afterSelectCardCoroutine: AfterSelectCardCoroutine1,
  264. message: "Specify the order to place the cards in the digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  265. maxCount: selectedCards.Count,
  266. canEndNotMax: false,
  267. isShowOpponent: false,
  268. mode: SelectCardEffect.Mode.Custom,
  269. root: SelectCardEffect.Root.Custom,
  270. customRootCardList: selectedCards,
  271. canLookReverseCard: true,
  272. selectPlayer: card.Owner,
  273. cardEffect: activateClass);
  274. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Cards");
  275. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  276. IEnumerator AfterSelectCardCoroutine1(List<CardSource> cardSources)
  277. {
  278. foreach (CardSource cardSource in cardSources)
  279. {
  280. digivolutionCards.Add(cardSource);
  281. }
  282. yield return null;
  283. }
  284. }
  285. if (digivolutionCards.Count >= 1)
  286. {
  287. int maxCount = 1;
  288. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  289. selectPermanentEffect.SetUp(
  290. selectPlayer: card.Owner,
  291. canTargetCondition: CanSelectPermanentCondition1,
  292. canTargetCondition_ByPreSelecetedList: null,
  293. canEndSelectCondition: null,
  294. maxCount: maxCount,
  295. canNoSelect: false,
  296. canEndNotMax: false,
  297. selectPermanentCoroutine: SelectPermanentCoroutine,
  298. afterSelectPermanentCoroutine: null,
  299. mode: SelectPermanentEffect.Mode.Custom,
  300. cardEffect: activateClass);
  301. selectPermanentEffect.SetUpCustomMessage($"Select 1 Tamer with [General] traits that will get digivolution cards from trash.", $"The opponent is selecting 1 Tamer with [General] traits that will get a digivolution cards from trash.");
  302. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  303. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  304. {
  305. Permanent selectedPermanent = permanent;
  306. if (selectedPermanent != null)
  307. {
  308. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(digivolutionCards, activateClass));
  309. }
  310. }
  311. }
  312. }
  313. }
  314. }
  315. }
  316. if (timing == EffectTiming.None)
  317. {
  318. bool Condition()
  319. {
  320. if (CardEffectCommons.IsExistOnBattleArea(card))
  321. {
  322. if (CardEffectCommons.IsOpponentTurn(card))
  323. {
  324. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("Blue Flare"))
  325. {
  326. return true;
  327. }
  328. if (card.PermanentOfThisCard().TopCard.CardTraits.Contains("BlueFlare"))
  329. {
  330. return true;
  331. }
  332. }
  333. }
  334. return false;
  335. }
  336. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: true, card: card, condition: Condition));
  337. }
  338. return cardEffects;
  339. }
  340. }
  341. }