P_199.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Dan Yuki
  7. namespace DCGO.CardEffects.P
  8. {
  9. public class P_199 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Start Of Your Main Phase
  15. if (timing == EffectTiming.OnStartMainPhase)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect("+3K DP", CanUseCondition, card);
  19. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Start of Your Main Phase] If you have 4 or less memory, 1 of your Digimon gets +3000 DP for the turn.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.IsExistOnBattleArea(card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card)
  32. && CardEffectCommons.IsOwnerTurn(card)
  33. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition)
  34. && card.Owner.MemoryForPlayer <= 4;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable hashtable)
  41. {
  42. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  43. {
  44. Permanent selectedPermanent = null;
  45. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  46. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  47. selectPermanentEffect.SetUp(
  48. selectPlayer: card.Owner,
  49. canTargetCondition: CanSelectPermanentCondition,
  50. canTargetCondition_ByPreSelecetedList: null,
  51. canEndSelectCondition: null,
  52. maxCount: maxCount,
  53. canNoSelect: false,
  54. canEndNotMax: false,
  55. selectPermanentCoroutine: SelectPermanentCoroutine,
  56. afterSelectPermanentCoroutine: null,
  57. mode: SelectPermanentEffect.Mode.Custom,
  58. cardEffect: activateClass);
  59. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  60. {
  61. selectedPermanent = permanent;
  62. yield return null;
  63. }
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain 3k DP.", "The opponent is selecting 1 Digimon that will gain 3k DP.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  67. targetPermanent: selectedPermanent,
  68. changeValue: 3000,
  69. effectDuration: EffectDuration.UntilEachTurnEnd,
  70. activateClass: activateClass));
  71. }
  72. }
  73. }
  74. #endregion
  75. #region Your Turn
  76. #region Reduce Cost Effect
  77. ActivateClass activateClass2 = new ActivateClass();
  78. activateClass2.SetUpICardEffect("Reduce play cost", CanUseCondition2, card);
  79. activateClass2.SetUpActivateClass(CanActivateCondition2, ActivateCoroutine2, -1, true, EffectDiscription2());
  80. string EffectDiscription2()
  81. {
  82. return "[Your Turn] When any of your Digimon cards with the [TS] trait would be played, by suspending this Tamer, reduce their play costs by 1.";
  83. }
  84. bool CardCondition(CardSource cardSource)
  85. {
  86. if (cardSource.Owner == card.Owner)
  87. {
  88. if (cardSource.IsDigimon)
  89. {
  90. if (cardSource.HasTSTraits)
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition2(Hashtable hashtable)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleArea(card))
  101. {
  102. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  103. {
  104. if (CardEffectCommons.IsOwnerTurn(card))
  105. {
  106. if (CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition))
  107. {
  108. return true;
  109. }
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. bool CanActivateCondition2(Hashtable hashtable)
  116. {
  117. if (CardEffectCommons.IsExistOnBattleArea(card))
  118. {
  119. PlayCardClass playCardClass = CardEffectCommons.GetPlayCardClassFromHashtable(hashtable);
  120. if (playCardClass != null)
  121. {
  122. if (playCardClass.PayCost)
  123. {
  124. return true;
  125. }
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine2(Hashtable _hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleArea(card))
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  135. permanents: new List<Permanent> { card.PermanentOfThisCard() },
  136. hashtable: _hashtable).Tap());
  137. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  138. ChangeCostClass changeCostClass = new ChangeCostClass();
  139. changeCostClass.SetUpICardEffect($"Play Cost -1", CanUseCondition1, card);
  140. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  141. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  142. yield return new WaitForSeconds(0.4f);
  143. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  144. bool CanUseCondition1(Hashtable hashtable)
  145. {
  146. return true;
  147. }
  148. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  149. {
  150. if (CardSourceCondition(cardSource))
  151. {
  152. if (RootCondition(root))
  153. {
  154. if (PermanentsCondition(targetPermanents))
  155. {
  156. Cost -= 1;
  157. }
  158. }
  159. }
  160. return Cost;
  161. }
  162. bool PermanentsCondition(List<Permanent> targetPermanents)
  163. {
  164. if (targetPermanents == null)
  165. {
  166. return true;
  167. }
  168. else
  169. {
  170. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  171. {
  172. return true;
  173. }
  174. }
  175. return false;
  176. }
  177. bool CardSourceCondition(CardSource cardSource)
  178. {
  179. CardSource Card = CardEffectCommons.GetCardFromHashtable(_hashtable);
  180. if (Card != null)
  181. {
  182. if (cardSource == Card)
  183. {
  184. return true;
  185. }
  186. }
  187. return false;
  188. }
  189. bool RootCondition(SelectCardEffect.Root root)
  190. {
  191. return true;
  192. }
  193. bool isUpDown()
  194. {
  195. return true;
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Before Pay Cost
  201. if (timing == EffectTiming.BeforePayCost)
  202. {
  203. cardEffects.Add(activateClass2);
  204. }
  205. #endregion
  206. #region Before Pay Cost (Not Shown)
  207. if (timing == EffectTiming.None)
  208. {
  209. ChangeCostClass changeCostClass = new ChangeCostClass();
  210. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  211. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  212. changeCostClass.SetNotShowUI(true);
  213. cardEffects.Add(changeCostClass);
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. if (!card.Owner.isYou && GManager.instance.IsAI)
  217. {
  218. return false;
  219. }
  220. if (CardEffectCommons.IsExistOnBattleArea(card))
  221. {
  222. if (CardEffectCommons.IsOwnerTurn(card))
  223. {
  224. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  225. {
  226. if (activateClass2 != null)
  227. {
  228. if (!card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass2, activateClass2.MaxCountPerTurn))
  229. {
  230. return true;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. return false;
  237. }
  238. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  239. {
  240. if (CardSourceCondition(cardSource))
  241. {
  242. if (RootCondition(root))
  243. {
  244. if (PermanentsCondition(targetPermanents))
  245. {
  246. Cost -= 1;
  247. }
  248. }
  249. }
  250. return Cost;
  251. }
  252. bool PermanentsCondition(List<Permanent> targetPermanents)
  253. {
  254. if (targetPermanents == null)
  255. {
  256. return true;
  257. }
  258. else
  259. {
  260. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  261. {
  262. return true;
  263. }
  264. }
  265. return false;
  266. }
  267. bool CardSourceCondition(CardSource cardSource)
  268. {
  269. if (cardSource.IsDigimon)
  270. {
  271. if (cardSource.HasTSTraits)
  272. {
  273. return true;
  274. }
  275. }
  276. return false;
  277. }
  278. bool RootCondition(SelectCardEffect.Root root)
  279. {
  280. return true;
  281. }
  282. bool isUpDown()
  283. {
  284. return true;
  285. }
  286. }
  287. #endregion
  288. #endregion
  289. #region Security
  290. if (timing == EffectTiming.SecuritySkill)
  291. {
  292. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  293. }
  294. #endregion
  295. return cardEffects;
  296. }
  297. }
  298. }