BT17_097.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_097 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Digivolve into level 5 or higher [Free] trait Digimon",
  17. CanUseCondition, card);
  18. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  19. cardEffects.Add(activateClass);
  20. string EffectDescription()
  21. {
  22. return
  23. "[Main] 1 of your Digimon may digivolve into a level 5 or higher Digimon card with the [Free] trait in your hand with the digivolution cost reduced by 4. Then, place this card in the battle area.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  28. }
  29. bool CanSelectHandCardCondition(CardSource cardSource)
  30. {
  31. return cardSource.IsDigimon &&
  32. cardSource.Level >= 5 &&
  33. cardSource.CardTraits.Contains("Free");
  34. }
  35. bool CanSelectOwnPermanentCondition(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  38. card.Owner.HandCards.Where(CanSelectHandCardCondition).Any(cardSource =>
  39. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  40. }
  41. IEnumerator ActivateCoroutine(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnPermanentCondition))
  44. {
  45. Permanent selectedPermanent = null;
  46. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  47. selectPermanentEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: CanSelectOwnPermanentCondition,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: 1,
  53. canNoSelect: true,
  54. canEndNotMax: false,
  55. selectPermanentCoroutine: SelectPermanentCoroutine,
  56. afterSelectPermanentCoroutine: null,
  57. mode: SelectPermanentEffect.Mode.Custom,
  58. cardEffect: activateClass);
  59. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.",
  60. "The opponent is selecting 1 Digimon that will digivolve.");
  61. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  62. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  63. {
  64. selectedPermanent = permanent;
  65. yield return null;
  66. }
  67. if (selectedPermanent != null)
  68. {
  69. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  70. targetPermanent: selectedPermanent,
  71. cardCondition: CanSelectHandCardCondition,
  72. payCost: true,
  73. reduceCostTuple: (reduceCost: 4, reduceCostCardCondition: null),
  74. fixedCostTuple: null,
  75. ignoreDigivolutionRequirementFixedCost: -1,
  76. isHand: true,
  77. activateClass: activateClass,
  78. successProcess: null));
  79. }
  80. }
  81. yield return ContinuousController.instance.StartCoroutine(
  82. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  83. }
  84. }
  85. #endregion
  86. #region Delay Effect
  87. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect(
  91. "Digivolve into a Digimon card with [Imperialdramon] in its name in your hand to prevent deletion",
  92. CanUseCondition, card);
  93. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  94. activateClass.SetHashString("DigivolveIntoImperialdramon_BT17_097");
  95. cardEffects.Add(activateClass);
  96. string EffectDescription()
  97. {
  98. return
  99. "[All Turns] When one of your Digimon with the [Free] trait would be deleted other than by one of your effects, [Delay] • By digivolving that Digimon into a Digimon card with [Imperialdramon] in its name in your hand without paying the cost, prevent that deletion.";
  100. }
  101. bool CanUseCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.CanDeclareOptionDelayEffect(card) &&
  104. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, IsOwnerPermanentCondition) &&
  105. !CardEffectCommons.IsByEffect(hashtable,
  106. cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  107. }
  108. bool CanSelectHandCardCondition(CardSource cardSource)
  109. {
  110. return cardSource.IsDigimon &&
  111. cardSource.ContainsCardName("Imperialdramon");
  112. }
  113. bool IsOwnerPermanentCondition(Permanent permanent)
  114. {
  115. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  116. permanent.TopCard.ContainsTraits("Free") &&
  117. card.Owner.HandCards.Where(CanSelectHandCardCondition).Any(cardSource =>
  118. cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass));
  119. }
  120. bool IsOwnerPermanentToBeDeletedCondition(Permanent permanent)
  121. {
  122. return IsOwnerPermanentCondition(permanent) && permanent.willBeRemoveField;
  123. }
  124. IEnumerator ActivateCoroutine(Hashtable hashtable)
  125. {
  126. yield return ContinuousController.instance.StartCoroutine(
  127. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  128. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  129. activateClass: activateClass, successProcess: permanents => SuccessProcess(),
  130. failureProcess: null));
  131. }
  132. IEnumerator SuccessProcess()
  133. {
  134. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentToBeDeletedCondition))
  135. {
  136. Permanent selectedPermanent = null;
  137. int maxCount = Math.Min(1,
  138. CardEffectCommons.MatchConditionPermanentCount(IsOwnerPermanentToBeDeletedCondition));
  139. SelectPermanentEffect selectPermanentEffect =
  140. GManager.instance.GetComponent<SelectPermanentEffect>();
  141. selectPermanentEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: IsOwnerPermanentToBeDeletedCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: maxCount,
  147. canNoSelect: true,
  148. canEndNotMax: false,
  149. selectPermanentCoroutine: SelectPermanentCoroutine,
  150. afterSelectPermanentCoroutine: null,
  151. mode: SelectPermanentEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. selectPermanentEffect.SetUpCustomMessage(
  154. "Select 1 Digimon to digivolve.",
  155. "The opponent is selecting 1 Digimon to digivolve.");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  158. {
  159. selectedPermanent = permanent;
  160. yield return null;
  161. }
  162. if (selectedPermanent != null)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  165. targetPermanent: selectedPermanent,
  166. cardCondition: CanSelectHandCardCondition,
  167. payCost: false,
  168. reduceCostTuple: null,
  169. fixedCostTuple: null,
  170. ignoreDigivolutionRequirementFixedCost: -1,
  171. isHand: true,
  172. activateClass: activateClass,
  173. successProcess: null));
  174. selectedPermanent.willBeRemoveField = false;
  175. selectedPermanent.HideDeleteEffect();
  176. }
  177. }
  178. }
  179. }
  180. #endregion
  181. #region Security Effect
  182. if (timing == EffectTiming.SecuritySkill)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect(
  186. $"Play 1 [Davis Motomiya] or [Ken Ichijoji] from hand or trash and place this card in the battle area",
  187. CanUseCondition, card);
  188. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  189. activateClass.SetIsSecurityEffect(true);
  190. cardEffects.Add(activateClass);
  191. string EffectDescription()
  192. {
  193. return
  194. "[Security] You may play 1 Tamer card with [Davis Motomiya]/[Ken Ichijoji] in its name from your hand or trash without paying the cost. Then, place this card in the battle area.";
  195. }
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  199. }
  200. bool CanSelectCardCondition(CardSource cardSource)
  201. {
  202. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  203. {
  204. if (cardSource.IsTamer)
  205. {
  206. return cardSource.ContainsCardName("Davis Motomiya") ||
  207. cardSource.ContainsCardName("DavisMotomiya") ||
  208. cardSource.ContainsCardName("Ken Ichijoji") ||
  209. cardSource.ContainsCardName("KenIchijoji");
  210. }
  211. }
  212. return false;
  213. }
  214. IEnumerator ActivateCoroutine(Hashtable hashtable)
  215. {
  216. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  217. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  218. if (canSelectHand || canSelectTrash)
  219. {
  220. if (canSelectHand && canSelectTrash)
  221. {
  222. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  223. {
  224. new(message: "From hand", value: true, spriteIndex: 0),
  225. new(message: "From trash", value: false, spriteIndex: 1),
  226. };
  227. string selectPlayerMessage = "From which area do you play a card?";
  228. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  229. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  230. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  231. notSelectPlayerMessage: notSelectPlayerMessage);
  232. }
  233. else
  234. {
  235. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  236. }
  237. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  238. .WaitForEndSelect());
  239. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  240. List<CardSource> selectedCards = new List<CardSource>();
  241. IEnumerator SelectCardCoroutine(CardSource cardSource)
  242. {
  243. selectedCards.Add(cardSource);
  244. yield return null;
  245. }
  246. if (fromHand)
  247. {
  248. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  249. selectHandEffect.SetUp(
  250. selectPlayer: card.Owner,
  251. canTargetCondition: CanSelectCardCondition,
  252. canTargetCondition_ByPreSelecetedList: null,
  253. canEndSelectCondition: null,
  254. maxCount: 1,
  255. canNoSelect: true,
  256. canEndNotMax: false,
  257. isShowOpponent: true,
  258. selectCardCoroutine: SelectCardCoroutine,
  259. afterSelectCardCoroutine: null,
  260. mode: SelectHandEffect.Mode.Custom,
  261. cardEffect: activateClass);
  262. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  263. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  264. yield return StartCoroutine(selectHandEffect.Activate());
  265. }
  266. else
  267. {
  268. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  269. selectCardEffect.SetUp(
  270. canTargetCondition: CanSelectCardCondition,
  271. canTargetCondition_ByPreSelecetedList: null,
  272. canEndSelectCondition: null,
  273. canNoSelect: () => true,
  274. selectCardCoroutine: SelectCardCoroutine,
  275. afterSelectCardCoroutine: null,
  276. message: "Select 1 card to play.",
  277. maxCount: 1,
  278. canEndNotMax: false,
  279. isShowOpponent: true,
  280. mode: SelectCardEffect.Mode.Custom,
  281. root: SelectCardEffect.Root.Trash,
  282. customRootCardList: null,
  283. canLookReverseCard: true,
  284. selectPlayer: card.Owner,
  285. cardEffect: activateClass);
  286. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  287. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  288. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  289. }
  290. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  291. if (!fromHand)
  292. {
  293. root = SelectCardEffect.Root.Trash;
  294. }
  295. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  296. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: root,
  297. activateETB: true));
  298. }
  299. yield return ContinuousController.instance.StartCoroutine(
  300. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  301. }
  302. }
  303. #endregion
  304. return cardEffects;
  305. }
  306. }
  307. }