BT19_037.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT19
  6. {
  7. public class BT19_037 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Blast Digivolve
  13. if (timing == EffectTiming.OnCounterTiming)
  14. {
  15. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  16. }
  17. #endregion
  18. #region On Play
  19. if (timing == EffectTiming.OnEnterFieldAnyone)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("If it's your turn, you may use 1 single-color Option", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  24. cardEffects.Add(activateClass);
  25. string EffectDescription()
  26. {
  27. return "[On Play] If it's your turn, you may use 1 single-color Option card with a cost of 5 or less from your hand without paying the cost. If it's your opponent's turn, 1 of their Digimon gains <Security Attack -1> and can't activate effects for the turn.";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  32. }
  33. bool CanSelectOptionCard(CardSource cardSource)
  34. {
  35. return cardSource.OptionCardColors.Count == 1
  36. && cardSource.GetCostItself <= 5
  37. && !cardSource.CanNotPlayThisOption;
  38. }
  39. bool PermanentCondition(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  42. {
  43. return true;
  44. }
  45. return false;
  46. }
  47. bool CanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. if (card.Owner.HandCards.Count(CanSelectOptionCard) >= 1 && CardEffectCommons.IsOwnerTurn(card))
  54. {
  55. List<CardSource> selectedCards = new List<CardSource>();
  56. int maxCount = 1;
  57. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  58. selectHandEffect.SetUp(
  59. selectPlayer: card.Owner,
  60. canTargetCondition: CanSelectOptionCard,
  61. canTargetCondition_ByPreSelecetedList: null,
  62. canEndSelectCondition: null,
  63. maxCount: maxCount,
  64. canNoSelect: true,
  65. canEndNotMax: false,
  66. isShowOpponent: true,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. mode: SelectHandEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. selectHandEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  72. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  73. yield return StartCoroutine(selectHandEffect.Activate());
  74. IEnumerator SelectCardCoroutine(CardSource cardSource)
  75. {
  76. selectedCards.Add(cardSource);
  77. yield return null;
  78. }
  79. yield return ContinuousController.instance.StartCoroutine(
  80. CardEffectCommons.PlayOptionCards(
  81. cardSources: selectedCards,
  82. activateClass: activateClass,
  83. payCost: false,
  84. root: SelectCardEffect.Root.Hand));
  85. }
  86. if (CardEffectCommons.IsOpponentTurn(card))
  87. {
  88. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: PermanentCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: maxCount,
  96. canNoSelect: false,
  97. canEndNotMax: false,
  98. selectPermanentCoroutine: SelectPermanentCoroutine,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.Custom,
  101. cardEffect: activateClass);
  102. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -1 and effects", "The opponent is selecting 1 Digimon that will get Security Attack -1.");
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  105. {
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  107. Permanent selectedPermanent = permanent;
  108. if (selectedPermanent != null)
  109. {
  110. DisableEffectClass invalidationClass = new DisableEffectClass();
  111. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition1, card);
  112. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  113. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => invalidationClass);
  114. bool CanUseCondition1(Hashtable hashtable)
  115. {
  116. return true;
  117. }
  118. bool InvalidateCondition(ICardEffect cardEffect)
  119. {
  120. if (selectedPermanent.TopCard != null)
  121. {
  122. if (cardEffect != null)
  123. {
  124. if (cardEffect.EffectSourceCard != null)
  125. {
  126. if (isExistOnField(cardEffect.EffectSourceCard))
  127. {
  128. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  129. {
  130. if (cardEffect.IsWhenDigivolving)
  131. {
  132. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  133. {
  134. return true;
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return false;
  143. }
  144. }
  145. }
  146. }
  147. }
  148. }
  149. #endregion
  150. #region When Digivolving
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("If it's your turn, you may use 1 single-color Option", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  156. cardEffects.Add(activateClass);
  157. string EffectDescription()
  158. {
  159. return "[When Digivolving] If it's your turn, you may use 1 single-color Option card with a cost of 5 or less from your hand without paying the cost. If it's your opponent's turn, 1 of their Digimon gains <Security Attack -1> and can't activate effects for the turn.";
  160. }
  161. bool CanUseCondition(Hashtable hashtable)
  162. {
  163. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  164. {
  165. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  166. {
  167. return true;
  168. }
  169. }
  170. return false;
  171. }
  172. bool CanSelectOptionCard(CardSource cardSource)
  173. {
  174. if (cardSource.IsOption)
  175. {
  176. if (cardSource.CardColors.Count == 1 && cardSource.GetCostItself <= 5)
  177. {
  178. if (!cardSource.CanNotPlayThisOption)
  179. {
  180. return true;
  181. }
  182. }
  183. }
  184. return false;
  185. }
  186. bool PermanentCondition(Permanent permanent)
  187. {
  188. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  189. {
  190. return true;
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  197. }
  198. IEnumerator ActivateCoroutine(Hashtable hashtable)
  199. {
  200. if (card.Owner.HandCards.Count(CanSelectOptionCard) >= 1 && CardEffectCommons.IsOwnerTurn(card))
  201. {
  202. List<CardSource> selectedCards = new List<CardSource>();
  203. int maxCount = 1;
  204. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  205. selectHandEffect.SetUp(
  206. selectPlayer: card.Owner,
  207. canTargetCondition: CanSelectOptionCard,
  208. canTargetCondition_ByPreSelecetedList: null,
  209. canEndSelectCondition: null,
  210. maxCount: maxCount,
  211. canNoSelect: true,
  212. canEndNotMax: false,
  213. isShowOpponent: true,
  214. selectCardCoroutine: SelectCardCoroutine,
  215. afterSelectCardCoroutine: null,
  216. mode: SelectHandEffect.Mode.Custom,
  217. cardEffect: activateClass);
  218. selectHandEffect.SetUpCustomMessage("Select 1 option card to use.", "The opponent is selecting 1 option card to use.");
  219. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  220. yield return StartCoroutine(selectHandEffect.Activate());
  221. IEnumerator SelectCardCoroutine(CardSource cardSource)
  222. {
  223. selectedCards.Add(cardSource);
  224. yield return null;
  225. }
  226. yield return ContinuousController.instance.StartCoroutine(
  227. CardEffectCommons.PlayOptionCards(
  228. cardSources: selectedCards,
  229. activateClass: activateClass,
  230. payCost: false,
  231. root: SelectCardEffect.Root.Hand));
  232. }
  233. if (CardEffectCommons.IsOpponentTurn(card))
  234. {
  235. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  236. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  237. selectPermanentEffect.SetUp(
  238. selectPlayer: card.Owner,
  239. canTargetCondition: PermanentCondition,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canEndSelectCondition: null,
  242. maxCount: maxCount,
  243. canNoSelect: false,
  244. canEndNotMax: false,
  245. selectPermanentCoroutine: SelectPermanentCoroutine,
  246. afterSelectPermanentCoroutine: null,
  247. mode: SelectPermanentEffect.Mode.Custom,
  248. cardEffect: activateClass);
  249. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -1 and effects", "The opponent is selecting 1 Digimon that will get Security Attack -1.");
  250. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  251. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  252. {
  253. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  254. Permanent selectedPermanent = permanent;
  255. if (selectedPermanent != null)
  256. {
  257. DisableEffectClass invalidationClass = new DisableEffectClass();
  258. invalidationClass.SetUpICardEffect("Ignore [When Digivolving] Effect", CanUseCondition1, card);
  259. invalidationClass.SetUpDisableEffectClass(DisableCondition: InvalidateCondition);
  260. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => invalidationClass);
  261. bool CanUseCondition1(Hashtable hashtable)
  262. {
  263. return true;
  264. }
  265. bool InvalidateCondition(ICardEffect cardEffect)
  266. {
  267. if (selectedPermanent.TopCard != null)
  268. {
  269. if (cardEffect != null)
  270. {
  271. if (cardEffect.EffectSourceCard != null)
  272. {
  273. if (isExistOnField(cardEffect.EffectSourceCard))
  274. {
  275. if (cardEffect.EffectSourceCard.PermanentOfThisCard() == selectedPermanent)
  276. {
  277. if (cardEffect.IsWhenDigivolving)
  278. {
  279. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  280. {
  281. return true;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. return false;
  290. }
  291. }
  292. }
  293. }
  294. }
  295. }
  296. #endregion
  297. #region Inherit
  298. if (timing == EffectTiming.OnAllyAttack)
  299. {
  300. ActivateClass activateClass = new ActivateClass();
  301. activateClass.SetUpICardEffect("DP -4000", CanUseCondition, card);
  302. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  303. activateClass.SetIsInheritedEffect(true);
  304. cardEffects.Add(activateClass);
  305. string EffectDiscription()
  306. {
  307. return "[When Attacking] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  308. }
  309. bool CanSelectPermanentCondition(Permanent permanent)
  310. {
  311. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  312. }
  313. bool CanUseCondition(Hashtable hashtable)
  314. {
  315. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  316. }
  317. bool CanActivateCondition(Hashtable hashtable)
  318. {
  319. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  320. {
  321. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  322. {
  323. return true;
  324. }
  325. }
  326. return false;
  327. }
  328. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  329. {
  330. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  331. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  332. selectPermanentEffect.SetUp(
  333. selectPlayer: card.Owner,
  334. canTargetCondition: CanSelectPermanentCondition,
  335. canTargetCondition_ByPreSelecetedList: null,
  336. canEndSelectCondition: null,
  337. maxCount: maxCount,
  338. canNoSelect: false,
  339. canEndNotMax: false,
  340. selectPermanentCoroutine: SelectPermanentCoroutine,
  341. afterSelectPermanentCoroutine: null,
  342. mode: SelectPermanentEffect.Mode.Custom,
  343. cardEffect: activateClass);
  344. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.", "The opponent is selecting 1 Digimon that will get DP -4000.");
  345. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  346. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  347. {
  348. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -4000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  349. }
  350. }
  351. }
  352. #endregion
  353. return cardEffects;
  354. }
  355. }
  356. }