BT17_082.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_082 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region On Play
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Labramon] or [Seasarmon] from hand or digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return
  22. "[On Play] You may play 1 [Labramon]/[Seasarmon] from your hand or from one of your Digimon's digivolution cards without paying the cost.";
  23. }
  24. bool CanSelectCardCondition(CardSource cardSource)
  25. {
  26. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  27. {
  28. if (cardSource.IsDigimon)
  29. {
  30. return cardSource.EqualsCardName("Labramon") ||
  31. cardSource.EqualsCardName("Seasarmon");
  32. }
  33. }
  34. return false;
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  39. {
  40. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  41. {
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  50. }
  51. bool CanActivateCondition(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.IsExistOnBattleArea(card))
  54. {
  55. if (card.Owner.HandCards.Count >= 1)
  56. {
  57. return true;
  58. }
  59. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  69. bool canSelectDigivolutionCards = CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  70. if (canSelectHand || canSelectDigivolutionCards)
  71. {
  72. if (canSelectHand && canSelectDigivolutionCards)
  73. {
  74. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  75. {
  76. new(message: "From hand", value: true, spriteIndex: 0),
  77. new(message: "From digivolution cards", value: false, spriteIndex: 1),
  78. };
  79. string selectPlayerMessage = "From which area do you play a card?";
  80. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  81. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements,
  82. selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage,
  83. notSelectPlayerMessage: notSelectPlayerMessage);
  84. }
  85. else
  86. {
  87. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  88. }
  89. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager
  90. .WaitForEndSelect());
  91. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  92. List<CardSource> selectedCards = new List<CardSource>();
  93. IEnumerator SelectCardCoroutine(CardSource cardSource)
  94. {
  95. selectedCards.Add(cardSource);
  96. yield return null;
  97. }
  98. if (fromHand)
  99. {
  100. int maxCount = Math.Min(1, card.Owner.HandCards.Count(CanSelectCardCondition));
  101. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  102. selectHandEffect.SetUp(
  103. selectPlayer: card.Owner,
  104. canTargetCondition: CanSelectCardCondition,
  105. canTargetCondition_ByPreSelecetedList: null,
  106. canEndSelectCondition: null,
  107. maxCount: maxCount,
  108. canNoSelect: true,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. selectCardCoroutine: SelectCardCoroutine,
  112. afterSelectCardCoroutine: null,
  113. mode: SelectHandEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectHandEffect.SetUpCustomMessage("Select 1 card to play.",
  116. "The opponent is selecting 1 card to play.");
  117. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  118. yield return StartCoroutine(selectHandEffect.Activate());
  119. }
  120. else
  121. {
  122. int maxCount = Math.Min(1,
  123. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  124. SelectPermanentEffect selectPermanentEffect =
  125. GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: SelectPermanentCoroutine,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectPermanentEffect.SetUpCustomMessage(
  139. "Select 1 Digimon which has digivolution cards.",
  140. "The opponent is selecting 1 Digimon which has digivolution cards.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. if (permanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  145. {
  146. maxCount = Math.Min(1,
  147. permanent.DigivolutionCards.Count(CanSelectCardCondition));
  148. SelectCardEffect selectCardEffect =
  149. GManager.instance.GetComponent<SelectCardEffect>();
  150. selectCardEffect.SetUp(
  151. canTargetCondition: CanSelectCardCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. canNoSelect: () => true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. message: "Select 1 digivolution card to play.",
  158. maxCount: maxCount,
  159. canEndNotMax: false,
  160. isShowOpponent: true,
  161. mode: SelectCardEffect.Mode.Custom,
  162. root: SelectCardEffect.Root.Custom,
  163. customRootCardList: permanent.DigivolutionCards,
  164. canLookReverseCard: true,
  165. selectPlayer: card.Owner,
  166. cardEffect: activateClass);
  167. selectCardEffect.SetUpCustomMessage(
  168. "Select 1 digivolution card to play.",
  169. "The opponent is selecting 1 digivolution card to play.");
  170. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  171. yield return StartCoroutine(selectCardEffect.Activate());
  172. }
  173. }
  174. }
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  176. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  177. root: (fromHand) ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.DigivolutionCards,
  178. activateETB: true));
  179. }
  180. }
  181. }
  182. #endregion
  183. #region Your Turn
  184. if (timing == EffectTiming.OnEnterFieldAnyone)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect("1 of your blue Digimon gains [Rush] for the turn", CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true,
  189. EffectDescription());
  190. cardEffects.Add(activateClass);
  191. string EffectDescription()
  192. {
  193. return
  194. "[All Turns] When one of your Digimon is played from digivolution cards, by suspending this Tamer, 1 of your blue Digimon gains for the turn.";
  195. }
  196. bool PermanentCondition(Permanent permanent)
  197. {
  198. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  199. }
  200. bool IsBluePermanentCondition(Permanent permanent)
  201. {
  202. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  203. permanent.IsDigimon &&
  204. permanent.TopCard.CardColors.Contains(CardColor.Blue);
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. if (CardEffectCommons.IsExistOnBattleArea(card))
  209. {
  210. if (CardEffectCommons.IsOwnerTurn(card))
  211. {
  212. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  213. {
  214. return CardEffectCommons.IsFromDigimonDigivolutionCards(hashtable);
  215. }
  216. }
  217. }
  218. return false;
  219. }
  220. bool CanActivateCondition(Hashtable hashtable)
  221. {
  222. if (CardEffectCommons.IsExistOnBattleArea(card))
  223. {
  224. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  225. {
  226. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsBluePermanentCondition);
  227. }
  228. }
  229. return false;
  230. }
  231. IEnumerator ActivateCoroutine(Hashtable hashtable)
  232. {
  233. yield return ContinuousController.instance.StartCoroutine(
  234. new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() },
  235. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  236. if (CardEffectCommons.HasMatchConditionPermanent(IsBluePermanentCondition))
  237. {
  238. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsBluePermanentCondition));
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: IsBluePermanentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: SelectPermanentCoroutine,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain Rush.",
  253. "The opponent is selecting 1 Digimon that will gain Rush.");
  254. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  255. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  256. {
  257. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRush(targetPermanent: permanent,
  258. effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  259. }
  260. }
  261. }
  262. }
  263. #endregion
  264. #region Security Effect
  265. if (timing == EffectTiming.SecuritySkill)
  266. {
  267. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  268. }
  269. #endregion
  270. return cardEffects;
  271. }
  272. }
  273. }