EX4_063.cs 15 KB

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