BT14_040.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_040 : 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.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Place 1 Tamer card from hand at the top of security", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] You may place 1 Tamer card from your hand on top of your security stack. ";
  20. }
  21. bool CanSelectCardCondition(CardSource cardSource)
  22. {
  23. return cardSource.IsTamer;
  24. }
  25. bool CanUseCondition(Hashtable hashtable)
  26. {
  27. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. if (CardEffectCommons.IsExistOnBattleArea(card))
  32. {
  33. if (card.Owner.CanAddSecurity(activateClass))
  34. {
  35. if (card.Owner.HandCards.Count >= 1)
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. return false;
  42. }
  43. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  44. {
  45. if (card.Owner.CanAddSecurity(activateClass))
  46. {
  47. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  48. {
  49. List<CardSource> selectedCards = new List<CardSource>();
  50. int maxCount = 1;
  51. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: CanSelectCardCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. isShowOpponent: true,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. mode: SelectHandEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of security.", "The opponent is selecting 1 card to place on top of security.");
  66. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  67. yield return StartCoroutine(selectHandEffect.Activate());
  68. IEnumerator SelectCardCoroutine(CardSource cardSource)
  69. {
  70. selectedCards.Add(cardSource);
  71. yield return null;
  72. }
  73. foreach (CardSource cardSource in selectedCards)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource));
  76. }
  77. }
  78. }
  79. }
  80. }
  81. if (timing == EffectTiming.OnEnterFieldAnyone)
  82. {
  83. ActivateClass activateClass = new ActivateClass();
  84. activateClass.SetUpICardEffect("Place 1 Tamer card from hand at the top of security", CanUseCondition, card);
  85. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  86. cardEffects.Add(activateClass);
  87. string EffectDiscription()
  88. {
  89. return "[When Digivolving] You may place 1 Tamer card from your hand on top of your security stack. ";
  90. }
  91. bool CanSelectCardCondition(CardSource cardSource)
  92. {
  93. return cardSource.IsTamer;
  94. }
  95. bool CanUseCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  98. }
  99. bool CanActivateCondition(Hashtable hashtable)
  100. {
  101. if (CardEffectCommons.IsExistOnBattleArea(card))
  102. {
  103. if (card.Owner.CanAddSecurity(activateClass))
  104. {
  105. if (card.Owner.HandCards.Count >= 1)
  106. {
  107. return true;
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. if (card.Owner.CanAddSecurity(activateClass))
  116. {
  117. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  118. {
  119. List<CardSource> selectedCards = new List<CardSource>();
  120. int maxCount = 1;
  121. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  122. selectHandEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectCardCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: true,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. selectCardCoroutine: SelectCardCoroutine,
  132. afterSelectCardCoroutine: null,
  133. mode: SelectHandEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. selectHandEffect.SetUpCustomMessage("Select 1 card to place on top of security.", "The opponent is selecting 1 card to place on top of security.");
  136. selectHandEffect.SetUpCustomMessage_ShowCard("Security Top Card");
  137. yield return StartCoroutine(selectHandEffect.Activate());
  138. IEnumerator SelectCardCoroutine(CardSource cardSource)
  139. {
  140. selectedCards.Add(cardSource);
  141. yield return null;
  142. }
  143. foreach (CardSource cardSource in selectedCards)
  144. {
  145. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(cardSource));
  146. }
  147. }
  148. }
  149. }
  150. }
  151. if (timing == EffectTiming.OnEnterFieldAnyone)
  152. {
  153. ActivateClass activateClass = new ActivateClass();
  154. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  155. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  156. activateClass.SetHashString("Play1Digimon_Bt14_040");
  157. cardEffects.Add(activateClass);
  158. string EffectDiscription()
  159. {
  160. return "[All Turns][Once Per Turn] When you play a Tamer, you may play 1 level 3 Digimon card from your hand without paying the cost.";
  161. }
  162. bool PermanentCondition(Permanent permanent)
  163. {
  164. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  165. {
  166. if (permanent.IsTamer)
  167. {
  168. return true;
  169. }
  170. }
  171. return false;
  172. }
  173. bool CanSelectCardCondition(CardSource cardSource)
  174. {
  175. if (cardSource.IsDigimon)
  176. {
  177. if (cardSource.Level == 3)
  178. {
  179. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  180. {
  181. if (cardSource.HasLevel)
  182. {
  183. return true;
  184. }
  185. }
  186. }
  187. }
  188. return false;
  189. }
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. if (CardEffectCommons.IsExistOnBattleArea(card))
  193. {
  194. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. if (CardEffectCommons.IsExistOnBattleArea(card))
  204. {
  205. if (card.Owner.HandCards.Count >= 1)
  206. {
  207. return true;
  208. }
  209. }
  210. return false;
  211. }
  212. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  213. {
  214. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  215. {
  216. List<CardSource> selectedCards = new List<CardSource>();
  217. int maxCount = 1;
  218. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  219. selectHandEffect.SetUp(
  220. selectPlayer: card.Owner,
  221. canTargetCondition: CanSelectCardCondition,
  222. canTargetCondition_ByPreSelecetedList: null,
  223. canEndSelectCondition: null,
  224. maxCount: maxCount,
  225. canNoSelect: true,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. selectCardCoroutine: SelectCardCoroutine,
  229. afterSelectCardCoroutine: null,
  230. mode: SelectHandEffect.Mode.Custom,
  231. cardEffect: activateClass);
  232. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  233. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  234. yield return StartCoroutine(selectHandEffect.Activate());
  235. IEnumerator SelectCardCoroutine(CardSource cardSource)
  236. {
  237. selectedCards.Add(cardSource);
  238. yield return null;
  239. }
  240. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  241. cardSources: selectedCards,
  242. activateClass: activateClass,
  243. payCost: false,
  244. isTapped: false,
  245. root: SelectCardEffect.Root.Hand,
  246. activateETB: true));
  247. }
  248. }
  249. }
  250. return cardEffects;
  251. }
  252. }
  253. }