Phoenixmon_BT15_017.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 Phoenixmon_BT15_017 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Delete 1 Digimon with the lowest DP and trash the top card of opponent's security", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] If your opponent has 3 or fewer security cards, delete 1 of their Digimon with the lowest DP. If they have 4 or more, trash the top card of their security stack.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  36. {
  37. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  38. {
  39. return true;
  40. }
  41. }
  42. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  50. {
  51. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: maxCount,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: null,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Destroy,
  68. cardEffect: activateClass);
  69. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  70. }
  71. }
  72. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  75. player: card.Owner.Enemy,
  76. destroySecurityCount: 1,
  77. cardEffect: activateClass,
  78. fromTop: true).DestroySecurity());
  79. }
  80. }
  81. }
  82. if (timing == EffectTiming.OnDestroyedAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Delete 1 Digimon with the lowest DP and trash the top card of opponent's security", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  87. cardEffects.Add(activateClass);
  88. string EffectDiscription()
  89. {
  90. return "[On Deletion] If your opponent has 3 or fewer security cards, delete 1 of their Digimon with the lowest DP. If they have 4 or more, trash the top card of their security stack.";
  91. }
  92. bool CanSelectPermanentCondition(Permanent permanent)
  93. {
  94. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card);
  99. }
  100. bool CanActivateCondition(Hashtable hashtable)
  101. {
  102. if (CardEffectCommons.CanActivateOnDeletion(card))
  103. {
  104. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  105. {
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. return true;
  109. }
  110. }
  111. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  112. {
  113. return true;
  114. }
  115. }
  116. return false;
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  119. {
  120. if (card.Owner.Enemy.SecurityCards.Count <= 3)
  121. {
  122. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  123. {
  124. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  125. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: false,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: null,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Destroy,
  137. cardEffect: activateClass);
  138. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  139. }
  140. }
  141. if (card.Owner.Enemy.SecurityCards.Count >= 4)
  142. {
  143. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  144. player: card.Owner.Enemy,
  145. destroySecurityCount: 1,
  146. cardEffect: activateClass,
  147. fromTop: true).DestroySecurity());
  148. }
  149. }
  150. }
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Play 1 Digimon or Tamer from hand", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  156. cardEffects.Add(activateClass);
  157. string EffectDiscription()
  158. {
  159. return "[On Play] You may play 1 red Digimon card with 5000 DP or less or 1 red Tamer card from your hand without paying the cost.";
  160. }
  161. bool CanSelectCardCondition(CardSource cardSource)
  162. {
  163. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  164. {
  165. if (cardSource.CardColors.Contains(CardColor.Red))
  166. {
  167. if (cardSource.IsDigimon)
  168. {
  169. if (cardSource.CardDP <= 5000)
  170. {
  171. if (cardSource.HasDP)
  172. {
  173. return true;
  174. }
  175. }
  176. }
  177. if (cardSource.IsTamer)
  178. {
  179. return true;
  180. }
  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.HandCards.Count >= 1)
  194. {
  195. return true;
  196. }
  197. }
  198. return false;
  199. }
  200. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  201. {
  202. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  203. {
  204. List<CardSource> selectedCards = new List<CardSource>();
  205. int maxCount = 1;
  206. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  207. selectHandEffect.SetUp(
  208. selectPlayer: card.Owner,
  209. canTargetCondition: CanSelectCardCondition,
  210. canTargetCondition_ByPreSelecetedList: null,
  211. canEndSelectCondition: null,
  212. maxCount: maxCount,
  213. canNoSelect: true,
  214. canEndNotMax: false,
  215. isShowOpponent: true,
  216. selectCardCoroutine: SelectCardCoroutine,
  217. afterSelectCardCoroutine: null,
  218. mode: SelectHandEffect.Mode.Custom,
  219. cardEffect: activateClass);
  220. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  221. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  222. yield return StartCoroutine(selectHandEffect.Activate());
  223. IEnumerator SelectCardCoroutine(CardSource cardSource)
  224. {
  225. selectedCards.Add(cardSource);
  226. yield return null;
  227. }
  228. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  229. }
  230. }
  231. }
  232. return cardEffects;
  233. }
  234. }