BT14_030.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT14
  5. {
  6. public class BT14_030 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.OnEnterFieldAnyone)
  12. {
  13. ActivateClass activateClass = new ActivateClass();
  14. activateClass.SetUpICardEffect("Return Digimon to hand", CanUseCondition, card);
  15. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  16. cardEffects.Add(activateClass);
  17. string EffectDiscription()
  18. {
  19. return "[On Play] By returning 1 of your opponent's level 3 Digimon or 1 of your Digimon to the hand, return 1 of your opponent's Digimon whose level is less than or equal to the returned Digimon's level to the hand.";
  20. }
  21. bool CanSelectPermanentCondition(Permanent permanent)
  22. {
  23. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  24. {
  25. if (permanent.TopCard.HasLevel)
  26. {
  27. if (permanent.Level == 3)
  28. {
  29. return true;
  30. }
  31. }
  32. }
  33. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  34. {
  35. return true;
  36. }
  37. return false;
  38. }
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  42. }
  43. bool CanActivateCondition(Hashtable hashtable)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  48. {
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. Permanent bounceTargetPermanent = null;
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: CanSelectPermanentCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: true,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. bounceTargetPermanent = permanent;
  78. yield return null;
  79. }
  80. if (bounceTargetPermanent != null)
  81. {
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  83. targetPermanents: new List<Permanent>() { bounceTargetPermanent },
  84. activateClass: activateClass,
  85. successProcess: SuccessProcess(),
  86. failureProcess: null));
  87. IEnumerator SuccessProcess()
  88. {
  89. bool CanSelectPermanentCondition1(Permanent permanent)
  90. {
  91. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  92. {
  93. if (bounceTargetPermanent.LevelJustBeforeRemoveField > 0)
  94. {
  95. if (permanent.Level <= bounceTargetPermanent.LevelJustBeforeRemoveField)
  96. {
  97. if (permanent.TopCard.HasLevel)
  98. {
  99. return true;
  100. }
  101. }
  102. }
  103. }
  104. return false;
  105. }
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  107. {
  108. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  109. selectPermanentEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectPermanentCondition1,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: false,
  116. canEndNotMax: false,
  117. selectPermanentCoroutine: null,
  118. afterSelectPermanentCoroutine: null,
  119. mode: SelectPermanentEffect.Mode.Bounce,
  120. cardEffect: activateClass);
  121. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect("Return Digimon to hand", CanUseCondition, card);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  133. cardEffects.Add(activateClass);
  134. string EffectDiscription()
  135. {
  136. return "[When Digivolving] By returning 1 of your opponent's level 3 Digimon or 1 of your Digimon to the hand, return 1 of your opponent's Digimon whose level is less than or equal to the returned Digimon's level to the hand.";
  137. }
  138. bool CanSelectPermanentCondition(Permanent permanent)
  139. {
  140. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  141. {
  142. if (permanent.TopCard.HasLevel)
  143. {
  144. if (permanent.Level == 3)
  145. {
  146. return true;
  147. }
  148. }
  149. }
  150. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  151. {
  152. return true;
  153. }
  154. return false;
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  159. }
  160. bool CanActivateCondition(Hashtable hashtable)
  161. {
  162. if (CardEffectCommons.IsExistOnBattleArea(card))
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  172. {
  173. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  174. {
  175. Permanent bounceTargetPermanent = null;
  176. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  177. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  178. selectPermanentEffect.SetUp(
  179. selectPlayer: card.Owner,
  180. canTargetCondition: CanSelectPermanentCondition,
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. maxCount: maxCount,
  184. canNoSelect: true,
  185. canEndNotMax: false,
  186. selectPermanentCoroutine: SelectPermanentCoroutine,
  187. afterSelectPermanentCoroutine: null,
  188. mode: SelectPermanentEffect.Mode.Custom,
  189. cardEffect: activateClass);
  190. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to return to hand.", "The opponent is selecting 1 Digimon to return to hand.");
  191. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  192. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  193. {
  194. bounceTargetPermanent = permanent;
  195. yield return null;
  196. }
  197. if (bounceTargetPermanent != null)
  198. {
  199. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.BouncePeremanentAndProcessAccordingToResult(
  200. targetPermanents: new List<Permanent>() { bounceTargetPermanent },
  201. activateClass: activateClass,
  202. successProcess: SuccessProcess(),
  203. failureProcess: null));
  204. IEnumerator SuccessProcess()
  205. {
  206. bool CanSelectPermanentCondition1(Permanent permanent)
  207. {
  208. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  209. {
  210. if (bounceTargetPermanent.LevelJustBeforeRemoveField > 0)
  211. {
  212. if (permanent.Level <= bounceTargetPermanent.LevelJustBeforeRemoveField)
  213. {
  214. if (permanent.TopCard.HasLevel)
  215. {
  216. return true;
  217. }
  218. }
  219. }
  220. }
  221. return false;
  222. }
  223. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  224. {
  225. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition1,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: null,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Bounce,
  237. cardEffect: activateClass);
  238. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  239. }
  240. }
  241. }
  242. }
  243. }
  244. }
  245. if (timing == EffectTiming.OnPermamemtReturnedToHand)
  246. {
  247. ActivateClass activateClass = new ActivateClass();
  248. activateClass.SetUpICardEffect("Recovery +1 (Deck)", CanUseCondition, card);
  249. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  250. activateClass.SetHashString("Recovery_BT14_030");
  251. cardEffects.Add(activateClass);
  252. string EffectDiscription()
  253. {
  254. return "[Your Turn][Once Per Turn] When another Digimon returns to the hand, <Recovery +1 (Deck)>.";
  255. }
  256. bool PermanentCondition(Permanent permanent)
  257. {
  258. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  259. {
  260. if (permanent.IsDigimon)
  261. {
  262. if (permanent != card.PermanentOfThisCard())
  263. {
  264. return true;
  265. }
  266. }
  267. }
  268. return false;
  269. }
  270. bool CanUseCondition(Hashtable hashtable)
  271. {
  272. if (CardEffectCommons.IsExistOnBattleArea(card))
  273. {
  274. if (CardEffectCommons.IsOwnerTurn(card))
  275. {
  276. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition))
  277. {
  278. return true;
  279. }
  280. }
  281. }
  282. return false;
  283. }
  284. bool CanActivateCondition(Hashtable hashtable)
  285. {
  286. if (CardEffectCommons.IsExistOnBattleArea(card))
  287. {
  288. return true;
  289. }
  290. return false;
  291. }
  292. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  293. {
  294. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  295. }
  296. }
  297. return cardEffects;
  298. }
  299. }
  300. }