BT7_111.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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 BT7_111 : 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. bool Condition()
  16. {
  17. return card.Owner.HandCards.Contains(card);
  18. }
  19. bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. if (CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent))
  22. {
  23. if (targetPermanent.TopCard.CardNames.Contains("Lucemon"))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 7, ignoreDigivolutionRequirement: true, card: card, condition: Condition));
  31. }
  32. if (timing == EffectTiming.None)
  33. {
  34. ChangeCostClass changeCostClass = new ChangeCostClass();
  35. changeCostClass.SetUpICardEffect($"Reduce Play Cost", CanUseCondition, card);
  36. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  37. cardEffects.Add(changeCostClass);
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return card.Owner.HandCards.Contains(card);
  41. }
  42. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  43. {
  44. if (CardSourceCondition(cardSource))
  45. {
  46. if (RootCondition(root))
  47. {
  48. if (PermanentsCondition(targetPermanents))
  49. {
  50. int count = 3 * (card.Owner.TrashCards.Count / 10);
  51. Cost -= count;
  52. }
  53. }
  54. }
  55. return Cost;
  56. }
  57. bool PermanentsCondition(List<Permanent> targetPermanents)
  58. {
  59. if (targetPermanents == null)
  60. {
  61. return true;
  62. }
  63. else
  64. {
  65. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  66. {
  67. return true;
  68. }
  69. }
  70. return false;
  71. }
  72. bool CardSourceCondition(CardSource cardSource)
  73. {
  74. return cardSource == card;
  75. }
  76. bool RootCondition(SelectCardEffect.Root root)
  77. {
  78. if (root == SelectCardEffect.Root.Hand)
  79. {
  80. return true;
  81. }
  82. return false;
  83. }
  84. bool isUpDown()
  85. {
  86. return true;
  87. }
  88. }
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Delete 1 level 6 or lower Digimon or Tamer", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[On Play] Delete 1 of your opponent's Tamers or level 6 or lower Digimon.";
  98. }
  99. bool CanSelectPermanentCondition(Permanent permanent)
  100. {
  101. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  102. {
  103. if (permanent.IsDigimon)
  104. {
  105. if (permanent.Level <= 6)
  106. {
  107. if (permanent.TopCard.HasLevel)
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. if (permanent.IsTamer)
  114. {
  115. return true;
  116. }
  117. }
  118. return false;
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  123. }
  124. bool CanActivateCondition(Hashtable hashtable)
  125. {
  126. if (CardEffectCommons.IsExistOnBattleArea(card))
  127. {
  128. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  129. {
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  136. {
  137. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: null,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Destroy,
  150. cardEffect: activateClass);
  151. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  152. }
  153. }
  154. if (timing == EffectTiming.OnEnterFieldAnyone)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("Delete 1 level 6 or lower Digimon or Tamer", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  159. cardEffects.Add(activateClass);
  160. string EffectDiscription()
  161. {
  162. return "[When Digivolving] Delete 1 of your opponent's Tamers or level 6 or lower Digimon.";
  163. }
  164. bool CanSelectPermanentCondition(Permanent permanent)
  165. {
  166. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  167. {
  168. if (permanent.IsDigimon)
  169. {
  170. if (permanent.Level <= 6)
  171. {
  172. if (permanent.TopCard.HasLevel)
  173. {
  174. return true;
  175. }
  176. }
  177. }
  178. if (permanent.IsTamer)
  179. {
  180. return true;
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. if (CardEffectCommons.IsExistOnBattleArea(card))
  192. {
  193. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition) >= 1)
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  201. {
  202. int maxCount = Math.Min(1, card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectPermanentCondition));
  203. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  204. selectPermanentEffect.SetUp(
  205. selectPlayer: card.Owner,
  206. canTargetCondition: CanSelectPermanentCondition,
  207. canTargetCondition_ByPreSelecetedList: null,
  208. canEndSelectCondition: null,
  209. maxCount: maxCount,
  210. canNoSelect: false,
  211. canEndNotMax: false,
  212. selectPermanentCoroutine: null,
  213. afterSelectPermanentCoroutine: null,
  214. mode: SelectPermanentEffect.Mode.Destroy,
  215. cardEffect: activateClass);
  216. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  217. }
  218. }
  219. return cardEffects;
  220. }
  221. }