EX9_054.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. namespace DCGO.CardEffects.EX9
  6. {
  7. public class EX9_054 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  22. }
  23. bool IsOpponentDigimon(Permanent targetPermanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  34. CardEffectCommons.HasMatchConditionPermanent(IsOpponentDigimon);
  35. }
  36. IEnumerator ActivateCoroutine(Hashtable hashtable)
  37. {
  38. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  39. selectPermanentEffect.SetUp(
  40. selectPlayer: card.Owner,
  41. canTargetCondition: IsOpponentDigimon,
  42. canTargetCondition_ByPreSelecetedList: null,
  43. canEndSelectCondition: null,
  44. maxCount: 1,
  45. canNoSelect: false,
  46. canEndNotMax: false,
  47. selectPermanentCoroutine: SelectPermanentCoroutine1,
  48. afterSelectPermanentCoroutine: null,
  49. mode: SelectPermanentEffect.Mode.Custom,
  50. cardEffect: activateClass);
  51. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  52. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  53. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  54. {
  55. Permanent selectedPermanent = permanent;
  56. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  57. }
  58. }
  59. }
  60. #endregion
  61. #region When Digivolving
  62. if (timing == EffectTiming.OnEnterFieldAnyone)
  63. {
  64. ActivateClass activateClass = new ActivateClass();
  65. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  66. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  67. cardEffects.Add(activateClass);
  68. string EffectDiscription()
  69. {
  70. return "[When Digivolving] <De-Digivolve 1> 1 of your opponent's Digimon (Trash the top card. You can't trash past level 3 cards).";
  71. }
  72. bool IsOpponentDigimon(Permanent targetPermanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(targetPermanent, card);
  75. }
  76. bool CanUseCondition(Hashtable hashtable)
  77. {
  78. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  79. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  80. }
  81. bool CanActivateCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  84. CardEffectCommons.HasMatchConditionPermanent(IsOpponentDigimon);
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable hashtable)
  87. {
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: IsOpponentDigimon,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: 1,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: SelectPermanentCoroutine1,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Custom,
  100. cardEffect: activateClass);
  101. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  104. {
  105. Permanent selectedPermanent = permanent;
  106. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  107. }
  108. }
  109. }
  110. #endregion
  111. #region On Deletion
  112. if (timing == EffectTiming.OnDestroyedAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Play 1 Digimon", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[On Deletion] you may play 1 level 4 or lower Digimon card with [Negamon] in its text from your hand without paying the cost. For every 2 [Negamon] in your trash or your Digimon's digivolution cards, add 1 to this effect's level maximum.";
  121. }
  122. int LevelAmount()
  123. {
  124. int value = 4;
  125. int cardCount = 0;
  126. cardCount += CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsNegamon);
  127. foreach (Permanent perm in card.Owner.GetBattleAreaDigimons())
  128. {
  129. cardCount += perm.DigivolutionCards.Count(IsNegamon);
  130. }
  131. return value + Mathf.FloorToInt(cardCount/2);
  132. }
  133. bool IsNegamon(CardSource source)
  134. {
  135. return source.EqualsCardName("Negamon");
  136. }
  137. bool CardCondition(CardSource cardSource)
  138. {
  139. if (cardSource.Owner == card.Owner)
  140. {
  141. if (cardSource.IsDigimon)
  142. {
  143. if(cardSource.HasLevel && cardSource.Level <= LevelAmount())
  144. {
  145. if (cardSource.HasText("Negamon"))
  146. {
  147. return true;
  148. }
  149. }
  150. }
  151. }
  152. return false;
  153. }
  154. bool CanUseCondition(Hashtable hashtable)
  155. {
  156. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  157. }
  158. bool CanActivateCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. List<CardSource> selectedCards = new List<CardSource>();
  165. if (card.Owner.HandCards.Count(CardCondition) >= 1)
  166. {
  167. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  168. selectHandEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: CardCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: 1,
  174. canNoSelect: true,
  175. canEndNotMax: false,
  176. isShowOpponent: true,
  177. selectCardCoroutine: SelectCardCoroutine,
  178. afterSelectCardCoroutine: null,
  179. mode: SelectHandEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectHandEffect.SetUpCustomMessage("Select 1 Digimon to play.",
  182. "The opponent is selecting 1 Digimon to play.");
  183. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  184. yield return StartCoroutine(selectHandEffect.Activate());
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. yield return ContinuousController.instance.StartCoroutine(
  191. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  192. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  193. }
  194. }
  195. }
  196. #endregion
  197. #region All Turns - ESS
  198. if (timing == EffectTiming.OnAttackTargetChanged)
  199. {
  200. ActivateClass activateClass = new ActivateClass();
  201. activateClass.SetUpICardEffect("Unsuspend", CanUseCondition, card);
  202. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  203. activateClass.SetHashString("Unsuspend_EX9-054");
  204. activateClass.SetIsInheritedEffect(true);
  205. cardEffects.Add(activateClass);
  206. string EffectDiscription()
  207. {
  208. return "[All Turns] [Once Per Turn] When attack targets change, if this Digimon has [Abbadomon] in its name, it unsuspends.";
  209. }
  210. bool CanUseCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  213. {
  214. if (CardEffectCommons.CanTriggerOnPermanentAttackTargetSwitch(hashtable, permanent => true))
  215. {
  216. return true;
  217. }
  218. }
  219. return false;
  220. }
  221. bool CanActivateCondition(Hashtable hashtable)
  222. {
  223. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  224. card.PermanentOfThisCard().TopCard.ContainsCardName("Abbadomon");
  225. }
  226. IEnumerator ActivateCoroutine(Hashtable hashtable)
  227. {
  228. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  229. permanents: new List<Permanent> { card.PermanentOfThisCard() },
  230. cardEffect: activateClass).Unsuspend());
  231. }
  232. }
  233. #endregion
  234. return cardEffects;
  235. }
  236. }
  237. }