EX4_063.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Henry Wong & Shu-Chong Wong
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_063 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of Your Main Phase
  13. if (timing == EffectTiming.OnStartMainPhase)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Terriermon] or [Lopmon] from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Start of Your Main Phase] If you have 1 or fewer Digimon in play, you may play 1 [Terriermon] or [Lopmon] from your hand without paying the cost. Digimon played by this effect can't digivolve and are deleted at the end of your opponent's turn.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource.CardNames.Contains("Terriermon") || cardSource.CardNames.Contains("Lopmon"))
  26. {
  27. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Hand))
  28. {
  29. return true;
  30. }
  31. }
  32. return false;
  33. }
  34. bool CanUseCondition(Hashtable hashtable)
  35. {
  36. if (CardEffectCommons.IsExistOnBattleArea(card))
  37. {
  38. if (CardEffectCommons.IsOwnerTurn(card))
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (card.Owner.GetBattleAreaDigimons().Count <= 1)
  50. {
  51. if (card.Owner.HandCards.Count >= 1)
  52. {
  53. return true;
  54. }
  55. }
  56. }
  57. return false;
  58. }
  59. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  60. {
  61. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  62. {
  63. List<CardSource> selectedCards = new List<CardSource>();
  64. int maxCount = 1;
  65. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  66. selectHandEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: CanSelectCardCondition,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: maxCount,
  72. canNoSelect: true,
  73. canEndNotMax: false,
  74. isShowOpponent: true,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. mode: SelectHandEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  80. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  81. yield return StartCoroutine(selectHandEffect.Activate());
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCards.Add(cardSource);
  85. yield return null;
  86. }
  87. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  88. cardSources: selectedCards,
  89. activateClass: activateClass,
  90. payCost: false,
  91. isTapped: false,
  92. root: SelectCardEffect.Root.Hand,
  93. activateETB: true));
  94. foreach (CardSource selectedCard in selectedCards)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleArea(selectedCard))
  97. {
  98. Permanent selectedPermanent = selectedCard.PermanentOfThisCard();
  99. if (selectedPermanent != null)
  100. {
  101. CanNotDigivolveClass canNotEvolveClass = new CanNotDigivolveClass();
  102. canNotEvolveClass.SetUpICardEffect("Can't digivolve", CanUseCondition1, card);
  103. canNotEvolveClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  104. selectedPermanent.PermanentEffects.Add((_timing) => canNotEvolveClass);
  105. bool CanUseCondition1(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent);
  108. }
  109. bool PermanentCondition(Permanent permanent)
  110. {
  111. return permanent == selectedPermanent;
  112. }
  113. bool CardCondition(CardSource cardSource)
  114. {
  115. return true;
  116. }
  117. }
  118. if (selectedPermanent != null)
  119. {
  120. ActivateClass activateClass1 = new ActivateClass();
  121. activateClass1.SetUpICardEffect("Delete the Digimon", CanUseCondition1, card);
  122. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, 1, false, "");
  123. activateClass1.SetHashString("EX4_063_EoOT");
  124. card.Owner.UntilOpponentTurnEndEffects.Add(GetCardEffect);
  125. bool CanUseCondition1(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  128. {
  129. if (CardEffectCommons.IsOpponentTurn(card))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. bool CanActivateCondition1(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  139. {
  140. if (selectedPermanent.CanBeDestroyedBySkill(activateClass1))
  141. {
  142. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass1))
  143. {
  144. return true;
  145. }
  146. }
  147. }
  148. return false;
  149. }
  150. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  151. {
  152. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(new List<Permanent>() { selectedPermanent }, CardEffectCommons.CardEffectHashtable(activateClass1)).Destroy());
  153. }
  154. ICardEffect GetCardEffect(EffectTiming _timing)
  155. {
  156. if (_timing == EffectTiming.OnEndTurn)
  157. {
  158. return activateClass1;
  159. }
  160. return null;
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. #region Your Turn
  170. if (timing == EffectTiming.BeforePayCost)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  175. activateClass.SetHashString("Digisorption-1_EX4_063");
  176. cardEffects.Add(activateClass);
  177. string EffectDescription()
  178. {
  179. return "[Your Turn] When one of your Digimon with [Terriermon] or [Lopmon] in its digivolution cards would digivolve, by suspending this Tamer, reduce the digivolution cost by 1.";
  180. }
  181. bool PermanentCondition(Permanent permanent)
  182. {
  183. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  184. {
  185. if (permanent.DigivolutionCards.Count((evoRoot) => evoRoot.CardNames.Contains("Terriermon") || evoRoot.CardNames.Contains("Lopmon")) >= 1)
  186. {
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. bool CardCondition(CardSource cardSource)
  193. {
  194. return true;
  195. }
  196. bool CanUseCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleArea(card))
  199. {
  200. if (CardEffectCommons.IsOwnerTurn(card))
  201. {
  202. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  203. {
  204. return true;
  205. }
  206. }
  207. }
  208. return false;
  209. }
  210. bool CanActivateCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleArea(card))
  213. {
  214. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  215. {
  216. return true;
  217. }
  218. }
  219. return false;
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  222. {
  223. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(
  224. new List<Permanent>() { card.PermanentOfThisCard() },
  225. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  226. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  227. ChangeCostClass changeCostClass = new ChangeCostClass();
  228. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  229. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  230. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  231. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  232. bool CanUseCondition1(Hashtable hashtable)
  233. {
  234. return true;
  235. }
  236. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  237. {
  238. if (CardSourceCondition(cardSource))
  239. {
  240. if (RootCondition(root))
  241. {
  242. if (PermanentsCondition(targetPermanents))
  243. {
  244. Cost -= 1;
  245. }
  246. }
  247. }
  248. return Cost;
  249. }
  250. bool PermanentsCondition(List<Permanent> targetPermanents)
  251. {
  252. if (targetPermanents != null)
  253. {
  254. if (targetPermanents.Count(PermanentCondition) >= 1)
  255. {
  256. return true;
  257. }
  258. }
  259. return false;
  260. }
  261. bool PermanentCondition(Permanent targetPermanent)
  262. {
  263. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  264. }
  265. bool CardSourceCondition(CardSource cardSource)
  266. {
  267. return cardSource.Owner == card.Owner;
  268. }
  269. bool RootCondition(SelectCardEffect.Root root)
  270. {
  271. return true;
  272. }
  273. bool isUpDown()
  274. {
  275. return true;
  276. }
  277. }
  278. }
  279. #endregion
  280. #region Security
  281. if (timing == EffectTiming.SecuritySkill)
  282. {
  283. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  284. }
  285. #endregion
  286. return cardEffects;
  287. }
  288. }
  289. }