EX4_030.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_030 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. ChangeCardNamesClass changeCardNamesClass = new ChangeCardNamesClass();
  15. changeCardNamesClass.SetUpICardEffect("Also treated as having [Sakuyamon] in its name", CanUseCondition, card);
  16. changeCardNamesClass.SetUpChangeCardNamesClass(changeCardNames: changeCardNames);
  17. cardEffects.Add(changeCardNamesClass);
  18. bool CanUseCondition(Hashtable hashtable)
  19. {
  20. return true;
  21. }
  22. List<string> changeCardNames(CardSource cardSource, List<string> CardNames)
  23. {
  24. if (cardSource == card)
  25. {
  26. CardNames.Add("Sakuyamon_EX4_030");
  27. }
  28. return CardNames;
  29. }
  30. }
  31. if (timing == EffectTiming.OnEnterFieldAnyone)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Play 1 Option from hand", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] You may use an Option card with a cost of 5 or less in your hand without paying the cost.";
  40. }
  41. bool CanSelectCardCondition(CardSource cardSource)
  42. {
  43. if (cardSource.IsOption)
  44. {
  45. if (cardSource.HasUseCost)
  46. {
  47. if (cardSource.GetCostItself <= 5)
  48. {
  49. if (!cardSource.CanNotPlayThisOption)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnBattleArea(card))
  65. {
  66. if (card.Owner.HandCards.Count >= 1)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  74. {
  75. List<CardSource> selectedCards = new List<CardSource>();
  76. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  77. {
  78. int maxCount = 1;
  79. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  80. selectHandEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: CanSelectCardCondition,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: maxCount,
  86. canNoSelect: true,
  87. canEndNotMax: false,
  88. isShowOpponent: true,
  89. selectCardCoroutine: SelectCardCoroutine,
  90. afterSelectCardCoroutine: null,
  91. mode: SelectHandEffect.Mode.Custom,
  92. cardEffect: activateClass);
  93. selectHandEffect.SetUpCustomMessage(
  94. "Select 1 option card to use.",
  95. "The opponent is selecting 1 option card to use.");
  96. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  97. yield return StartCoroutine(selectHandEffect.Activate());
  98. IEnumerator SelectCardCoroutine(CardSource cardSource)
  99. {
  100. selectedCards.Add(cardSource);
  101. yield return null;
  102. }
  103. }
  104. yield return ContinuousController.instance.StartCoroutine(
  105. CardEffectCommons.PlayOptionCards(
  106. cardSources: selectedCards,
  107. activateClass: activateClass,
  108. payCost: false,
  109. root: SelectCardEffect.Root.Hand
  110. )
  111. );
  112. }
  113. }
  114. if (timing == EffectTiming.OnUseOption)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect("Play 1 digivolution card", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  119. activateClass.SetHashString("PlayDigivolutionCard_EX4_030");
  120. cardEffects.Add(activateClass);
  121. string EffectDiscription()
  122. {
  123. return "[Your Turn][Once Per Turn] When you use an Option card with a cost of 2 or more, you may play 1 [Taomon] or 1 level 4 or lower yellow or blue Digimon card from this Digimon's digivolution cards without paying the cost.";
  124. }
  125. bool CanSelectCardCondition(CardSource cardSource)
  126. {
  127. if (cardSource.IsDigimon)
  128. {
  129. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  130. {
  131. if (cardSource.CardNames.Contains("Taomon"))
  132. {
  133. return true;
  134. }
  135. if (cardSource.HasLevel && cardSource.Level <= 4)
  136. {
  137. if (cardSource.HasCardColor(CardColor.Blue))
  138. {
  139. return true;
  140. }
  141. if (cardSource.HasCardColor(CardColor.Yellow))
  142. {
  143. return true;
  144. }
  145. }
  146. }
  147. }
  148. return false;
  149. }
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.IsExistOnBattleArea(card))
  153. {
  154. if (CardEffectCommons.IsOwnerTurn(card))
  155. {
  156. if (CardEffectCommons.CanTriggerWhenOwnerUseOption(hashtable, null, (cost) => cost >= 2, card))
  157. {
  158. return true;
  159. }
  160. }
  161. }
  162. return false;
  163. }
  164. bool CanActivateCondition(Hashtable hashtable)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleArea(card))
  167. {
  168. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  169. {
  170. return true;
  171. }
  172. }
  173. return false;
  174. }
  175. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  176. {
  177. Permanent selectedPermanent = card.PermanentOfThisCard();
  178. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  179. {
  180. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  181. List<CardSource> selectedCards = new List<CardSource>();
  182. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  183. selectCardEffect.SetUp(
  184. canTargetCondition: CanSelectCardCondition,
  185. canTargetCondition_ByPreSelecetedList: null,
  186. canEndSelectCondition: null,
  187. canNoSelect: () => true,
  188. selectCardCoroutine: SelectCardCoroutine,
  189. afterSelectCardCoroutine: null,
  190. message: "Select 1 digivolution card to play.",
  191. maxCount: maxCount,
  192. canEndNotMax: false,
  193. isShowOpponent: true,
  194. mode: SelectCardEffect.Mode.Custom,
  195. root: SelectCardEffect.Root.Custom,
  196. customRootCardList: selectedPermanent.DigivolutionCards,
  197. canLookReverseCard: true,
  198. selectPlayer: card.Owner,
  199. cardEffect: activateClass);
  200. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  201. yield return StartCoroutine(selectCardEffect.Activate());
  202. IEnumerator SelectCardCoroutine(CardSource cardSource)
  203. {
  204. selectedCards.Add(cardSource);
  205. yield return null;
  206. }
  207. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  208. cardSources: selectedCards,
  209. activateClass: activateClass,
  210. payCost: false,
  211. isTapped: false,
  212. root: SelectCardEffect.Root.DigivolutionCards,
  213. activateETB: true));
  214. }
  215. }
  216. }
  217. return cardEffects;
  218. }
  219. }
  220. }