P_186.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Gallantmon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_186 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. if (targetPermanent.TopCard.IsLevel5)
  20. {
  21. if (targetPermanent.TopCard.ContainsCardName("WarGrowlmon"))
  22. {
  23. return true;
  24. }
  25. }
  26. return false;
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  29. permanentCondition: PermanentCondition,
  30. digivolutionCost: 3,
  31. ignoreDigivolutionRequirement: false,
  32. card: card,
  33. condition: null)
  34. );
  35. }
  36. #endregion
  37. #region Blocker
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  41. isInheritedEffect: false,
  42. card: card,
  43. condition: null));
  44. }
  45. #endregion
  46. #region Rush
  47. if (timing == EffectTiming.None)
  48. {
  49. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  50. }
  51. #endregion
  52. #endregion
  53. #region Play Cost Reduction
  54. if (timing == EffectTiming.None)
  55. {
  56. int count()
  57. {
  58. return 2 * ((card.Owner.TrashCards.Count + card.Owner.Enemy.TrashCards.Count) / 5);
  59. }
  60. ChangeCostClass changeCostClass = new ChangeCostClass();
  61. changeCostClass.SetUpICardEffect($"Play Cost -", CanUseCondition, card);
  62. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  63. changeCostClass.SetNotShowUI(true);
  64. cardEffects.Add(changeCostClass);
  65. bool CanUseCondition(Hashtable hashtable)
  66. {
  67. if (card.Owner.HandCards.Contains(card))
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(PermanentCondition))
  70. {
  71. changeCostClass.SetEffectName($"Play Cost -{count()}");
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  78. {
  79. if (CardSourceCondition(cardSource))
  80. {
  81. if (RootCondition(root))
  82. {
  83. if (PermanentsCondition(targetPermanents))
  84. {
  85. int reducedCount = count();
  86. if (reducedCount >= 1)
  87. Cost -= reducedCount;
  88. }
  89. }
  90. }
  91. return Cost;
  92. }
  93. bool PermanentCondition(Permanent Permanent)
  94. {
  95. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(Permanent))
  96. {
  97. if (Permanent.DP >= 13000)
  98. {
  99. return true;
  100. }
  101. }
  102. return false;
  103. }
  104. bool PermanentsCondition(List<Permanent> targetPermanents)
  105. {
  106. if (targetPermanents != null)
  107. {
  108. if (targetPermanents.Count(PermanentCondition) > 0)
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. bool CardSourceCondition(CardSource cardSource)
  116. {
  117. return cardSource == card;
  118. }
  119. bool RootCondition(SelectCardEffect.Root root)
  120. {
  121. return root == SelectCardEffect.Root.Hand;
  122. }
  123. bool isUpDown()
  124. {
  125. return true;
  126. }
  127. }
  128. #endregion
  129. #region Shared OP/WD
  130. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  131. {
  132. bool PermanentCondition(Permanent permanent)
  133. {
  134. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  135. {
  136. if (permanent.DP >= 13000)
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }
  143. Permanent selectedPermanent = null;
  144. bool permanentDeleted = false;
  145. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  146. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  147. selectPermanentEffect.SetUp(
  148. selectPlayer: card.Owner,
  149. canTargetCondition: PermanentCondition,
  150. canTargetCondition_ByPreSelecetedList: null,
  151. canEndSelectCondition: null,
  152. maxCount: maxCount,
  153. canNoSelect: false,
  154. canEndNotMax: false,
  155. selectPermanentCoroutine: SelectPermanentCoroutine,
  156. afterSelectPermanentCoroutine: null,
  157. mode: SelectPermanentEffect.Mode.Custom,
  158. cardEffect: activateClass);
  159. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete.");
  160. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  161. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  162. {
  163. selectedPermanent = permanent;
  164. yield return null;
  165. }
  166. if (selectedPermanent != null)
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { selectedPermanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  169. IEnumerator SuccessProcess()
  170. {
  171. permanentDeleted = true;
  172. yield return null;
  173. }
  174. }
  175. if (!permanentDeleted)
  176. {
  177. if (card.Owner.CanAddSecurity(activateClass))
  178. {
  179. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  180. }
  181. }
  182. }
  183. #endregion
  184. #region On Play
  185. if (timing == EffectTiming.OnEnterFieldAnyone)
  186. {
  187. ActivateClass activateClass = new ActivateClass();
  188. activateClass.SetUpICardEffect("Delete a digimon, if you didnt <Recovery +1 (Deck)>", CanUseCondition, card);
  189. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  190. cardEffects.Add(activateClass);
  191. string EffectDiscription()
  192. {
  193. return "[On Play] Delete 1 Digimon with 13000 DP or more. If this effect didn't delete, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  194. }
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  198. {
  199. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  200. {
  201. return true;
  202. }
  203. }
  204. return false;
  205. }
  206. bool CanActivateCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  209. }
  210. }
  211. #endregion
  212. #region When Digivolving
  213. if (timing == EffectTiming.OnEnterFieldAnyone)
  214. {
  215. ActivateClass activateClass = new ActivateClass();
  216. activateClass.SetUpICardEffect("Delete a digimon, if you didnt <Recovery +1 (Deck)>", CanUseCondition, card);
  217. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  218. cardEffects.Add(activateClass);
  219. string EffectDiscription()
  220. {
  221. return "[When Digivolving] Delete 1 Digimon with 13000 DP or more. If this effect didn't delete, <Recovery +1 (Deck)> (Place the top card of your deck on top of your security stack).";
  222. }
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  226. {
  227. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  228. {
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. bool CanActivateCondition(Hashtable hashtable)
  235. {
  236. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  237. }
  238. }
  239. #endregion
  240. return cardEffects;
  241. }
  242. }
  243. }