Skadimon_EX8_028.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. using System.Diagnostics;
  6. namespace DCGO.CardEffects.EX8
  7. {
  8. public class Skadimon_EX8_028
  9. : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternate Digivolution Requirement
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.EqualsTraits("Ice-Snow") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Iceclad
  25. if (timing == EffectTiming.None)
  26. {
  27. cardEffects.Add(CardEffectFactory.IcecladSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  28. }
  29. #endregion
  30. #region Barrier
  31. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  32. {
  33. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region When Digivolving
  37. if (timing == EffectTiming.OnEnterFieldAnyone)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("Play 1 [Ice-Snow] trait Digimon card", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[When Digivolving] You may play 1 level 4 or lower [Ice-Snow] trait Digimon card from your hand without paying the cost. For each of your opponent's Digimon with no digivolution cards, add 1 to this effect's level maximum.";
  46. }
  47. int MaxLevel()
  48. {
  49. int level = 4;
  50. level += card.Owner.Enemy.GetBattleAreaDigimons().Count(permanent => permanent.DigivolutionCards.Count == 0);
  51. return level;
  52. }
  53. bool CanSelectCardCondition(CardSource cardSource)
  54. {
  55. if (cardSource.IsDigimon)
  56. {
  57. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  58. {
  59. if (cardSource.EqualsTraits("Ice-Snow"))
  60. {
  61. if (cardSource.HasLevel && cardSource.Level <= MaxLevel())
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  73. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  78. {
  79. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  80. {
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  87. {
  88. List<CardSource> selectedCards = new List<CardSource>();
  89. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  90. selectHandEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectCardCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: 1,
  96. canNoSelect: true,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. selectCardCoroutine: SelectCardCoroutine,
  100. afterSelectCardCoroutine: null,
  101. mode: SelectHandEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  104. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  105. yield return StartCoroutine(selectHandEffect.Activate());
  106. IEnumerator SelectCardCoroutine(CardSource cardSource)
  107. {
  108. selectedCards.Add(cardSource);
  109. yield return null;
  110. }
  111. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  112. cardSources: selectedCards,
  113. activateClass: activateClass,
  114. payCost: false,
  115. isTapped: false,
  116. root: SelectCardEffect.Root.Hand,
  117. activateETB: true));
  118. }
  119. }
  120. #endregion
  121. #region When Digivolving - OPT
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("By placing 1 digimon to bottom of security, unsuspend", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  127. activateClass.SetHashString("Unsuspend_EX8_028");
  128. cardEffects.Add(activateClass);
  129. string EffectDiscription()
  130. {
  131. return "[When Digivolving] [Once Per Turn] By placing 1 Digimon with no digivolution cards as the bottom security card, this Digimon unsuspends.";
  132. }
  133. bool CanSelectPermanentCondition(Permanent permanent)
  134. {
  135. if (permanent.IsDigimon)
  136. {
  137. if (permanent.DigivolutionCards.Count == 0)
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card) &&
  147. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  161. {
  162. Permanent selectedCard = null;
  163. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  164. selectPermanentEffect.SetUp(
  165. selectPlayer: card.Owner,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canTargetCondition: CanSelectPermanentCondition,
  168. canEndSelectCondition: null,
  169. maxCount: 1,
  170. canNoSelect: false,
  171. canEndNotMax: false,
  172. selectPermanentCoroutine: CardSelected,
  173. afterSelectPermanentCoroutine: null,
  174. mode: SelectPermanentEffect.Mode.Custom,
  175. cardEffect: activateClass);
  176. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place at bottom of security.", "The opponent is selecting 1 Digimon to place at bottom of security.");
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. IEnumerator CardSelected(Permanent permanent)
  179. {
  180. if (permanent != null)
  181. selectedCard = permanent;
  182. yield return null;
  183. }
  184. if (selectedCard != null)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  187. selectedCard,
  188. CardEffectCommons.CardEffectHashtable(activateClass),
  189. false).PutSecurity());
  190. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  191. }
  192. }
  193. }
  194. #endregion
  195. #region When Attacking - OPT
  196. if (timing == EffectTiming.OnAllyAttack)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("By placing 1 digimon to bottom of security, unsuspend", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  201. activateClass.SetHashString("Unsuspend_EX8_028");
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[When Attacking] [Once Per Turn] By placing 1 Digimon with no digivolution cards as the bottom security card, this Digimon unsuspends.";
  206. }
  207. bool CanSelectPermanentCondition(Permanent permanent)
  208. {
  209. if (permanent.IsDigimon)
  210. {
  211. if (permanent.DigivolutionCards.Count == 0)
  212. {
  213. return true;
  214. }
  215. }
  216. return false;
  217. }
  218. bool CanUseCondition(Hashtable hashtable)
  219. {
  220. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  221. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  226. {
  227. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  228. {
  229. return true;
  230. }
  231. }
  232. return false;
  233. }
  234. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  235. {
  236. Permanent selectedCard = null;
  237. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  238. selectPermanentEffect.SetUp(
  239. selectPlayer: card.Owner,
  240. canTargetCondition_ByPreSelecetedList: null,
  241. canTargetCondition: CanSelectPermanentCondition,
  242. canEndSelectCondition: null,
  243. maxCount: 1,
  244. canNoSelect: false,
  245. canEndNotMax: false,
  246. selectPermanentCoroutine: CardSelected,
  247. afterSelectPermanentCoroutine: null,
  248. mode: SelectPermanentEffect.Mode.Custom,
  249. cardEffect: activateClass);
  250. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place at bottom of security.", "The opponent is selecting 1 Digimon to place at bottom of security.");
  251. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  252. IEnumerator CardSelected(Permanent permanent)
  253. {
  254. if (permanent != null)
  255. selectedCard = permanent;
  256. yield return null;
  257. }
  258. if (selectedCard != null)
  259. {
  260. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  261. selectedCard,
  262. CardEffectCommons.CardEffectHashtable(activateClass),
  263. false).PutSecurity());
  264. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  265. }
  266. }
  267. }
  268. #endregion
  269. return cardEffects;
  270. }
  271. }
  272. }