BT5_092.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 BT5_092 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Agumon] or [Gabumon] from hand", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] You may play 1 [Agumon] or [Gabumon] from your hand without paying its memory cost.";
  22. }
  23. bool CanSelectCardCondition(CardSource cardSource)
  24. {
  25. if (cardSource != null)
  26. {
  27. if (cardSource.CardNames.Contains("Agumon") || cardSource.CardNames.Contains("Gabumon"))
  28. {
  29. if (cardSource.Owner == card.Owner)
  30. {
  31. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  32. {
  33. return true;
  34. }
  35. }
  36. }
  37. }
  38. return false;
  39. }
  40. bool CanUseCondition(Hashtable hashtable)
  41. {
  42. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  43. }
  44. bool CanActivateCondition(Hashtable hashtable)
  45. {
  46. if (isExistOnField(card))
  47. {
  48. if (card.Owner.HandCards.Count >= 1)
  49. {
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  56. {
  57. if (isExistOnField(card))
  58. {
  59. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  60. {
  61. List<CardSource> selectedCards = new List<CardSource>();
  62. int maxCount = 1;
  63. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  64. selectHandEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: CanSelectCardCondition,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: maxCount,
  70. canNoSelect: true,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. selectCardCoroutine: SelectCardCoroutine,
  74. afterSelectCardCoroutine: null,
  75. mode: SelectHandEffect.Mode.Custom,
  76. cardEffect: activateClass);
  77. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  78. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  79. yield return StartCoroutine(selectHandEffect.Activate());
  80. IEnumerator SelectCardCoroutine(CardSource cardSource)
  81. {
  82. selectedCards.Add(cardSource);
  83. yield return null;
  84. }
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  86. }
  87. }
  88. }
  89. }
  90. if (timing == EffectTiming.BeforePayCost)
  91. {
  92. ActivateClass activateClass = new ActivateClass();
  93. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  94. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  95. activateClass.SetHashString("Digisorption-1_BT5_092");
  96. cardEffects.Add(activateClass);
  97. string EffectDiscription()
  98. {
  99. return "[Main] When digivolving one of your Digimon into a Digimon card in your hand with [Garurumon], [Omnimon], or [Greymon] (other than [DoruGreymon], [BurningGreymon], or [DexDoruGreymon]), in its name, you may suspend this Tamer to reduce the memory cost of the digivolution by 1.";
  100. }
  101. bool PermanentCondition(Permanent permanent)
  102. {
  103. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card);
  104. }
  105. bool CardCondition(CardSource cardSource)
  106. {
  107. if (cardSource.IsDigimon)
  108. {
  109. if (cardSource.HasGarurumonName || cardSource.ContainsCardName("Omnimon") || cardSource.HasGreymonName)
  110. {
  111. if (CardEffectCommons.IsExistOnHand(cardSource))
  112. {
  113. return true;
  114. }
  115. }
  116. }
  117. return false;
  118. }
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (GManager.instance.turnStateMachine.gameContext.TurnPhase == GameContext.phase.Main)
  124. {
  125. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  126. {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanActivateCondition(Hashtable hashtable)
  134. {
  135. if (CardEffectCommons.IsExistOnBattleArea(card))
  136. {
  137. if (CardEffectCommons.CanActivateSuspendCostEffect(card))
  138. {
  139. return true;
  140. }
  141. }
  142. return false;
  143. }
  144. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  145. {
  146. if (isExistOnField(card))
  147. {
  148. if (!card.PermanentOfThisCard().IsSuspended && card.PermanentOfThisCard().CanSuspend)
  149. {
  150. Hashtable hashtable = new Hashtable();
  151. hashtable.Add("CardEffect", activateClass);
  152. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, hashtable).Tap());
  153. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  154. ChangeCostClass changeCostClass = new ChangeCostClass();
  155. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  156. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  157. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  159. bool CanUseCondition1(Hashtable hashtable)
  160. {
  161. return true;
  162. }
  163. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  164. {
  165. if (CardSourceCondition(cardSource))
  166. {
  167. if (RootCondition(root))
  168. {
  169. if (PermanentsCondition(targetPermanents))
  170. {
  171. Cost -= 1;
  172. }
  173. }
  174. }
  175. return Cost;
  176. }
  177. bool PermanentsCondition(List<Permanent> targetPermanents)
  178. {
  179. if (targetPermanents != null)
  180. {
  181. if (targetPermanents.Count(PermanentCondition) >= 1)
  182. {
  183. return true;
  184. }
  185. }
  186. return false;
  187. }
  188. bool PermanentCondition(Permanent targetPermanent)
  189. {
  190. if(targetPermanent != null)
  191. {
  192. if (targetPermanent.TopCard != null)
  193. {
  194. if (targetPermanent.TopCard.Owner == card.Owner)
  195. {
  196. if (targetPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(targetPermanent))
  197. {
  198. return true;
  199. }
  200. }
  201. }
  202. }
  203. return false;
  204. }
  205. bool CardSourceCondition(CardSource cardSource)
  206. {
  207. if (cardSource != null)
  208. {
  209. if (cardSource.Owner == card.Owner)
  210. {
  211. return true;
  212. }
  213. }
  214. return false;
  215. }
  216. bool RootCondition(SelectCardEffect.Root root)
  217. {
  218. return true;
  219. }
  220. bool isUpDown()
  221. {
  222. return true;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. if (timing == EffectTiming.SecuritySkill)
  229. {
  230. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  231. }
  232. return cardEffects;
  233. }
  234. }