BT21_062.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition) >= 4)
  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("Prevent this Digimon from leaving play", CanUseCondition, card);
  278. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  279. activateClass.SetHashString("Substitute_BT21_062");
  280. cardEffects.Add(activateClass);
  281. string EffectDiscription()
  282. {
  283. return "[All Turns] When this Digimon would leave the battle area, by placing 4 [Vemmon] from this Digimon's digivolution cards at the bottom of their owners' decks, prevent it from leaving play.";
  284. }
  285. bool CanSelectCardCondition(CardSource cardSource)
  286. {
  287. return cardSource.EqualsCardName("Vemmon");
  288. }
  289. bool CanUseCondition(Hashtable hashtable)
  290. {
  291. if (CardEffectCommons.IsExistOnBattleArea(card))
  292. {
  293. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  294. {
  295. return true;
  296. }
  297. }
  298. return false;
  299. }
  300. bool CanActivateCondition(Hashtable hashtable)
  301. {
  302. if (CardEffectCommons.IsExistOnBattleArea(card))
  303. {
  304. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 4)
  305. {
  306. return true;
  307. }
  308. }
  309. return false;
  310. }
  311. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  312. {
  313. if (CardEffectCommons.IsExistOnBattleArea(card))
  314. {
  315. Permanent selectedPermanent = card.PermanentOfThisCard();
  316. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 4)
  317. {
  318. List<CardSource> selectedCards = new List<CardSource>();
  319. int maxCount = 4;
  320. bool returnedToLibrary = false;
  321. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  322. selectCardEffect.SetUp(
  323. canTargetCondition: CanSelectCardCondition,
  324. canTargetCondition_ByPreSelecetedList: null,
  325. canEndSelectCondition: null,
  326. canNoSelect: () => true,
  327. selectCardCoroutine: SelectCardCoroutine,
  328. afterSelectCardCoroutine: null,
  329. message: "Select digivolution cards to return to the bottom of deck\n(cards will be placed back to the bottom of the deck so that cards with lower numbers are on top).",
  330. maxCount: maxCount,
  331. canEndNotMax: false,
  332. isShowOpponent: true,
  333. mode: SelectCardEffect.Mode.Custom,
  334. root: SelectCardEffect.Root.Custom,
  335. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  336. canLookReverseCard: true,
  337. selectPlayer: card.Owner,
  338. cardEffect: null);
  339. selectCardEffect.SetUpCustomMessage("Select digivolution cards to return to the bottom of deck.", "The opponent is selecting digivolution cards to return to the bottom of deck.");
  340. selectCardEffect.SetNotShowCard();
  341. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  342. IEnumerator SelectCardCoroutine(CardSource cardSource)
  343. {
  344. selectedCards.Add(cardSource);
  345. yield return null;
  346. }
  347. if (selectedCards.Count >= 1)
  348. {
  349. yield return ContinuousController.instance.StartCoroutine(new ReturnToLibraryBottomDigivolutionCardsClass(
  350. card.PermanentOfThisCard(),
  351. selectedCards,
  352. CardEffectCommons.CardEffectHashtable(activateClass)).ReturnToLibraryBottomDigivolutionCards());
  353. if (selectedCards.Count == 4)
  354. {
  355. returnedToLibrary = true;
  356. }
  357. }
  358. if (returnedToLibrary)
  359. {
  360. selectedPermanent.willBeRemoveField = false;
  361. selectedPermanent.HideDeleteEffect();
  362. selectedPermanent.HideHandBounceEffect();
  363. selectedPermanent.HideDeckBounceEffect();
  364. selectedPermanent.HideWillRemoveFieldEffect();
  365. }
  366. }
  367. }
  368. }
  369. }
  370. #endregion
  371. return cardEffects;
  372. }
  373. }
  374. }