BT9_054.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 BT9_054 : 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.OnDeclaration)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Place this card to digivolution cards", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Hand][Main] If you have a Digimon with [Justimon] or [Raidenmon] in its name in play, you may pay 1 memory to place this card under that Digimon as its bottom digivolution card.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.TopCard.ContainsCardName("Justimon") || permanent.TopCard.ContainsCardName("Raidenmon"))
  28. {
  29. if (!permanent.IsToken)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. if (card.Owner.HandCards.Contains(card))
  40. {
  41. if (card.Owner.MaxMemoryCost >= 1)
  42. {
  43. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  44. {
  45. return true;
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  52. {
  53. if (card.Owner.HandCards.Contains(card))
  54. {
  55. if (card.Owner.MaxMemoryCost >= 1)
  56. {
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(-1, activateClass));
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. Permanent selectedPermanent = permanent;
  79. if (selectedPermanent != null)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. if (timing == EffectTiming.OnEnterFieldAnyone)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("Trash 1 card from hand to suspend 1 Digimon", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[When Digivolving] You may trash 1 Digimon card with [Machine] or [Cyborg] in its traits in your hand to suspend 1 of your opponent's Digimon.";
  98. }
  99. bool CanSelectCardCondition(CardSource cardSource)
  100. {
  101. if (cardSource.CardTraits.Contains("Machine"))
  102. {
  103. return true;
  104. }
  105. if (cardSource.CardTraits.Contains("Cyborg"))
  106. {
  107. return true;
  108. }
  109. return false;
  110. }
  111. bool CanSelectPermanentCondition(Permanent permanent)
  112. {
  113. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  114. }
  115. bool CanUseCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  118. }
  119. bool CanActivateCondition(Hashtable hashtable)
  120. {
  121. if (CardEffectCommons.IsExistOnBattleArea(card))
  122. {
  123. if (card.Owner.HandCards.Count >= 1)
  124. {
  125. return true;
  126. }
  127. }
  128. return false;
  129. }
  130. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  131. {
  132. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  133. {
  134. bool discarded = false;
  135. int discardCount = 1;
  136. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  137. selectHandEffect.SetUp(
  138. selectPlayer: card.Owner,
  139. canTargetCondition: CanSelectCardCondition,
  140. canTargetCondition_ByPreSelecetedList: null,
  141. canEndSelectCondition: null,
  142. maxCount: discardCount,
  143. canNoSelect: true,
  144. canEndNotMax: false,
  145. isShowOpponent: true,
  146. selectCardCoroutine: null,
  147. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  148. mode: SelectHandEffect.Mode.Discard,
  149. cardEffect: activateClass);
  150. yield return StartCoroutine(selectHandEffect.Activate());
  151. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  152. {
  153. if (cardSources.Count >= 1)
  154. {
  155. discarded = true;
  156. yield return null;
  157. }
  158. }
  159. if (discarded)
  160. {
  161. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  162. {
  163. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  164. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  165. selectPermanentEffect.SetUp(
  166. selectPlayer: card.Owner,
  167. canTargetCondition: CanSelectPermanentCondition,
  168. canTargetCondition_ByPreSelecetedList: null,
  169. canEndSelectCondition: null,
  170. maxCount: maxCount,
  171. canNoSelect: false,
  172. canEndNotMax: false,
  173. selectPermanentCoroutine: null,
  174. afterSelectPermanentCoroutine: null,
  175. mode: SelectPermanentEffect.Mode.Tap,
  176. cardEffect: activateClass);
  177. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  178. }
  179. }
  180. }
  181. }
  182. }
  183. if (timing == EffectTiming.OnAllyAttack)
  184. {
  185. ActivateClass activateClass = new ActivateClass();
  186. activateClass.SetUpICardEffect("Suspend 1 Digimon with 5000 DP or less and it can't unsuspend", CanUseCondition, card);
  187. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  188. activateClass.SetIsInheritedEffect(true);
  189. cardEffects.Add(activateClass);
  190. string EffectDiscription()
  191. {
  192. return "[When Attacking] Suspend 1 of your opponent's Digimon with 5000 DP or less. That Digimon doesn't unsuspend during your opponent's next unsuspend phase.";
  193. }
  194. bool CanSelectPermanentCondition(Permanent permanent)
  195. {
  196. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  197. {
  198. if (permanent.DP <= 5000)
  199. {
  200. return true;
  201. }
  202. }
  203. return false;
  204. }
  205. bool CanUseCondition(Hashtable hashtable)
  206. {
  207. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  208. }
  209. bool CanActivateCondition(Hashtable hashtable)
  210. {
  211. if (CardEffectCommons.IsExistOnBattleArea(card))
  212. {
  213. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  214. {
  215. return true;
  216. }
  217. }
  218. return false;
  219. }
  220. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  221. {
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  223. {
  224. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: null,
  235. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  236. mode: SelectPermanentEffect.Mode.Tap,
  237. cardEffect: activateClass);
  238. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  239. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  240. {
  241. foreach (Permanent selectedPermanent in permanents)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendNextActivePhase(
  244. targetPermanent: selectedPermanent,
  245. activateClass: activateClass
  246. ));
  247. }
  248. }
  249. }
  250. }
  251. }
  252. return cardEffects;
  253. }
  254. }