P_186.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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: () => false, isChangePayingCost: () => true);
  63. cardEffects.Add(changeCostClass);
  64. bool CanUseCondition(Hashtable hashtable)
  65. {
  66. if (card.Owner.HandCards.Contains(card))
  67. {
  68. if (count() >= 1)
  69. {
  70. if (CardEffectCommons.HasMatchConditionPermanent(PermanentsCondition))
  71. {
  72. changeCostClass.SetEffectName($"Play Cost -{count()}");
  73. return true;
  74. }
  75. }
  76. }
  77. return false;
  78. }
  79. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  80. {
  81. if (CardSourceCondition(cardSource))
  82. {
  83. if (RootCondition(root))
  84. {
  85. if (targetPermanents.Select(x => PermanentsCondition(x)) != null)
  86. {
  87. Cost -= count();
  88. }
  89. }
  90. }
  91. return Cost;
  92. }
  93. bool PermanentsCondition(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 CardSourceCondition(CardSource cardSource)
  105. {
  106. return cardSource == card;
  107. }
  108. bool RootCondition(SelectCardEffect.Root root)
  109. {
  110. if (root == SelectCardEffect.Root.Hand)
  111. {
  112. return true;
  113. }
  114. return false;
  115. }
  116. bool isUpDown()
  117. {
  118. return true;
  119. }
  120. }
  121. #endregion
  122. #region Shared OP/WD
  123. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  124. {
  125. bool PermanentCondition(Permanent permanent)
  126. {
  127. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  128. {
  129. if (permanent.DP >= 13000)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. Permanent permanent = null;
  137. bool permanentDeleted = false;
  138. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  139. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  140. selectPermanentEffect.SetUp(
  141. selectPlayer: card.Owner,
  142. canTargetCondition: PermanentCondition,
  143. canTargetCondition_ByPreSelecetedList: null,
  144. canEndSelectCondition: null,
  145. maxCount: maxCount,
  146. canNoSelect: false,
  147. canEndNotMax: false,
  148. selectPermanentCoroutine: SelectPermanentCoroutine,
  149. afterSelectPermanentCoroutine: null,
  150. mode: SelectPermanentEffect.Mode.Custom,
  151. cardEffect: activateClass);
  152. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete.");
  153. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  154. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  155. {
  156. Permanent selectedPermanent = permanent;
  157. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: selectedPermanent, trashCount: 4, isFromTop: false, activateClass: activateClass));
  158. }
  159. if (permanent != null)
  160. {
  161. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  162. IEnumerator SuccessProcess()
  163. {
  164. permanentDeleted = true;
  165. yield return null;
  166. }
  167. }
  168. if (permanent == null || !permanentDeleted)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  171. }
  172. }
  173. #endregion
  174. #region On Play
  175. if (timing == EffectTiming.OnEnterFieldAnyone)
  176. {
  177. ActivateClass activateClass = new ActivateClass();
  178. activateClass.SetUpICardEffect("Delete a digimon, if you didnt <Recovery +1 (Deck)>", CanUseCondition, card);
  179. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  180. cardEffects.Add(activateClass);
  181. string EffectDiscription()
  182. {
  183. 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).";
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  188. {
  189. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  190. {
  191. return true;
  192. }
  193. }
  194. return false;
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  199. }
  200. }
  201. #endregion
  202. #region When Digivolving
  203. if (timing == EffectTiming.OnEnterFieldAnyone)
  204. {
  205. ActivateClass activateClass = new ActivateClass();
  206. activateClass.SetUpICardEffect("Delete a digimon, if you didnt <Recovery +1 (Deck)>", CanUseCondition, card);
  207. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  208. cardEffects.Add(activateClass);
  209. string EffectDiscription()
  210. {
  211. 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).";
  212. }
  213. bool CanUseCondition(Hashtable hashtable)
  214. {
  215. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  216. {
  217. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  218. {
  219. return true;
  220. }
  221. }
  222. return false;
  223. }
  224. bool CanActivateCondition(Hashtable hashtable)
  225. {
  226. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  227. }
  228. }
  229. #endregion
  230. return cardEffects;
  231. }
  232. }
  233. }