BT9_112.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT9_112 : 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. int count()
  16. {
  17. return 3 * card.Owner.Enemy.GetBattleAreaPermanents().Count((permanent) => permanent.IsDigimon || permanent.IsTamer);
  18. }
  19. ChangeCostClass changeCostClass = new ChangeCostClass();
  20. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  21. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  22. changeCostClass.SetNotShowUI(true);
  23. cardEffects.Add(changeCostClass);
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return true;
  27. }
  28. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  29. {
  30. if (CardSourceCondition(cardSource))
  31. {
  32. if (RootCondition(root))
  33. {
  34. if (PermanentsCondition(targetPermanents))
  35. {
  36. Cost -= count();
  37. }
  38. }
  39. }
  40. return Cost;
  41. }
  42. bool PermanentsCondition(List<Permanent> targetPermanents)
  43. {
  44. if (targetPermanents == null)
  45. {
  46. return true;
  47. }
  48. else
  49. {
  50. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  51. {
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. bool CardSourceCondition(CardSource cardSource)
  58. {
  59. return cardSource == card;
  60. }
  61. bool RootCondition(SelectCardEffect.Root root)
  62. {
  63. return true;
  64. }
  65. bool isUpDown()
  66. {
  67. return true;
  68. }
  69. }
  70. if (timing == EffectTiming.OnEnterFieldAnyone)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("De-Digivolve 1 and delete opponent's all level 4 or lower Digimon", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[On Play] <De-Digivolve 1> all of your opponent's Digimon. Then, delete all of your opponent's level 4 or lower Digimon.";
  79. }
  80. bool PermanentCondition(Permanent permanent)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.Level <= 4)
  85. {
  86. if (permanent.TopCard.HasLevel)
  87. {
  88. return true;
  89. }
  90. }
  91. }
  92. return false;
  93. }
  94. bool CanUseCondition(Hashtable hashtable)
  95. {
  96. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  97. }
  98. bool CanActivateCondition(Hashtable hashtable)
  99. {
  100. if (CardEffectCommons.IsExistOnBattleArea(card))
  101. {
  102. if (card.Owner.Enemy.GetBattleAreaDigimons().Count() >= 1)
  103. {
  104. return true;
  105. }
  106. }
  107. return false;
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  110. {
  111. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons().Clone())
  112. {
  113. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  114. }
  115. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  116. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  117. }
  118. }
  119. if (timing == EffectTiming.OnEnterFieldAnyone)
  120. {
  121. ActivateClass activateClass = new ActivateClass();
  122. activateClass.SetUpICardEffect("De-Digivolve 1 and delete opponent's all level 4 or lower Digimon", CanUseCondition, card);
  123. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  124. cardEffects.Add(activateClass);
  125. string EffectDiscription()
  126. {
  127. return "[When Digivolving] <De-Digivolve 1> all of your opponent's Digimon. Then, delete all of your opponent's level 4 or lower Digimon.";
  128. }
  129. bool PermanentCondition(Permanent permanent)
  130. {
  131. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  132. {
  133. if (permanent.Level <= 4)
  134. {
  135. if (permanent.TopCard.HasLevel)
  136. {
  137. return true;
  138. }
  139. }
  140. }
  141. return false;
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  146. }
  147. bool CanActivateCondition(Hashtable hashtable)
  148. {
  149. if (CardEffectCommons.IsExistOnBattleArea(card))
  150. {
  151. if (card.Owner.Enemy.GetBattleAreaDigimons().Count() >= 1)
  152. {
  153. return true;
  154. }
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. foreach (Permanent permanent in card.Owner.Enemy.GetBattleAreaDigimons().Clone())
  161. {
  162. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  163. }
  164. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  165. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  166. }
  167. }
  168. if (timing == EffectTiming.OnEndTurn)
  169. {
  170. ActivateClass activateClass = new ActivateClass();
  171. activateClass.SetUpICardEffect("Delete opponent's all Digimon with the lowest play cost", CanUseCondition, card);
  172. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  173. activateClass.SetHashString("Delete_BT9_112");
  174. cardEffects.Add(activateClass);
  175. string EffectDiscription()
  176. {
  177. return "[End of Opponent's Turn][Once Per Turn] Delete all of your opponent's Digimon with the lowest play cost.";
  178. }
  179. bool PermanentCondition(Permanent permanent)
  180. {
  181. return CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  182. }
  183. bool CanUseCondition(Hashtable hashtable)
  184. {
  185. if (CardEffectCommons.IsExistOnBattleArea(card))
  186. {
  187. if (CardEffectCommons.IsOpponentTurn(card))
  188. {
  189. return true;
  190. }
  191. }
  192. return false;
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. if (CardEffectCommons.IsExistOnBattleArea(card))
  197. {
  198. return true;
  199. }
  200. return false;
  201. }
  202. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  203. {
  204. List<Permanent> destroyTargetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(PermanentCondition);
  205. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  206. }
  207. }
  208. return cardEffects;
  209. }
  210. }