BT5_109.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Mega Digimon Fusion
  7. namespace DCGO.CardEffects.BT5
  8. {
  9. public class BT5_109 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Main
  15. if (timing == EffectTiming.OptionSkill)
  16. {
  17. ActivateClass activateClass = new ActivateClass();
  18. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  19. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  20. cardEffects.Add(activateClass);
  21. string EffectDiscription()
  22. {
  23. return "[Main] The next time one of your Digimon digivolves from level 6 to level 7 this turn, reduce the memory cost of the digivolution by 6. At the end of the turn, return the Digimon that digivolved with this effect to the bottom of its owner's deck. Trash all of the digivolution cards of that Digimon.";
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  28. }
  29. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  30. {
  31. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  32. yield return new WaitForSeconds(0.2f);
  33. ActivateClass activateClass1 = new ActivateClass();
  34. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  35. activateClass1.SetUpICardEffect("Digivolution Cost -6 and add self bounce", CanUseCondition1, card);
  36. activateClass1.SetUpActivateClass(CanActivateCondition, ActivateCoroutine1, -1, false, EffectDescription1());
  37. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect);
  38. ActivateClass activateClass2 = new ActivateClass();
  39. Func<EffectTiming, ICardEffect> getCardEffect1 = GetCardEffect1;
  40. activateClass2.SetUpICardEffect("Remove Effect", CanUseCondition1, card);
  41. activateClass2.SetUpActivateClass(null, ActivateCoroutine2, -1, false, "");
  42. activateClass2.SetIsBackgroundProcess(true);
  43. CardEffectCommons.AddEffectToPlayer(effectDuration: EffectDuration.UntilEachTurnEnd, card: card, cardEffect: null, timing: EffectTiming.None, getCardEffect: getCardEffect1);
  44. #region Reduce evo cost
  45. string EffectDescription1()
  46. {
  47. return "Reduce the memory cost of the digivolution by 6.";
  48. }
  49. bool PermanentCondition(Permanent targetPermanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card)
  52. && targetPermanent.TopCard.IsLevel6;
  53. }
  54. bool CanUseCondition1(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  57. hashtable: hashtable,
  58. permanentCondition: PermanentCondition,
  59. cardCondition: null))
  60. {
  61. return true;
  62. }
  63. return false;
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. return true;
  68. }
  69. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  70. {
  71. Permanent playedPermanent = null;
  72. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  73. ChangeCostClass changeCostClass = new ChangeCostClass();
  74. changeCostClass.SetUpICardEffect("Digivolution Cost -6 and add self bounce", CanUseCondition3, card);
  75. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true); card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  76. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable1));
  77. bool CanUseCondition3(Hashtable hashtable)
  78. {
  79. return true;
  80. }
  81. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  82. {
  83. if (CardSourceCondition(cardSource))
  84. {
  85. if (RootCondition(root))
  86. {
  87. if (PermanentsCondition(targetPermanents))
  88. {
  89. Cost -= 6;
  90. }
  91. }
  92. }
  93. return Cost;
  94. }
  95. bool PermanentsCondition(List<Permanent> targetPermanents)
  96. {
  97. if (targetPermanents != null)
  98. {
  99. playedPermanent = targetPermanents[0];
  100. if (targetPermanents.Count(PermanentCondition) >= 1)
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. bool CardSourceCondition(CardSource cardSource)
  108. {
  109. return cardSource.HasLevel
  110. && cardSource.Level == 7;
  111. }
  112. bool RootCondition(SelectCardEffect.Root root)
  113. {
  114. return true;
  115. }
  116. bool isUpDown()
  117. {
  118. return true;
  119. }
  120. ActivateClass activateClass3 = new ActivateClass();
  121. activateClass3.SetUpICardEffect("Bottom deck the Digimon", CanUseCondition2, playedPermanent.TopCard);
  122. activateClass3.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine3, -1, false, EffectDiscription2());
  123. activateClass3.SetEffectSourcePermanent(playedPermanent);
  124. playedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect2);
  125. #region Bot deck end of turn
  126. if (!playedPermanent.TopCard.CanNotBeAffected(activateClass))
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(playedPermanent));
  129. }
  130. string EffectDiscription2()
  131. {
  132. return "[End of Your Turn] Return the Digimon that digivolved with this effect to the bottom of its owner's deck. (Trash all of the digivolution cards of that Digimon.)";
  133. }
  134. bool CanUseCondition2(Hashtable hashtable1)
  135. {
  136. if (CardEffectCommons.IsOwnerTurn(card))
  137. {
  138. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(playedPermanent, playedPermanent.TopCard))
  139. {
  140. return true;
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanActivateCondition1(Hashtable hashtable1)
  146. {
  147. if (CardEffectCommons.IsPermanentExistsOnBattleArea(playedPermanent))
  148. {
  149. if (!playedPermanent.TopCard.CanNotBeAffected(activateClass))
  150. {
  151. return true;
  152. }
  153. }
  154. return false;
  155. }
  156. IEnumerator ActivateCoroutine3(Hashtable _hashtable1)
  157. {
  158. if (CardEffectCommons.IsPermanentExistsOnBattleArea(playedPermanent))
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(new DeckBottomBounceClass(
  161. new List<Permanent>() { playedPermanent },
  162. CardEffectCommons.CardEffectHashtable(activateClass3)).DeckBounce());
  163. }
  164. }
  165. ICardEffect GetCardEffect2(EffectTiming _timing)
  166. {
  167. if (_timing == EffectTiming.OnEndTurn)
  168. {
  169. return activateClass3;
  170. }
  171. return null;
  172. }
  173. #endregion
  174. }
  175. ICardEffect GetCardEffect(EffectTiming _timing)
  176. {
  177. if (_timing == EffectTiming.BeforePayCost)
  178. {
  179. return activateClass1;
  180. }
  181. return null;
  182. }
  183. IEnumerator ActivateCoroutine2(Hashtable _hashtable1)
  184. {
  185. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(
  186. hashtable: _hashtable1,
  187. permanentCondition: PermanentCondition,
  188. cardCondition: null))
  189. {
  190. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect);
  191. card.Owner.UntilEachTurnEndEffects.Remove(getCardEffect1);
  192. yield return null;
  193. }
  194. }
  195. ICardEffect GetCardEffect1(EffectTiming _timing)
  196. {
  197. if (_timing == EffectTiming.AfterPayCost)
  198. {
  199. return activateClass2;
  200. }
  201. return null;
  202. }
  203. yield return new WaitForSeconds(0.2f);
  204. #endregion
  205. }
  206. }
  207. #endregion
  208. #region Security Effect
  209. if (timing == EffectTiming.SecuritySkill)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  213. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  214. activateClass.SetIsSecurityEffect(true);
  215. cardEffects.Add(activateClass);
  216. string EffectDiscription()
  217. {
  218. return "[Security] Add this card to its owner's hand.";
  219. }
  220. bool CanUseCondition(Hashtable hashtable)
  221. {
  222. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  223. }
  224. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  225. {
  226. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  227. }
  228. }
  229. #endregion
  230. return cardEffects;
  231. }
  232. }
  233. }