BT18_024.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT18
  6. {
  7. public class BT18_024 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Lanamon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. if (timing == EffectTiming.None)
  22. {
  23. bool PermanentCondition(Permanent targetPermanent)
  24. {
  25. return targetPermanent.IsTamer && targetPermanent.TopCard.CardColors.Contains(CardColor.Blue);
  26. }
  27. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  28. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  29. card: card, condition: null));
  30. }
  31. #endregion
  32. #region On Play
  33. if (timing == EffectTiming.OnEnterFieldAnyone)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("Return opponent's Digimon or place a digivolution card", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. cardEffects.Add(activateClass);
  39. string EffectDiscription()
  40. {
  41. return "[On Play] f a level 3 Digimon card Is in this Digimon's digivolution cards, return 1 of your opponent's level 4 or lower Digimon to the hand. If there isn't, you may place 1 blue level 3 Digimon card from your hand as this Digimon's bottom digivolution card.";
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  46. {
  47. if (permanent.IsDigimon && permanent.TopCard.HasLevel)
  48. {
  49. if (permanent.Level <= 4)
  50. {
  51. return true;
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. bool CanSelectCardCondition(CardSource cardSource)
  58. {
  59. if (cardSource.IsDigimon)
  60. {
  61. if (cardSource.IsLevel3)
  62. {
  63. if (cardSource.CardColors.Contains(CardColor.Blue))
  64. {
  65. return true;
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. bool CanUseCondition(Hashtable hashtable)
  72. {
  73. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  74. }
  75. bool CanActivateCondition(Hashtable hashtable)
  76. {
  77. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  78. }
  79. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  80. {
  81. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.Level == 3) >= 1)
  82. {
  83. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  84. {
  85. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  86. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  87. selectPermanentEffect.SetUp(
  88. selectPlayer: card.Owner,
  89. canTargetCondition: CanSelectPermanentCondition,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. maxCount: maxCount,
  93. canNoSelect: false,
  94. canEndNotMax: false,
  95. selectPermanentCoroutine: null,
  96. afterSelectPermanentCoroutine: null,
  97. mode: SelectPermanentEffect.Mode.Bounce,
  98. cardEffect: activateClass);
  99. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  100. }
  101. }
  102. else
  103. {
  104. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  105. {
  106. List<CardSource> selectedCards = new List<CardSource>();
  107. int maxCount = 1;
  108. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  109. selectHandEffect.SetUp(
  110. selectPlayer: card.Owner,
  111. canTargetCondition: CanSelectCardCondition,
  112. canTargetCondition_ByPreSelecetedList: null,
  113. canEndSelectCondition: null,
  114. maxCount: maxCount,
  115. canNoSelect: true,
  116. canEndNotMax: false,
  117. isShowOpponent: true,
  118. selectCardCoroutine: SelectCardCoroutine,
  119. afterSelectCardCoroutine: null,
  120. mode: SelectHandEffect.Mode.Custom,
  121. cardEffect: activateClass);
  122. selectHandEffect.SetUpCustomMessage(
  123. "Select 1 card to place on the bottom of digivolution cards.",
  124. "The opponent is selecting 1 card to place on the bottom of digivolution cards.");
  125. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  126. yield return StartCoroutine(selectHandEffect.Activate());
  127. IEnumerator SelectCardCoroutine(CardSource cardSource)
  128. {
  129. selectedCards.Add(cardSource);
  130. yield return null;
  131. }
  132. if (selectedCards.Count >= 1)
  133. {
  134. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  135. .AddDigivolutionCardsBottom(selectedCards, activateClass));
  136. }
  137. }
  138. }
  139. }
  140. }
  141. #endregion
  142. #region When Digivolving
  143. if (timing == EffectTiming.OnEnterFieldAnyone)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect("Return opponent's Digimon or place a digivolution card", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  148. cardEffects.Add(activateClass);
  149. string EffectDiscription()
  150. {
  151. return "[When Digivolving] If a level 3 Digimon card Is in this Digimon's digivolution cards, return 1 of your opponent's level 4 or lower Digimon to the hand. If there isn't, you may place 1 blue level 3 Digimon card from your hand as this Digimon's bottom digivolution card.";
  152. }
  153. bool CanSelectPermanentCondition(Permanent permanent)
  154. {
  155. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  156. {
  157. if (permanent.IsDigimon && permanent.TopCard.HasLevel)
  158. {
  159. if (permanent.Level <= 4)
  160. {
  161. return true;
  162. }
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanSelectCardCondition(CardSource cardSource)
  168. {
  169. if (cardSource.IsDigimon)
  170. {
  171. if (cardSource.IsLevel3)
  172. {
  173. if (cardSource.CardColors.Contains(CardColor.Blue))
  174. {
  175. return true;
  176. }
  177. }
  178. }
  179. return false;
  180. }
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  184. {
  185. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  186. }
  187. return false;
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  194. {
  195. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.Level == 3) >= 1)
  196. {
  197. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  198. {
  199. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  200. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: CanSelectPermanentCondition,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: maxCount,
  207. canNoSelect: false,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: null,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Bounce,
  212. cardEffect: activateClass);
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. }
  215. }
  216. else
  217. {
  218. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  219. {
  220. List<CardSource> selectedCards = new List<CardSource>();
  221. int maxCount = 1;
  222. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  223. selectHandEffect.SetUp(
  224. selectPlayer: card.Owner,
  225. canTargetCondition: CanSelectCardCondition,
  226. canTargetCondition_ByPreSelecetedList: null,
  227. canEndSelectCondition: null,
  228. maxCount: maxCount,
  229. canNoSelect: true,
  230. canEndNotMax: false,
  231. isShowOpponent: true,
  232. selectCardCoroutine: SelectCardCoroutine,
  233. afterSelectCardCoroutine: null,
  234. mode: SelectHandEffect.Mode.Custom,
  235. cardEffect: activateClass);
  236. selectHandEffect.SetUpCustomMessage(
  237. "Select 1 card to place on the bottom of digivolution cards.",
  238. "The opponent is selecting 1 card to place on the bottom of digivolution cards.");
  239. selectHandEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  240. yield return StartCoroutine(selectHandEffect.Activate());
  241. IEnumerator SelectCardCoroutine(CardSource cardSource)
  242. {
  243. selectedCards.Add(cardSource);
  244. yield return null;
  245. }
  246. if (selectedCards.Count >= 1)
  247. {
  248. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard()
  249. .AddDigivolutionCardsBottom(selectedCards, activateClass));
  250. }
  251. }
  252. }
  253. }
  254. }
  255. #endregion
  256. #region Inherit
  257. if (timing == EffectTiming.OnAllyAttack)
  258. {
  259. ActivateClass activateClass = new ActivateClass();
  260. activateClass.SetUpICardEffect("Return Digimon to hand", CanUseCondition, card);
  261. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  262. activateClass.SetHashString("ReturnDigimon_BT18-024");
  263. activateClass.SetIsInheritedEffect(true);
  264. cardEffects.Add(activateClass);
  265. string EffectDiscription()
  266. {
  267. return "[When Attacking] [Once Per Turn] You may return 1 level 3 Digimon to the hand.";
  268. }
  269. bool CanSelectPermanentCondition(Permanent permanent)
  270. {
  271. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent))
  272. {
  273. if (permanent.IsDigimon && permanent.TopCard.HasLevel)
  274. {
  275. if (permanent.Level == 3)
  276. {
  277. return true;
  278. }
  279. }
  280. }
  281. return false;
  282. }
  283. bool CanUseCondition(Hashtable hashtable)
  284. {
  285. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  286. }
  287. bool CanActivateCondition(Hashtable hashtable)
  288. {
  289. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  290. {
  291. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  292. {
  293. return true;
  294. }
  295. }
  296. return false;
  297. }
  298. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  299. {
  300. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  301. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  302. selectPermanentEffect.SetUp(
  303. selectPlayer: card.Owner,
  304. canTargetCondition: CanSelectPermanentCondition,
  305. canTargetCondition_ByPreSelecetedList: null,
  306. canEndSelectCondition: null,
  307. maxCount: maxCount,
  308. canNoSelect: true,
  309. canEndNotMax: false,
  310. selectPermanentCoroutine: null,
  311. afterSelectPermanentCoroutine: null,
  312. mode: SelectPermanentEffect.Mode.Bounce,
  313. cardEffect: activateClass);
  314. selectPermanentEffect.SetUpCustomMessage("Select 1 level 3 Digimon to return to hand.", "The opponent is selecting 1 level 3 Digimon to return to hand.");
  315. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  316. }
  317. }
  318. #endregion
  319. return cardEffects;
  320. }
  321. }
  322. }