BT9_029.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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_029 : 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 return 1 level 4 or lower Digimon to the bottom of deck", 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 place 1 of your opponent's level 4 or lower Digimon at the bottom of its owner's deck.";
  98. }
  99. bool CanSelectCardCondition(CardSource cardSource)
  100. {
  101. if (cardSource != null)
  102. {
  103. if (cardSource.Owner == card.Owner)
  104. {
  105. if (cardSource.CardTraits.Contains("Machine"))
  106. {
  107. return true;
  108. }
  109. if (cardSource.CardTraits.Contains("Cyborg"))
  110. {
  111. return true;
  112. }
  113. }
  114. }
  115. return false;
  116. }
  117. bool CanSelectPermanentCondition(Permanent permanent)
  118. {
  119. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  120. {
  121. if (permanent.Level <= 4)
  122. {
  123. if (permanent.TopCard.HasLevel)
  124. {
  125. return true;
  126. }
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. if (CardEffectCommons.IsExistOnBattleArea(card))
  138. {
  139. if (card.Owner.HandCards.Count >= 1)
  140. {
  141. return true;
  142. }
  143. }
  144. return false;
  145. }
  146. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  147. {
  148. if (isExistOnField(card))
  149. {
  150. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  151. {
  152. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  153. {
  154. bool discarded = false;
  155. int discardCount = 1;
  156. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  157. selectHandEffect.SetUp(
  158. selectPlayer: card.Owner,
  159. canTargetCondition: CanSelectCardCondition,
  160. canTargetCondition_ByPreSelecetedList: null,
  161. canEndSelectCondition: null,
  162. maxCount: discardCount,
  163. canNoSelect: true,
  164. canEndNotMax: false,
  165. isShowOpponent: true,
  166. selectCardCoroutine: null,
  167. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  168. mode: SelectHandEffect.Mode.Discard,
  169. cardEffect: activateClass);
  170. yield return StartCoroutine(selectHandEffect.Activate());
  171. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  172. {
  173. if (cardSources.Count >= 1)
  174. {
  175. discarded = true;
  176. yield return null;
  177. }
  178. }
  179. if (discarded)
  180. {
  181. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  182. {
  183. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  184. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect.SetUp(
  186. selectPlayer: card.Owner,
  187. canTargetCondition: CanSelectPermanentCondition,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: CanEndSelectCondition,
  190. maxCount: maxCount,
  191. canNoSelect: false,
  192. canEndNotMax: false,
  193. selectPermanentCoroutine: null,
  194. afterSelectPermanentCoroutine: null,
  195. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  196. cardEffect: activateClass);
  197. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  198. bool CanEndSelectCondition(List<Permanent> permanents)
  199. {
  200. if (permanents.Count <= 0)
  201. {
  202. return false;
  203. }
  204. return true;
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. }
  212. }
  213. if (timing == EffectTiming.OnAllyAttack)
  214. {
  215. ActivateClass activateClass = new ActivateClass();
  216. activateClass.SetUpICardEffect("Return 1 level 4 or lower Digimon to hand", CanUseCondition, card);
  217. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  218. activateClass.SetIsInheritedEffect(true);
  219. cardEffects.Add(activateClass);
  220. string EffectDiscription()
  221. {
  222. return "[When Attacking] Return 1 of your opponent's level 4 or lower Digimon to its owner's hand.";
  223. }
  224. bool CanSelectPermanentCondition(Permanent permanent)
  225. {
  226. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  227. {
  228. if (permanent.Level <= 4)
  229. {
  230. if (permanent.TopCard.HasLevel)
  231. {
  232. return true;
  233. }
  234. }
  235. }
  236. return false;
  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. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  247. {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  254. {
  255. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  256. {
  257. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  258. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  259. selectPermanentEffect.SetUp(
  260. selectPlayer: card.Owner,
  261. canTargetCondition: CanSelectPermanentCondition,
  262. canTargetCondition_ByPreSelecetedList: null,
  263. canEndSelectCondition: null,
  264. maxCount: maxCount,
  265. canNoSelect: false,
  266. canEndNotMax: false,
  267. selectPermanentCoroutine: null,
  268. afterSelectPermanentCoroutine: null,
  269. mode: SelectPermanentEffect.Mode.Bounce,
  270. cardEffect: activateClass);
  271. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  272. }
  273. }
  274. }
  275. return cardEffects;
  276. }
  277. }