BT21_062.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. //Galacticmon
  8. public class BT21_062 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Snatchmon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 9, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region When Digivolving
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Place 4 cards from trash to digivolution cards to use [Ragnarok Cannon]", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[When Digivolving] By placing 4 cards with [Vemmon] in their texts from your trash as this Digimon's bottom digivolution cards, you may use 1 [Ragnarok Cannon] from your hand or trash without paying the cost.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource.HasText("Vemmon"))
  37. {
  38. return true;
  39. }
  40. return false;
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  45. {
  46. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  47. {
  48. return true;
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. if (CardEffectCommons.IsExistOnBattleArea(card))
  56. {
  57. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  58. {
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. bool CanSelectCardCondition1(CardSource cardSource)
  65. {
  66. if (cardSource.EqualsCardName("Ragnarok Cannon"))
  67. {
  68. if (cardSource.HasUseCost)
  69. {
  70. if (!cardSource.CanNotPlayThisOption)
  71. {
  72. return true;
  73. }
  74. }
  75. }
  76. return false;
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  79. {
  80. if (CardEffectCommons.IsExistOnBattleArea(card))
  81. {
  82. bool added = false;
  83. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  84. {
  85. List<CardSource> selectedCards = new List<CardSource>();
  86. int maxCount = 4;
  87. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  88. selectCardEffect.SetUp(
  89. canTargetCondition: CanSelectCardCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. canNoSelect: () => true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. message: "Select 4 cards to place on bottom of digivolution cards.",
  96. maxCount: maxCount,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. mode: SelectCardEffect.Mode.Custom,
  100. root: SelectCardEffect.Root.Trash,
  101. customRootCardList: null,
  102. canLookReverseCard: true,
  103. selectPlayer: card.Owner,
  104. cardEffect: activateClass);
  105. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  106. selectCardEffect.SetUpCustomMessage("Select 4 cards to place on bottom of digivolution cards.", "The opponent is selecting 4 cards to place on bottom of digivolution cards.");
  107. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  108. IEnumerator SelectCardCoroutine(CardSource cardSource)
  109. {
  110. selectedCards.Add(cardSource);
  111. yield return null;
  112. }
  113. if (selectedCards.Count >= 4)
  114. {
  115. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  116. selectedCards,
  117. activateClass));
  118. added = true;
  119. }
  120. }
  121. if (added)
  122. {
  123. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition1) >= 1;
  124. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition1);
  125. if (canSelectHand || canSelectTrash)
  126. {
  127. if (canSelectHand && canSelectTrash)
  128. {
  129. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  130. {
  131. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  132. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  133. };
  134. string selectPlayerMessage = "From which area do you play a card?";
  135. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  136. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  137. }
  138. else
  139. {
  140. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  141. }
  142. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  143. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  144. List<CardSource> selectedCards = new List<CardSource>();
  145. IEnumerator SelectCardCoroutine(CardSource cardSource)
  146. {
  147. selectedCards.Add(cardSource);
  148. yield return null;
  149. }
  150. if (fromHand)
  151. {
  152. int maxCount = 1;
  153. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  154. selectHandEffect.SetUp(
  155. selectPlayer: card.Owner,
  156. canTargetCondition: CanSelectCardCondition1,
  157. canTargetCondition_ByPreSelecetedList: null,
  158. canEndSelectCondition: null,
  159. maxCount: maxCount,
  160. canNoSelect: true,
  161. canEndNotMax: false,
  162. isShowOpponent: true,
  163. selectCardCoroutine: SelectCardCoroutine,
  164. afterSelectCardCoroutine: null,
  165. mode: SelectHandEffect.Mode.Custom,
  166. cardEffect: activateClass);
  167. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  168. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  169. yield return StartCoroutine(selectHandEffect.Activate());
  170. }
  171. else
  172. {
  173. int maxCount = 1;
  174. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  175. selectCardEffect.SetUp(
  176. canTargetCondition: CanSelectCardCondition1,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. canNoSelect: () => true,
  180. selectCardCoroutine: SelectCardCoroutine,
  181. afterSelectCardCoroutine: null,
  182. message: "Select 1 card to play.",
  183. maxCount: maxCount,
  184. canEndNotMax: false,
  185. isShowOpponent: true,
  186. mode: SelectCardEffect.Mode.Custom,
  187. root: SelectCardEffect.Root.Trash,
  188. customRootCardList: null,
  189. canLookReverseCard: true,
  190. selectPlayer: card.Owner,
  191. cardEffect: activateClass);
  192. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  193. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  194. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  195. }
  196. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  197. if (!fromHand)
  198. {
  199. root = SelectCardEffect.Root.Trash;
  200. }
  201. yield return ContinuousController.instance.StartCoroutine(
  202. CardEffectCommons.PlayOptionCards(
  203. cardSources: selectedCards,
  204. activateClass: activateClass,
  205. payCost: false,
  206. root: root));
  207. }
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. #region Start of Your Main Phase
  214. if (timing == EffectTiming.OnStartMainPhase)
  215. {
  216. ActivateClass activateClass = new ActivateClass();
  217. activateClass.SetUpICardEffect("Delete 1 oppont Digimon", CanUseCondition, card);
  218. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  219. cardEffects.Add(activateClass);
  220. string EffectDiscription()
  221. {
  222. return "[Start of Your Main Phase] Delete 1 of your opponent's Digimon.";
  223. }
  224. bool CanSelectPermanentCondition(Permanent permanent)
  225. {
  226. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  227. }
  228. bool CanUseCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnBattleArea(card))
  231. {
  232. if (CardEffectCommons.IsOwnerTurn(card))
  233. {
  234. return true;
  235. }
  236. }
  237. return false;
  238. }
  239. bool CanActivateCondition(Hashtable hashtable)
  240. {
  241. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  242. {
  243. if (card.Owner.Enemy.GetBattleAreaDigimons().Count >= 1)
  244. {
  245. return true;
  246. }
  247. }
  248. return false;
  249. }
  250. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  251. {
  252. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  253. {
  254. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  255. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  256. selectPermanentEffect.SetUp(
  257. selectPlayer: card.Owner,
  258. canTargetCondition: CanSelectPermanentCondition,
  259. canTargetCondition_ByPreSelecetedList: null,
  260. canEndSelectCondition: null,
  261. maxCount: maxCount,
  262. canNoSelect: false,
  263. canEndNotMax: false,
  264. selectPermanentCoroutine: null,
  265. afterSelectPermanentCoroutine: null,
  266. mode: SelectPermanentEffect.Mode.Destroy,
  267. cardEffect: activateClass);
  268. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  269. }
  270. }
  271. }
  272. #endregion
  273. #region All Turns
  274. if (timing == EffectTiming.WhenRemoveField)
  275. {
  276. ActivateClass activateClass = new ActivateClass();
  277. activateClass.SetUpICardEffect("Return 4 [Vemmon] from evo cards to bottom of deck to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  278. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  279. cardEffects.Add(activateClass);
  280. string EffectDiscription()
  281. {
  282. return "[All Turns] When this Digimon would leave the battle area, by returning 4 [Vemmon] from its digivolution cards to the bottom of the deck, it doesn't leave.";
  283. }
  284. bool CanSelectVemmon(CardSource cardSource)
  285. {
  286. return cardSource.EqualsCardName("Vemmon");
  287. }
  288. bool CanUseCondition(Hashtable hashtable)
  289. {
  290. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  291. {
  292. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  293. {
  294. return true;
  295. }
  296. }
  297. return false;
  298. }
  299. bool CanActivateCondition(Hashtable hashtable)
  300. {
  301. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  302. {
  303. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectVemmon) >= 4)
  304. {
  305. return true;
  306. }
  307. }
  308. return false;
  309. }
  310. IEnumerator ActivateCoroutine(Hashtable hashtable)
  311. {
  312. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  313. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectVemmon) >= 4;
  314. if (canSelectDigivolutionCards)
  315. {
  316. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  317. selectCardEffect.SetUp(
  318. canTargetCondition: CanSelectVemmon,
  319. canTargetCondition_ByPreSelecetedList: null,
  320. canEndSelectCondition: null,
  321. canNoSelect: () => false,
  322. selectCardCoroutine: null,
  323. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  324. message: "Select 4 [Vemmon] to place at the bottom of the deck.",
  325. maxCount: 4,
  326. canEndNotMax: false,
  327. isShowOpponent: false,
  328. mode: SelectCardEffect.Mode.Custom,
  329. root: SelectCardEffect.Root.Custom,
  330. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  331. canLookReverseCard: true,
  332. selectPlayer: card.Owner,
  333. cardEffect: activateClass);
  334. selectCardEffect.SetNotShowCard();
  335. selectCardEffect.SetNotAddLog();
  336. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  337. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  338. {
  339. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddLibraryBottomCards(cardSources));
  340. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().ShowCardEffect2(cardSources, "Deck Bottom Cards", true, true));
  341. Permanent thisCardPermanent = card.PermanentOfThisCard();
  342. thisCardPermanent.willBeRemoveField = false;
  343. thisCardPermanent.HideDeleteEffect();
  344. thisCardPermanent.HideHandBounceEffect();
  345. thisCardPermanent.HideDeckBounceEffect();
  346. thisCardPermanent.HideWillRemoveFieldEffect();
  347. }
  348. }
  349. }
  350. }
  351. #endregion
  352. return cardEffects;
  353. }
  354. }
  355. }