Garurumon_BT15_024.cs 12 KB

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