EX5_013.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 EX5_013 : 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. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardTraits.Contains("Deva") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.OnCounterTiming)
  22. {
  23. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  24. }
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Delete 1 Digimon to gain Security Attack +1", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  30. activateClass.SetHashString("DeleteAndGainSAttak_EX5_013");
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[When Digivolving] [Once Per Turn] By deleting 1 Digimon with the [Deva] trait or 6000 DP or less, this Digimon gains <Security Attack +1> (This Digimon checks 1 additional security card) for the turn.";
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  39. {
  40. if (permanent.IsDigimon)
  41. {
  42. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  43. {
  44. return true;
  45. }
  46. if (permanent.TopCard.CardTraits.Contains("Deva"))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleArea(card))
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  70. {
  71. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  74. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: CanSelectPermanentCondition,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: maxCount,
  81. canNoSelect: true,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: SelectPermanentCoroutine,
  84. afterSelectPermanentCoroutine: null,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  89. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  92. targetPermanents: new List<Permanent>() { permanent },
  93. activateClass: activateClass,
  94. successProcess: permanents => SuccessProcess(),
  95. failureProcess: null));
  96. IEnumerator SuccessProcess()
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  99. targetPermanent: card.PermanentOfThisCard(),
  100. changeValue: 1,
  101. effectDuration: EffectDuration.UntilEachTurnEnd,
  102. activateClass: activateClass));
  103. }
  104. }
  105. }
  106. }
  107. }
  108. if (timing == EffectTiming.OnAllyAttack)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Delete 1 Digimon to gain Security Attack +1", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  113. activateClass.SetHashString("DeleteAndGainSAttak_EX5_013");
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "[When Attacking] [Once Per Turn] By deleting 1 Digimon with the [Deva] trait or 6000 DP or less, this Digimon gains <Security Attack +1> (This Digimon checks 1 additional security card) for the turn.";
  118. }
  119. bool CanSelectPermanentCondition(Permanent permanent)
  120. {
  121. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  122. {
  123. if (permanent.IsDigimon)
  124. {
  125. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(6000, activateClass))
  126. {
  127. return true;
  128. }
  129. if (permanent.TopCard.CardTraits.Contains("Deva"))
  130. {
  131. return true;
  132. }
  133. }
  134. }
  135. return false;
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. if (CardEffectCommons.IsExistOnBattleArea(card))
  144. {
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  153. {
  154. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  155. {
  156. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  157. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  158. selectPermanentEffect.SetUp(
  159. selectPlayer: card.Owner,
  160. canTargetCondition: CanSelectPermanentCondition,
  161. canTargetCondition_ByPreSelecetedList: null,
  162. canEndSelectCondition: null,
  163. maxCount: maxCount,
  164. canNoSelect: true,
  165. canEndNotMax: false,
  166. selectPermanentCoroutine: SelectPermanentCoroutine,
  167. afterSelectPermanentCoroutine: null,
  168. mode: SelectPermanentEffect.Mode.Custom,
  169. cardEffect: activateClass);
  170. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  171. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  172. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  175. targetPermanents: new List<Permanent>() { permanent },
  176. activateClass: activateClass,
  177. successProcess: permanents => SuccessProcess(),
  178. failureProcess: null));
  179. IEnumerator SuccessProcess()
  180. {
  181. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  182. targetPermanent: card.PermanentOfThisCard(),
  183. changeValue: 1,
  184. effectDuration: EffectDuration.UntilEachTurnEnd,
  185. activateClass: activateClass));
  186. }
  187. }
  188. }
  189. }
  190. }
  191. if (timing == EffectTiming.OnDestroyedAnyone)
  192. {
  193. ActivateClass activateClass = new ActivateClass();
  194. activateClass.SetUpICardEffect("Delete opponent's 1 Digimon with the highest DP", CanUseCondition, card);
  195. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  196. cardEffects.Add(activateClass);
  197. string EffectDiscription()
  198. {
  199. return "[On Deletion] Delete 1 of your opponent's Digimon with the highest DP.";
  200. }
  201. bool CanSelectPermanentCondition(Permanent permanent)
  202. {
  203. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  204. {
  205. if (CardEffectCommons.IsMaxDP(permanent, card.Owner.Enemy, null))
  206. {
  207. return true;
  208. }
  209. }
  210. return false;
  211. }
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  219. {
  220. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  221. {
  222. return true;
  223. }
  224. }
  225. return false;
  226. }
  227. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  228. {
  229. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  230. {
  231. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  232. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  233. selectPermanentEffect.SetUp(
  234. selectPlayer: card.Owner,
  235. canTargetCondition: CanSelectPermanentCondition,
  236. canTargetCondition_ByPreSelecetedList: null,
  237. canEndSelectCondition: null,
  238. maxCount: maxCount,
  239. canNoSelect: false,
  240. canEndNotMax: false,
  241. selectPermanentCoroutine: null,
  242. afterSelectPermanentCoroutine: null,
  243. mode: SelectPermanentEffect.Mode.Destroy,
  244. cardEffect: activateClass);
  245. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  246. }
  247. }
  248. }
  249. return cardEffects;
  250. }
  251. }