EX1_071.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.EX1
  7. {
  8. public class EX1_071 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  16. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  17. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  18. cardEffects.Add(ignoreColorConditionClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. return card.Owner.GetBattleAreaPermanents().Some(permanet => permanet.IsTamer);
  22. }
  23. bool CardCondition(CardSource cardSource)
  24. {
  25. return cardSource == card;
  26. }
  27. }
  28. if (timing == EffectTiming.OptionSkill)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  32. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[Main] The next time one of your Digimon digivolves this turn, you may trash 1 Digimon card in your hand of the same color as the digivolving Digimon to reduce the memory cost of the digivolution by 4.";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  45. yield return new WaitForSeconds(0.2f);
  46. ActivateClass activateClass1 = new ActivateClass();
  47. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  48. activateClass1.SetUpICardEffect("Digivolution Cost -4", CanUseCondition1, card);
  49. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDiscription1());
  50. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect);
  51. ActivateClass activateClass2 = new ActivateClass();
  52. Func<EffectTiming, ICardEffect> getCardEffect1 = GetCardEffect1;
  53. activateClass2.SetUpICardEffect("Remove Effect", CanUseCondition1, card);
  54. activateClass2.SetUpActivateClass(null, ActivateCoroutine2, -1, false, "");
  55. activateClass2.SetIsBackgroundProcess(true);
  56. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect1);
  57. string EffectDiscription1()
  58. {
  59. return "You may trash 1 Digimon card in your hand of the same color as the digivolving Digimon to reduce the memory cost of the digivolution by 4.";
  60. }
  61. bool PermanentCondition(Permanent targetPermanent)
  62. {
  63. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  64. }
  65. bool CanUseCondition1(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  68. hashtable: hashtable,
  69. permanentCondition: PermanentCondition,
  70. cardCondition: null))
  71. {
  72. return true;
  73. }
  74. return false;
  75. }
  76. bool CanActivateCondition1(Hashtable hashtable)
  77. {
  78. List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
  79. if (permanents != null)
  80. {
  81. bool CanSelectCardCondition(CardSource cardSource)
  82. {
  83. if (cardSource.IsDigimon)
  84. {
  85. List<CardColor> permanentColors = permanents
  86. .Map(permanent => permanent.TopCard.CardColors)
  87. .Flat();
  88. if (cardSource.CardColors.Some((cardColor) => permanentColors.Contains(cardColor)))
  89. {
  90. return true;
  91. }
  92. }
  93. return false;
  94. }
  95. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  96. {
  97. return true;
  98. }
  99. }
  100. return false;
  101. }
  102. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  103. {
  104. List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(_hashtable1);
  105. if (permanents != null)
  106. {
  107. bool CanSelectCardCondition(CardSource cardSource)
  108. {
  109. if (cardSource.IsDigimon)
  110. {
  111. List<CardColor> permanentColors = permanents
  112. .Map(permanent => permanent.TopCard.CardColors)
  113. .Flat();
  114. if (cardSource.CardColors.Some((cardColor) => permanentColors.Contains(cardColor)))
  115. {
  116. return true;
  117. }
  118. }
  119. return false;
  120. }
  121. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  122. {
  123. bool discarded = false;
  124. int discardCount = 1;
  125. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  126. selectHandEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectCardCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: discardCount,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. isShowOpponent: true,
  135. selectCardCoroutine: null,
  136. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  137. mode: SelectHandEffect.Mode.Discard,
  138. cardEffect: activateClass);
  139. yield return StartCoroutine(selectHandEffect.Activate());
  140. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  141. {
  142. if (cardSources.Count >= 1)
  143. {
  144. discarded = true;
  145. yield return null;
  146. }
  147. }
  148. if (discarded)
  149. {
  150. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  151. ChangeCostClass changeCostClass = new ChangeCostClass();
  152. changeCostClass.SetUpICardEffect("Digivolution Cost -4", CanUseCondition1, card);
  153. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  154. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  156. bool CanUseCondition1(Hashtable hashtable)
  157. {
  158. return true;
  159. }
  160. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  161. {
  162. if (CardSourceCondition(cardSource))
  163. {
  164. if (RootCondition(root))
  165. {
  166. if (PermanentsCondition(targetPermanents))
  167. {
  168. Cost -= 4;
  169. }
  170. }
  171. }
  172. return Cost;
  173. }
  174. bool PermanentsCondition(List<Permanent> targetPermanents)
  175. {
  176. if (targetPermanents != null)
  177. {
  178. if (targetPermanents.Count(PermanentCondition) >= 1)
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool PermanentCondition(Permanent targetPermanent)
  186. {
  187. return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent);
  188. }
  189. bool CardSourceCondition(CardSource cardSource)
  190. {
  191. return true;
  192. }
  193. bool RootCondition(SelectCardEffect.Root root)
  194. {
  195. return true;
  196. }
  197. bool isUpDown()
  198. {
  199. return true;
  200. }
  201. }
  202. }
  203. }
  204. }
  205. ICardEffect GetCardEffect(EffectTiming _timing)
  206. {
  207. if (_timing == EffectTiming.BeforePayCost)
  208. {
  209. return activateClass1;
  210. }
  211. return null;
  212. }
  213. IEnumerator ActivateCoroutine2(Hashtable _hashtable1)
  214. {
  215. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  216. hashtable: _hashtable1,
  217. permanentCondition: PermanentCondition,
  218. cardCondition: null))
  219. {
  220. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect);
  221. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect1);
  222. yield return null;
  223. }
  224. }
  225. ICardEffect GetCardEffect1(EffectTiming _timing)
  226. {
  227. if (_timing == EffectTiming.AfterPayCost)
  228. {
  229. return activateClass2;
  230. }
  231. return null;
  232. }
  233. }
  234. }
  235. if (timing == EffectTiming.SecuritySkill)
  236. {
  237. ActivateClass activateClass = new ActivateClass();
  238. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  239. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  240. activateClass.SetIsSecurityEffect(true);
  241. cardEffects.Add(activateClass);
  242. string EffectDiscription()
  243. {
  244. return "[Security] Add this card to its owner's hand.";
  245. }
  246. bool CanUseCondition(Hashtable hashtable)
  247. {
  248. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  249. }
  250. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  251. {
  252. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  253. }
  254. }
  255. return cardEffects;
  256. }
  257. }
  258. }