BT15_024.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_024 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.ContainsCardName("Gabumon"))
  18. {
  19. if (targetPermanent.TopCard.HasLevel)
  20. {
  21. if (targetPermanent.Level == 3)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region When Digivolving
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Draw 1 or Play 1 tamer", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[When Digivolving] If you have a Tamer with [Matt Ishida] in its name, <Draw 1>. If you don't have a Tamer with [Matt Ishida] in its name, you may play 1 Tamer card with [Matt Ishida] in its name from your hand with the play cost reduced by 3.";
  42. }
  43. bool PermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  46. {
  47. if (permanent.IsTamer)
  48. {
  49. if (permanent.TopCard.ContainsCardName("Matt Ishida"))
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanSelectCardCondition(CardSource cardSource)
  58. {
  59. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass))
  60. {
  61. if (cardSource.IsTamer)
  62. {
  63. if (cardSource.ContainsCardName("Matt Ishida"))
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. if (CardEffectCommons.IsExistOnBattleArea(card))
  78. {
  79. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  80. {
  81. if (card.Owner.LibraryCards.Count >= 1)
  82. {
  83. return true;
  84. }
  85. }
  86. if (!CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  87. {
  88. if (card.Owner.HandCards.Count >= 1)
  89. {
  90. return true;
  91. }
  92. }
  93. }
  94. return false;
  95. }
  96. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  97. {
  98. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  101. }
  102. if (!CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  103. {
  104. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  105. {
  106. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  107. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  108. };
  109. string selectPlayerMessage = "Will you play 1 [Matt Ishida] from your hand?";
  110. string notSelectPlayerMessage = "The opponent is choosing whether or not to play a Tamer.";
  111. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  112. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  113. bool willPlayMatt = GManager.instance.userSelectionManager.SelectedBoolValue;
  114. if (willPlayMatt)
  115. {
  116. #region reduce play cost
  117. ChangeCostClass changeCostClass = new ChangeCostClass();
  118. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition1, card);
  119. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  120. Func<EffectTiming, ICardEffect> getCardEffect = GetCardEffect;
  121. card.Owner.UntilCalculateFixedCostEffect.Add(getCardEffect);
  122. ICardEffect GetCardEffect(EffectTiming _timing)
  123. {
  124. if (_timing == EffectTiming.None)
  125. {
  126. return changeCostClass;
  127. }
  128. return null;
  129. }
  130. bool CanUseCondition1(Hashtable hashtable)
  131. {
  132. return true;
  133. }
  134. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  135. {
  136. if (CardSourceCondition(cardSource))
  137. {
  138. if (RootCondition(root))
  139. {
  140. if (PermanentsCondition(targetPermanents))
  141. {
  142. Cost -= 3;
  143. }
  144. }
  145. }
  146. return Cost;
  147. }
  148. bool PermanentsCondition(List<Permanent> targetPermanents)
  149. {
  150. if (targetPermanents == null)
  151. {
  152. return true;
  153. }
  154. else
  155. {
  156. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  157. {
  158. return true;
  159. }
  160. }
  161. return false;
  162. }
  163. bool CardSourceCondition(CardSource cardSource)
  164. {
  165. if (cardSource.IsTamer)
  166. {
  167. if (cardSource.ContainsCardName("Matt Ishida"))
  168. {
  169. return true;
  170. }
  171. }
  172. return false;
  173. }
  174. bool RootCondition(SelectCardEffect.Root root)
  175. {
  176. return true;
  177. }
  178. bool isUpDown()
  179. {
  180. return true;
  181. }
  182. #endregion
  183. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  184. {
  185. List<CardSource> selectedCards = new List<CardSource>();
  186. int maxCount = 1;
  187. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  188. selectHandEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: CanSelectCardCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: maxCount,
  194. canNoSelect: true,
  195. canEndNotMax: false,
  196. isShowOpponent: true,
  197. selectCardCoroutine: SelectCardCoroutine,
  198. afterSelectCardCoroutine: null,
  199. mode: SelectHandEffect.Mode.Custom,
  200. cardEffect: activateClass);
  201. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  202. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  203. yield return StartCoroutine(selectHandEffect.Activate());
  204. IEnumerator SelectCardCoroutine(CardSource cardSource)
  205. {
  206. selectedCards.Add(cardSource);
  207. yield return null;
  208. }
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  210. cardSources: selectedCards,
  211. activateClass: activateClass,
  212. payCost: true,
  213. isTapped: false,
  214. root: SelectCardEffect.Root.Hand,
  215. activateETB: true));
  216. }
  217. #region release effect reducing play cost
  218. card.Owner.UntilCalculateFixedCostEffect.Remove(getCardEffect);
  219. #endregion
  220. }
  221. }
  222. }
  223. }
  224. #endregion
  225. if (timing == EffectTiming.OnAllyAttack)
  226. {
  227. ActivateClass activateClass = new ActivateClass();
  228. activateClass.SetUpICardEffect("Draw 1", CanUseCondition, card);
  229. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  230. activateClass.SetIsInheritedEffect(true);
  231. activateClass.SetHashString("Draw1_BT15_024");
  232. cardEffects.Add(activateClass);
  233. string EffectDiscription()
  234. {
  235. return "[When Attacking][Once Per Turn] <Draw 1>. (Draw 1 card from your deck.)";
  236. }
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  240. }
  241. bool CanActivateCondition(Hashtable hashtable)
  242. {
  243. if (CardEffectCommons.IsExistOnBattleArea(card))
  244. {
  245. return true;
  246. }
  247. return false;
  248. }
  249. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  250. {
  251. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  252. }
  253. }
  254. return cardEffects;
  255. }
  256. }
  257. }