BT21_098.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT21
  4. {
  5. //Ragnarok Cannon
  6. public class BT21_098 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Main
  12. if (timing == EffectTiming.OptionSkill)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect($"Delete 1 opponent's Digimon with lowest play cost and place in battle area.", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  17. cardEffects.Add(activateClass);
  18. string EffectDescription()
  19. {
  20. return "[Main] Delete 1 of your opponent's Digimon with the lowest play cost. Then, place this card in the battle area.";
  21. }
  22. bool CanSelectPermanentCondition(Permanent permanent)
  23. {
  24. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  25. CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  34. {
  35. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  36. selectPermanentEffect.SetUp(
  37. selectPlayer: card.Owner,
  38. canTargetCondition: CanSelectPermanentCondition,
  39. canTargetCondition_ByPreSelecetedList: null,
  40. canEndSelectCondition: null,
  41. maxCount: 1,
  42. canNoSelect: false,
  43. canEndNotMax: false,
  44. selectPermanentCoroutine: null,
  45. afterSelectPermanentCoroutine: null,
  46. mode: SelectPermanentEffect.Mode.Destroy,
  47. cardEffect: activateClass);
  48. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  49. }
  50. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  51. }
  52. }
  53. #endregion
  54. #region Your Turn Delay
  55. if (timing == EffectTiming.OnAllyAttack)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("Delete 1 opponent's Digimon with lowest play cost, trash security until 1 left if didn't delete", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  60. cardEffects.Add(activateClass);
  61. string EffectDescription()
  62. {
  63. return "[Your Turn] When one of your [Galacticmon] attacks, <Delay>.\n• Delete 1 of your opponent's Digimon with the lowest play cost. If this effect didn't delete, trash the top cards of your opponent's security stack so that is has 1 card left.";
  64. }
  65. bool PermanentCondition(Permanent permanent)
  66. {
  67. if (CardEffectCommons.IsOwnerPermanent(permanent, card))
  68. {
  69. return permanent.TopCard.EqualsCardName("Galacticmon");
  70. }
  71. return false;
  72. }
  73. bool CanUseCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  78. {
  79. if (CardEffectCommons.CanDeclareOptionDelayEffect(card))
  80. {
  81. return true;
  82. }
  83. }
  84. }
  85. return false;
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. if (CardEffectCommons.IsExistOnBattleArea(card))
  90. {
  91. if (card.PermanentOfThisCard().CanBeDestroyedBySkill(activateClass))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanSelectPermanentCondition(Permanent permanent)
  99. {
  100. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  101. CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  102. }
  103. IEnumerator ActivateCoroutine(Hashtable hashtable)
  104. {
  105. bool activateDelay = false;
  106. List<Permanent> deleteTargetPermanents = new List<Permanent>();
  107. bool failedToDelete = false;
  108. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  109. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  110. activateClass: activateClass,
  111. successProcess: permanents => SuccessProcess(),
  112. failureProcess: null));
  113. IEnumerator SuccessProcess()
  114. {
  115. activateDelay = true;
  116. yield return null;
  117. }
  118. if (activateDelay)
  119. {
  120. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  121. {
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermanentCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: 1,
  129. canNoSelect: false,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: null,
  132. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  133. mode: SelectPermanentEffect.Mode.Destroy,
  134. cardEffect: activateClass);
  135. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  136. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  137. {
  138. deleteTargetPermanents = permanents.Clone();
  139. yield return null;
  140. }
  141. }
  142. if (deleteTargetPermanents.Count > 0)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: deleteTargetPermanents, activateClass: activateClass, successProcess: null, failureProcess: FailureProcess));
  145. IEnumerator FailureProcess()
  146. {
  147. failedToDelete = true;
  148. yield return null;
  149. }
  150. }
  151. else
  152. {
  153. failedToDelete = true;
  154. }
  155. if (failedToDelete)
  156. {
  157. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  158. player: card.Owner.Enemy,
  159. destroySecurityCount: card.Owner.Enemy.SecurityCards.Count - 1,
  160. cardEffect: activateClass,
  161. fromTop: true).DestroySecurity());
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. #region Security
  168. if (timing == EffectTiming.SecuritySkill)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect($"Play 1 card with [VEMMON] in text from hand or trash and add this card to hand", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  173. activateClass.SetIsSecurityEffect(true);
  174. cardEffects.Add(activateClass);
  175. string EffectDescription()
  176. {
  177. return
  178. "[Security] You may play 1 card with [Vemmon] in its text and a play cost of 6 or less from your hand or trash without paying the cost. Then, add this card to the hand.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  183. }
  184. bool CanSelectCardCondition(CardSource cardSource)
  185. {
  186. return (cardSource.HasText("Vemmon")) &&
  187. cardSource.HasPlayCost &&
  188. cardSource.GetCostItself <= 6 &&
  189. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  194. bool canSelectTrash = card.Owner.TrashCards.Some(CanSelectCardCondition);
  195. if (canSelectHand || canSelectTrash)
  196. {
  197. if (canSelectHand && canSelectTrash)
  198. {
  199. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  200. {
  201. new(message: "From hand", value: true, spriteIndex: 0),
  202. new(message: "From trash", value: false, spriteIndex: 1),
  203. };
  204. string selectPlayerMessage = "From which area do you play a card?";
  205. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  206. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  207. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  208. notSelectPlayerMessage: notSelectPlayerMessage);
  209. }
  210. else
  211. {
  212. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  213. }
  214. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  215. .WaitForEndSelect());
  216. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  217. List<CardSource> selectedCards = new List<CardSource>();
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCards.Add(cardSource);
  221. yield return null;
  222. }
  223. if (fromHand)
  224. {
  225. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  226. selectHandEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectCardCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. isShowOpponent: true,
  235. selectCardCoroutine: SelectCardCoroutine,
  236. afterSelectCardCoroutine: null,
  237. mode: SelectHandEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  240. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  241. yield return StartCoroutine(selectHandEffect.Activate());
  242. }
  243. else
  244. {
  245. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  246. selectCardEffect.SetUp(
  247. canTargetCondition: CanSelectCardCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. canNoSelect: () => true,
  251. selectCardCoroutine: SelectCardCoroutine,
  252. afterSelectCardCoroutine: null,
  253. message: "Select 1 card to play.",
  254. maxCount: 1,
  255. canEndNotMax: false,
  256. isShowOpponent: true,
  257. mode: SelectCardEffect.Mode.Custom,
  258. root: SelectCardEffect.Root.Trash,
  259. customRootCardList: null,
  260. canLookReverseCard: true,
  261. selectPlayer: card.Owner,
  262. cardEffect: activateClass);
  263. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  264. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  265. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  266. }
  267. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  268. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  269. root: fromHand ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash,
  270. activateETB: true));
  271. }
  272. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  273. }
  274. }
  275. #endregion
  276. return cardEffects;
  277. }
  278. }
  279. }