EX8_028.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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 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 (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  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. if (!selectedCard.TopCard.CanNotBeAffected(activateClass))
  187. {
  188. CardSource _topCard = selectedCard.TopCard;
  189. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  190. selectedCard,
  191. CardEffectCommons.CardEffectHashtable(activateClass),
  192. false).PutSecurity());
  193. if(!CardEffectCommons.IsExistOnBattleArea(_topCard))
  194. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region When Attacking - OPT
  201. if (timing == EffectTiming.OnAllyAttack)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("By placing 1 digimon to bottom of security, unsuspend", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  206. activateClass.SetHashString("Unsuspend_EX8_028");
  207. cardEffects.Add(activateClass);
  208. string EffectDiscription()
  209. {
  210. return "[When Attacking] [Once Per Turn] By placing 1 Digimon with no digivolution cards as the bottom security card, this Digimon unsuspends.";
  211. }
  212. bool CanSelectPermanentCondition(Permanent permanent)
  213. {
  214. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  215. {
  216. if (permanent.DigivolutionCards.Count == 0)
  217. {
  218. return true;
  219. }
  220. }
  221. return false;
  222. }
  223. bool CanUseCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.CanTriggerOnAttack(hashtable, card) &&
  226. CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  227. }
  228. bool CanActivateCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  231. {
  232. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  233. {
  234. return true;
  235. }
  236. }
  237. return false;
  238. }
  239. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  240. {
  241. Permanent selectedCard = null;
  242. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  243. selectPermanentEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition_ByPreSelecetedList: null,
  246. canTargetCondition: CanSelectPermanentCondition,
  247. canEndSelectCondition: null,
  248. maxCount: 1,
  249. canNoSelect: false,
  250. canEndNotMax: false,
  251. selectPermanentCoroutine: CardSelected,
  252. afterSelectPermanentCoroutine: null,
  253. mode: SelectPermanentEffect.Mode.Custom,
  254. cardEffect: activateClass);
  255. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place at bottom of security.", "The opponent is selecting 1 Digimon to place at bottom of security.");
  256. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  257. IEnumerator CardSelected(Permanent permanent)
  258. {
  259. if (permanent != null)
  260. selectedCard = permanent;
  261. yield return null;
  262. }
  263. if (selectedCard != null)
  264. {
  265. if (!selectedCard.TopCard.CanNotBeAffected(activateClass))
  266. {
  267. CardSource _topCard = selectedCard.TopCard;
  268. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  269. selectedCard,
  270. CardEffectCommons.CardEffectHashtable(activateClass),
  271. false).PutSecurity());
  272. if (!CardEffectCommons.IsExistOnBattleArea(_topCard))
  273. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  274. }
  275. }
  276. }
  277. }
  278. #endregion
  279. return cardEffects;
  280. }
  281. }
  282. }