BT16_100.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_100 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.HasText("Pulsemon") && (permanent.IsDigimon || permanent.IsTamer)))
  22. {
  23. return true;
  24. }
  25. return false;
  26. }
  27. bool CardCondition(CardSource cardSource)
  28. {
  29. if (cardSource == card)
  30. {
  31. return true;
  32. }
  33. return false;
  34. }
  35. }
  36. #endregion
  37. #region Cost reduction
  38. if (timing == EffectTiming.BeforePayCost)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("Trash security cards until you have 3 left to reduce the cost of this card by 2 for each card trashed.", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "When you would use this card, by trashing the top card of your security stack until you have 3 security cards left, reduce the use cost by 2 for each card trashed.";
  47. }
  48. bool CardCondition(CardSource cardSource)
  49. {
  50. if (cardSource == card)
  51. {
  52. if (CardEffectCommons.IsExistOnHand(cardSource))
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  62. {
  63. return true;
  64. }
  65. return false;
  66. }
  67. bool CanActivateCondition(Hashtable hashtable)
  68. {
  69. if (card.Owner.SecurityCards.Count >= 4)
  70. {
  71. return true;
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (card.Owner.SecurityCards.Count >= 4)
  78. {
  79. bool CanNoSelect =
  80. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable) != null &&
  81. card.PayingCost(
  82. CardEffectCommons.GetPlayCardClassFromHashtable(_hashtable).Root,
  83. null,
  84. checkAvailability: false)
  85. <= card.Owner.MaxMemoryCost;
  86. if (card.Owner.SecurityCards.Count >= 4)
  87. {
  88. int count = 0;
  89. while (card.Owner.SecurityCards.Count > 3)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  92. player: card.Owner,
  93. destroySecurityCount: 1,
  94. cardEffect: activateClass,
  95. fromTop: true).DestroySecurity());
  96. count++;
  97. }
  98. if (count >= 1)
  99. {
  100. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  101. ChangeCostClass changeCostClass = new ChangeCostClass();
  102. changeCostClass.SetUpICardEffect("Trash security cards until you have 3 left to reduce the cost of this card by 2 for each card trashed.", CanUseCondition1, card);
  103. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  104. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  105. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  106. bool CanUseCondition1(Hashtable hashtable)
  107. {
  108. return true;
  109. }
  110. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  111. {
  112. if (CardSourceCondition(cardSource))
  113. {
  114. if (RootCondition(root))
  115. {
  116. if (PermanentsCondition(targetPermanents))
  117. {
  118. Cost -= 2 * count;
  119. }
  120. }
  121. }
  122. return Cost;
  123. }
  124. bool PermanentsCondition(List<Permanent> targetPermanents)
  125. {
  126. if (targetPermanents == null)
  127. {
  128. return true;
  129. }
  130. else
  131. {
  132. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. bool CardSourceCondition(CardSource cardSource)
  140. {
  141. if (cardSource != null)
  142. {
  143. if (cardSource == card)
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. bool RootCondition(SelectCardEffect.Root root)
  151. {
  152. return true;
  153. }
  154. bool isUpDown()
  155. {
  156. return true;
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163. #endregion
  164. #region Main
  165. if (timing == EffectTiming.OptionSkill)
  166. {
  167. ActivateClass activateClass = new ActivateClass();
  168. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  169. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  170. cardEffects.Add(activateClass);
  171. string EffectDiscription()
  172. {
  173. return "[Main] Delete 1 of your opponent's level 5 or lower Digimon. Then, if you have 2 or fewer security cards, place this card at the bottom of your security stack.";
  174. }
  175. bool CanSelectPermanentCondition(Permanent permanent)
  176. {
  177. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  178. {
  179. if (permanent.TopCard.HasLevel && permanent.TopCard.Level <= 5 && permanent.TopCard.IsDigimon)
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool CanUseCondition(Hashtable hashtable)
  187. {
  188. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  189. }
  190. IEnumerator ActivateCoroutine(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  193. {
  194. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  195. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  196. selectPermanentEffect.SetUp(
  197. selectPlayer: card.Owner,
  198. canTargetCondition: CanSelectPermanentCondition,
  199. canTargetCondition_ByPreSelecetedList: null,
  200. canEndSelectCondition: null,
  201. maxCount: maxCount,
  202. canNoSelect: false,
  203. canEndNotMax: false,
  204. selectPermanentCoroutine: null,
  205. afterSelectPermanentCoroutine: null,
  206. mode: SelectPermanentEffect.Mode.Destroy,
  207. cardEffect: activateClass);
  208. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  209. }
  210. if (card.Owner.SecurityCards.Count <= 2)
  211. {
  212. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, toTop: false));
  213. }
  214. }
  215. }
  216. #endregion
  217. #region Security Skill
  218. if (timing == EffectTiming.SecuritySkill)
  219. {
  220. ActivateClass activateClass = new ActivateClass();
  221. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  222. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  223. activateClass.SetIsSecurityEffect(true);
  224. cardEffects.Add(activateClass);
  225. string EffectDiscription()
  226. {
  227. return "[Main] 1 of your opponent's Digimon gets -15000 DP for the turn.";
  228. }
  229. bool CanSelectPermanentCondition(Permanent permanent)
  230. {
  231. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  232. }
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  238. {
  239. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  240. {
  241. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  242. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  243. selectPermanentEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition: CanSelectPermanentCondition,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. maxCount: maxCount,
  249. canNoSelect: false,
  250. canEndNotMax: false,
  251. selectPermanentCoroutine: SelectPermanentCoroutine,
  252. afterSelectPermanentCoroutine: null,
  253. mode: SelectPermanentEffect.Mode.Custom,
  254. cardEffect: activateClass);
  255. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -15000.", "The opponent is selecting 1 Digimon that will get DP -15000.");
  256. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  257. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  258. {
  259. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -15000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  260. }
  261. }
  262. }
  263. }
  264. #endregion
  265. return cardEffects;
  266. }
  267. }
  268. }