P_222.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. //Rosemon
  6. namespace DCGO.CardEffects.P
  7. {
  8. public class P_222 : 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 Alternate Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.EqualsTraits("WG");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null));
  27. }
  28. #endregion
  29. #region Reduce Play Cost
  30. bool HasWingGuardiansCondition(CardSource cardSource)
  31. {
  32. return CardEffectCommons.IsExistInSecurity(cardSource) &&
  33. cardSource.EqualsCardName("Wind Guardians");
  34. }
  35. #endregion
  36. #region Before Pay Cost - Condition Effect
  37. if (timing == EffectTiming.BeforePayCost)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("If [Wind Guardians] is in your face up security cards get Play Cost -4", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "When this card would be played, if you have a face-up [Wind Guardians] security card, reduce the play cost by 4.";
  46. }
  47. bool CardCondition(CardSource cardSource)
  48. {
  49. if (cardSource == card)
  50. {
  51. if (CardEffectCommons.IsExistOnHand(cardSource))
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnHand(card))
  65. {
  66. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasWingGuardiansCondition, false))
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. if (card.Owner.CanReduceCost(null, card))
  76. {
  77. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  78. }
  79. ChangeCostClass changeCostClass = new ChangeCostClass();
  80. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition1, card);
  81. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  82. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  83. bool CanUseCondition1(Hashtable hashtable)
  84. {
  85. return true;
  86. }
  87. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  88. {
  89. if (CardSourceCondition(cardSource))
  90. {
  91. if (RootCondition(root))
  92. {
  93. if (PermanentsCondition(targetPermanents))
  94. {
  95. int targetCost = 0;
  96. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasWingGuardiansCondition, false))
  97. targetCost += 4;
  98. Cost -= targetCost;
  99. }
  100. }
  101. }
  102. return Cost;
  103. }
  104. bool PermanentsCondition(List<Permanent> targetPermanents)
  105. {
  106. if (targetPermanents == null)
  107. {
  108. return true;
  109. }
  110. else
  111. {
  112. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. bool CardSourceCondition(CardSource cardSource)
  120. {
  121. return cardSource == card;
  122. }
  123. bool RootCondition(SelectCardEffect.Root root)
  124. {
  125. return true;
  126. }
  127. bool isUpDown()
  128. {
  129. return true;
  130. }
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  132. }
  133. }
  134. #endregion
  135. #region Reduce Play Cost - Not Shown
  136. if (timing == EffectTiming.None)
  137. {
  138. ChangeCostClass changeCostClass = new ChangeCostClass();
  139. changeCostClass.SetUpICardEffect("Play Cost -4", CanUseCondition, card);
  140. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  141. changeCostClass.SetNotShowUI(true);
  142. cardEffects.Add(changeCostClass);
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. if (card.Owner.HandCards.Contains(card))
  146. {
  147. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == "If [Wind Guardians] is in your face up security cards get Play Cost -4");
  148. if (activateClass != null)
  149. {
  150. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasWingGuardiansCondition, false))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  159. {
  160. if (CardSourceCondition(cardSource))
  161. {
  162. if (RootCondition(root))
  163. {
  164. if (PermanentsCondition(targetPermanents))
  165. {
  166. int targetCount = 0;
  167. if (CardEffectCommons.HasMatchConditionOwnersSecurity(card, HasWingGuardiansCondition, false))
  168. targetCount += 4;
  169. Cost -= targetCount;
  170. }
  171. }
  172. }
  173. return Cost;
  174. }
  175. bool PermanentsCondition(List<Permanent> targetPermanents)
  176. {
  177. if (targetPermanents == null)
  178. {
  179. return true;
  180. }
  181. else
  182. {
  183. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  184. {
  185. return true;
  186. }
  187. }
  188. return false;
  189. }
  190. bool CardSourceCondition(CardSource cardSource)
  191. {
  192. if (cardSource != null)
  193. {
  194. if (cardSource == card)
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool RootCondition(SelectCardEffect.Root root)
  202. {
  203. return true;
  204. }
  205. bool isUpDown()
  206. {
  207. return true;
  208. }
  209. }
  210. #endregion
  211. #endregion
  212. #region OP/WD Shared
  213. string EffectNameShared()
  214. => "Suspend 1 Digimon";
  215. string EffectDiscriptionShared(string tag)
  216. {
  217. return $"[{tag}] You may suspend 1 Digimon";
  218. }
  219. bool SharedPermanentCondition(Permanent permanent)
  220. {
  221. return CardEffectCommons.IsExistOnBattleAreaDigimon(permanent.TopCard);
  222. }
  223. bool CanActivateConditionShared(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleArea(card);
  226. }
  227. IEnumerator ActivateCoroutineShared(Hashtable hashtable, ActivateClass activateClass)
  228. {
  229. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedPermanentCondition));
  230. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  231. selectPermanentEffect.SetUp(
  232. selectPlayer: card.Owner,
  233. canTargetCondition: SharedPermanentCondition,
  234. canTargetCondition_ByPreSelecetedList: null,
  235. canEndSelectCondition: null,
  236. maxCount: maxCount,
  237. canNoSelect: true,
  238. canEndNotMax: false,
  239. selectPermanentCoroutine: null,
  240. afterSelectPermanentCoroutine: null,
  241. mode: SelectPermanentEffect.Mode.Tap,
  242. cardEffect: activateClass);
  243. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  244. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  245. }
  246. #endregion
  247. #region On Play
  248. if (timing == EffectTiming.OnEnterFieldAnyone)
  249. {
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  252. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, true, EffectDiscriptionShared("On Play"));
  253. cardEffects.Add(activateClass);
  254. bool CanUseCondition(Hashtable hashtable)
  255. {
  256. return CardEffectCommons.IsExistOnBattleArea(card)
  257. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  258. }
  259. }
  260. #endregion
  261. #region When Digivolving
  262. if (timing == EffectTiming.OnEnterFieldAnyone)
  263. {
  264. ActivateClass activateClass = new ActivateClass();
  265. activateClass.SetUpICardEffect(EffectNameShared(), CanUseCondition, card);
  266. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => ActivateCoroutineShared(hash, activateClass), -1, true, EffectDiscriptionShared("When Digivolving"));
  267. cardEffects.Add(activateClass);
  268. bool CanUseCondition(Hashtable hashtable)
  269. {
  270. return CardEffectCommons.IsExistOnBattleArea(card)
  271. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  272. }
  273. }
  274. #endregion
  275. #region All Turns
  276. if (timing == EffectTiming.OnTappedAnyone)
  277. {
  278. ActivateClass activateClass = new ActivateClass();
  279. activateClass.SetUpICardEffect("Delete opponent's lowest DP Digimon", CanUseCondition, card);
  280. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription1());
  281. activateClass.SetHashString("P_222_AT");
  282. cardEffects.Add(activateClass);
  283. string EffectDiscription1()
  284. {
  285. return "[All Turns] [Once Per Turn] When any Digimon suspend, you may delete 1 of your opponent's lowest DP Digimon";
  286. }
  287. bool CanSelectPermanentCondition(Permanent permanent)
  288. {
  289. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  290. && CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  291. }
  292. bool CanTriggerPermanent(Permanent permanent)
  293. {
  294. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  295. }
  296. bool CanUseCondition(Hashtable hashtable)
  297. {
  298. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  299. && CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, CanTriggerPermanent);
  300. }
  301. bool CanActivateCondition(Hashtable hashtable)
  302. {
  303. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  304. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition);
  305. }
  306. IEnumerator ActivateCoroutine(Hashtable hashtable)
  307. {
  308. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  309. selectPermanentEffect.SetUp(
  310. selectPlayer: card.Owner,
  311. canTargetCondition: CanSelectPermanentCondition,
  312. canTargetCondition_ByPreSelecetedList: null,
  313. canEndSelectCondition: null,
  314. maxCount: 1,
  315. canNoSelect: false,
  316. canEndNotMax: false,
  317. selectPermanentCoroutine: null,
  318. afterSelectPermanentCoroutine: null,
  319. mode: SelectPermanentEffect.Mode.Destroy,
  320. cardEffect: activateClass);
  321. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  322. }
  323. }
  324. #endregion
  325. return cardEffects;
  326. }
  327. }
  328. }