P_186.cs 11 KB

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