BT9_082.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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_082 : 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. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  16. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  17. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  18. addJogressConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addJogressConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. JogressCondition GetJogress(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. bool PermanentCondition1(Permanent permanent)
  29. {
  30. if (permanent != null)
  31. {
  32. if (permanent.TopCard != null)
  33. {
  34. if (permanent.TopCard.Owner == card.Owner)
  35. {
  36. if (permanent.IsDigimon)
  37. {
  38. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  39. {
  40. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  41. {
  42. if (permanent.Levels_ForJogress(card).Contains(6))
  43. {
  44. return true;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool PermanentCondition2(Permanent permanent)
  55. {
  56. if (permanent != null)
  57. {
  58. if (permanent.TopCard != null)
  59. {
  60. if (permanent.TopCard.Owner == card.Owner)
  61. {
  62. if (permanent.IsDigimon)
  63. {
  64. if (permanent.TopCard.Owner.GetBattleAreaPermanents().Contains(permanent))
  65. {
  66. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  67. {
  68. if (permanent.Levels_ForJogress(card).Contains(6))
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. return false;
  79. }
  80. JogressConditionElement[] elements = new JogressConditionElement[]
  81. {
  82. new JogressConditionElement(PermanentCondition1, "a level 6 purple Digimon"),
  83. new JogressConditionElement(PermanentCondition2, "a level 6 yellow Digimon"),
  84. };
  85. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  86. return jogressCondition;
  87. }
  88. return null;
  89. }
  90. }
  91. if (timing == EffectTiming.OnEnterFieldAnyone)
  92. {
  93. ActivateClass activateClass = new ActivateClass();
  94. activateClass.SetUpICardEffect("Delete opponent's Digimon", CanUseCondition, card);
  95. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[When Digivolving] When DNA digivolving, delete 1 of your opponent's level 6 or higher Digimon and all of their level 5 or lower Digimon. For each Digimon deleted by this effect, <Recovery +1 (Deck)>. (Place the top card of your deck on top of your security stack.)";
  100. }
  101. bool CanSelectPermanentCondition(Permanent permanent)
  102. {
  103. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  104. {
  105. if (permanent.Level >= 6)
  106. {
  107. if (permanent.TopCard.HasLevel)
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. bool CanSelectPermanentCondition1(Permanent permanent)
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  118. {
  119. if (permanent.Level <= 5)
  120. {
  121. if (permanent.TopCard.HasLevel)
  122. {
  123. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  124. {
  125. if (permanent.CanBeDestroyedBySkill(activateClass))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. return false;
  134. }
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  138. {
  139. if (CardEffectCommons.IsJogress(hashtable))
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. if (CardEffectCommons.IsExistOnBattleArea(card))
  149. {
  150. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  151. {
  152. return true;
  153. }
  154. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition1))
  155. {
  156. return true;
  157. }
  158. }
  159. return false;
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  162. {
  163. List<Permanent> destroyTargetPermanents = new List<Permanent>();
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  167. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: CanSelectPermanentCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: maxCount,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: SelectPermanentCoroutine,
  177. afterSelectPermanentCoroutine: null,
  178. mode: SelectPermanentEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  183. {
  184. destroyTargetPermanents.Add(permanent);
  185. yield return null;
  186. }
  187. }
  188. destroyTargetPermanents = destroyTargetPermanents.Concat(card.Owner.Enemy.GetBattleAreaDigimons().Filter(CanSelectPermanentCondition1)).ToList();
  189. DestroyPermanentsClass destroyPermanentsClass = new DestroyPermanentsClass(destroyTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass));
  190. yield return ContinuousController.instance.StartCoroutine(destroyPermanentsClass.Destroy());
  191. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, destroyPermanentsClass.DestroyedPermanents.Count, activateClass).Recovery());
  192. }
  193. }
  194. if (timing == EffectTiming.OnDestroyedAnyone)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("Play this card from trash", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  199. cardEffects.Add(activateClass);
  200. string EffectDiscription()
  201. {
  202. return "[On Deletion] You may trash the top card of your security stack to play this card without paying its memory cost.";
  203. }
  204. bool CanUseCondition(Hashtable hashtable)
  205. {
  206. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  207. }
  208. bool CanActivateCondition(Hashtable hashtable)
  209. {
  210. if (CardEffectCommons.IsExistOnTrash(card))
  211. {
  212. if (card.Owner.SecurityCards.Count >= 1)
  213. {
  214. return true;
  215. }
  216. }
  217. return false;
  218. }
  219. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  220. {
  221. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  222. player: card.Owner,
  223. destroySecurityCount: 1,
  224. cardEffect: activateClass,
  225. fromTop: true).DestroySecurity());
  226. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: card, payCost: false, cardEffect: activateClass))
  227. {
  228. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  229. cardSources: new List<CardSource>() { card },
  230. activateClass: activateClass,
  231. payCost: false,
  232. isTapped: false,
  233. root: SelectCardEffect.Root.Trash,
  234. activateETB: true));
  235. }
  236. }
  237. }
  238. return cardEffects;
  239. }
  240. }