EX5_063.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Leviamon
  6. public class EX5_063 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Security A. +1
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  15. changeValue: 1,
  16. isInheritedEffect: false,
  17. card: card,
  18. condition: null));
  19. }
  20. #endregion
  21. #region On Play
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("Delete 1 Digimon with the highest level and 1 Digimon with the lowest level", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[On Play] If your opponent has as many or more total Digimon and Tamers as you, delete 1 of your opponent's Digimon with the highest level. Then, delete 1 of your opponent's Digimon with the lowest level.";
  31. }
  32. bool CanSelectPermanentCondition(Permanent permanent)
  33. {
  34. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  35. {
  36. if (CardEffectCommons.IsMaxLevel(permanent, card.Owner.Enemy))
  37. {
  38. return true;
  39. }
  40. }
  41. return false;
  42. }
  43. bool CanSelectPermanentCondition1(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  46. {
  47. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer)
  63. >= card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer))
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. return true;
  68. }
  69. }
  70. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  71. {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  78. {
  79. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer)
  80. >= card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer))
  81. {
  82. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  83. {
  84. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  85. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  86. selectPermanentEffect.SetUp(
  87. selectPlayer: card.Owner,
  88. canTargetCondition: CanSelectPermanentCondition,
  89. canTargetCondition_ByPreSelecetedList: null,
  90. canEndSelectCondition: null,
  91. maxCount: maxCount,
  92. canNoSelect: false,
  93. canEndNotMax: false,
  94. selectPermanentCoroutine: null,
  95. afterSelectPermanentCoroutine: null,
  96. mode: SelectPermanentEffect.Mode.Destroy,
  97. cardEffect: activateClass);
  98. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  99. }
  100. }
  101. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  102. {
  103. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: CanSelectPermanentCondition1,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: maxCount,
  111. canNoSelect: false,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: null,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.Destroy,
  116. cardEffect: activateClass);
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. }
  119. }
  120. }
  121. #endregion
  122. #region When Digivolving
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Delete 1 Digimon with the highest level and 1 Digimon with the lowest level", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  128. cardEffects.Add(activateClass);
  129. string EffectDiscription()
  130. {
  131. return "[When Digivolving] If your opponent has as many or more total Digimon and Tamers as you, delete 1 of your opponent's Digimon with the highest level. Then, delete 1 of your opponent's Digimon with the lowest level.";
  132. }
  133. bool CanSelectPermanentCondition(Permanent permanent)
  134. {
  135. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  136. {
  137. if (CardEffectCommons.IsMaxLevel(permanent, card.Owner.Enemy))
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CanSelectPermanentCondition1(Permanent permanent)
  145. {
  146. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  147. {
  148. if (CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy))
  149. {
  150. return true;
  151. }
  152. }
  153. return false;
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  158. }
  159. bool CanActivateCondition(Hashtable hashtable)
  160. {
  161. if (CardEffectCommons.IsExistOnBattleArea(card))
  162. {
  163. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer)
  164. >= card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer))
  165. {
  166. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  167. {
  168. return true;
  169. }
  170. }
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  179. {
  180. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer)
  181. >= card.Owner.GetBattleAreaPermanents().Count(permanent => permanent.IsDigimon || permanent.IsTamer))
  182. {
  183. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  184. {
  185. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanentCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: maxCount,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: null,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Destroy,
  198. cardEffect: activateClass);
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. }
  201. }
  202. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  203. {
  204. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  205. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  206. selectPermanentEffect.SetUp(
  207. selectPlayer: card.Owner,
  208. canTargetCondition: CanSelectPermanentCondition1,
  209. canTargetCondition_ByPreSelecetedList: null,
  210. canEndSelectCondition: null,
  211. maxCount: maxCount,
  212. canNoSelect: false,
  213. canEndNotMax: false,
  214. selectPermanentCoroutine: null,
  215. afterSelectPermanentCoroutine: null,
  216. mode: SelectPermanentEffect.Mode.Destroy,
  217. cardEffect: activateClass);
  218. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  219. }
  220. }
  221. }
  222. #endregion
  223. #region All Turns
  224. if (timing == EffectTiming.OnDestroyedAnyone)
  225. {
  226. ActivateClass activateClass = new ActivateClass();
  227. activateClass.SetUpICardEffect("Gain Memory", CanUseCondition, card);
  228. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  229. cardEffects.Add(activateClass);
  230. string EffectDiscription()
  231. {
  232. return "[All Turns] When an opponent's Digimon is deleted, gain 1 memory for each Digimon.";
  233. }
  234. bool PermanentCondition(Permanent permanent)
  235. {
  236. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  237. }
  238. bool CanUseCondition(Hashtable hashtable)
  239. {
  240. return CardEffectCommons.IsExistOnBattleArea(card)
  241. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass);
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. if (CardEffectCommons.IsExistOnBattleArea(card))
  246. {
  247. if (card.Owner.CanAddMemory(activateClass))
  248. {
  249. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  250. if (hashtables != null)
  251. {
  252. if (hashtables.Count >= 1)
  253. {
  254. return true;
  255. }
  256. }
  257. }
  258. }
  259. return false;
  260. }
  261. IEnumerator ActivateCoroutine(Hashtable hashtable)
  262. {
  263. List<CardSource> EnemyDigimon = new List<CardSource>();
  264. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  265. if (hashtables != null)
  266. {
  267. foreach (Hashtable hashtable1 in hashtables)
  268. {
  269. CardSource cardSource = CardEffectCommons.GetTopCardFromOneHashtable(hashtable1);
  270. if (cardSource != null
  271. && cardSource.IsDigimon
  272. && cardSource.Owner == card.Owner.Enemy)
  273. {
  274. EnemyDigimon.Add(cardSource);
  275. }
  276. }
  277. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(EnemyDigimon.Count, activateClass));
  278. }
  279. }
  280. }
  281. #endregion
  282. return cardEffects;
  283. }
  284. }