BT18_029.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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_029 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region DigiXros
  13. if (timing == EffectTiming.None)
  14. {
  15. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  16. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  17. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  18. addDigiXrosConditionClass.SetNotShowUI(true);
  19. cardEffects.Add(addDigiXrosConditionClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return true;
  23. }
  24. DigiXrosCondition GetDigiXros(CardSource cardSource)
  25. {
  26. if (cardSource == card)
  27. {
  28. DigiXrosConditionElement elementLanamon =
  29. new DigiXrosConditionElement(CanSelectCardCondition, "Lanamon");
  30. bool CanSelectCardCondition(CardSource conditionCardSource)
  31. {
  32. if (conditionCardSource != null)
  33. {
  34. if (conditionCardSource.Owner == card.Owner)
  35. {
  36. if (conditionCardSource.IsDigimon)
  37. {
  38. if (conditionCardSource.CardNames_DigiXros.Contains("Lanamon"))
  39. {
  40. return true;
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. DigiXrosConditionElement elementCalmaramon =
  48. new DigiXrosConditionElement(CanSelectCardCondition1, "Calmaramon");
  49. bool CanSelectCardCondition1(CardSource conditionCardSource)
  50. {
  51. if (conditionCardSource != null)
  52. {
  53. if (conditionCardSource.Owner == card.Owner)
  54. {
  55. if (conditionCardSource.IsDigimon)
  56. {
  57. if (conditionCardSource.CardNames_DigiXros.Contains("Calmaramon"))
  58. {
  59. return true;
  60. }
  61. }
  62. }
  63. }
  64. return false;
  65. }
  66. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>()
  67. { elementLanamon, elementCalmaramon };
  68. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  69. return digiXrosCondition;
  70. }
  71. return null;
  72. }
  73. }
  74. #endregion
  75. #region On Play
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Return 1 level 4 or lower Digimon to hand", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  81. cardEffects.Add(activateClass);
  82. string EffectDiscription()
  83. {
  84. return "[On Play] Return 1 of your opponent's level 4 or lower Digimon to the hand. For each of your other Digimon, add 1 to this effect's level maximum.";
  85. }
  86. bool CanSelectPermanentCondition(Permanent permanent)
  87. {
  88. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  89. {
  90. int maxCost = 4;
  91. maxCost += card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  92. if (permanent.TopCard.Level <= maxCost)
  93. {
  94. if (permanent.TopCard.HasLevel)
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  105. }
  106. bool CanActivateCondition(Hashtable hashtable)
  107. {
  108. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  109. {
  110. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  111. {
  112. return true;
  113. }
  114. }
  115. return false;
  116. }
  117. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  118. {
  119. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  120. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  121. selectPermanentEffect.SetUp(
  122. selectPlayer: card.Owner,
  123. canTargetCondition: CanSelectPermanentCondition,
  124. canTargetCondition_ByPreSelecetedList: null,
  125. canEndSelectCondition: null,
  126. maxCount: maxCount,
  127. canNoSelect: false,
  128. canEndNotMax: false,
  129. selectPermanentCoroutine: null,
  130. afterSelectPermanentCoroutine: null,
  131. mode: SelectPermanentEffect.Mode.Bounce,
  132. cardEffect: activateClass);
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. }
  135. }
  136. #endregion
  137. #region When Digivolving
  138. if (timing == EffectTiming.OnEnterFieldAnyone)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Return 1 level 4 or lower Digimon to hand", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  143. cardEffects.Add(activateClass);
  144. string EffectDiscription()
  145. {
  146. return "[When Digivolving] Return 1 of your opponent's level 4 or lower Digimon to the hand. For each of your other Digimon, add 1 to this effect's level maximum.";
  147. }
  148. bool CanSelectPermanentCondition(Permanent permanent)
  149. {
  150. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  151. {
  152. int maxCost = 4;
  153. maxCost += card.Owner.GetBattleAreaDigimons().Count((permanent) => permanent != card.PermanentOfThisCard());
  154. if (permanent.TopCard.Level <= maxCost)
  155. {
  156. if (permanent.TopCard.HasLevel)
  157. {
  158. return true;
  159. }
  160. }
  161. }
  162. return false;
  163. }
  164. bool CanUseCondition(Hashtable hashtable)
  165. {
  166. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  167. {
  168. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. return false;
  171. }
  172. bool CanActivateCondition(Hashtable hashtable)
  173. {
  174. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  175. {
  176. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  177. {
  178. return true;
  179. }
  180. }
  181. return false;
  182. }
  183. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  184. {
  185. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: CanSelectPermanentCondition,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: maxCount,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: null,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Bounce,
  198. cardEffect: activateClass);
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  200. }
  201. }
  202. #endregion
  203. #region All Turns
  204. if (timing == EffectTiming.WhenRemoveField)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("Return this Digimon to the hand or play a Digimon from the digivolution sources.", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  209. cardEffects.Add(activateClass);
  210. string EffectDiscription()
  211. {
  212. return "[All Turns] When this Digimon would leave the battle area, you may return to the hand or play 1 level 4 or lower blue Digimon card from this Digimon's digivolution cards without paying the cost.";
  213. }
  214. bool CanSelectCardCondition(CardSource cardSource)
  215. {
  216. if (cardSource != null)
  217. {
  218. if (cardSource.Owner == card.Owner)
  219. {
  220. if (cardSource.IsDigimon)
  221. {
  222. if (cardSource.Level <= 4)
  223. {
  224. if (cardSource.HasCardColor(CardColor.Blue))
  225. {
  226. if (cardSource.HasLevel)
  227. {
  228. return true;
  229. }
  230. }
  231. }
  232. }
  233. }
  234. }
  235. return false;
  236. }
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  240. {
  241. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  242. {
  243. return true;
  244. }
  245. }
  246. return false;
  247. }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  251. {
  252. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  253. {
  254. return true;
  255. }
  256. }
  257. return false;
  258. }
  259. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  260. {
  261. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  262. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  263. if (canSelectDigivolutionCards)
  264. {
  265. if (canSelectDigivolutionCards)
  266. {
  267. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  268. {
  269. new SelectionElement<bool>(message: $"Return to hand", value : true, spriteIndex: 0),
  270. new SelectionElement<bool>(message: $"Play a Digimon", value : false, spriteIndex: 1),
  271. };
  272. string selectPlayerMessage = "Do you want to return to hand or play 1 level 4 or lower Digimon from its digivolution sources";
  273. string notSelectPlayerMessage = "The opponent is choosing which effect to activate.";
  274. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  275. }
  276. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  277. bool toHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  278. List<CardSource> selectedCards = new List<CardSource>();
  279. IEnumerator SelectCardCoroutine(CardSource cardSource)
  280. {
  281. selectedCards.Add(cardSource);
  282. yield return null;
  283. }
  284. if (toHand)
  285. {
  286. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  287. selectCardEffect.SetUp(
  288. canTargetCondition: CanSelectCardCondition,
  289. canTargetCondition_ByPreSelecetedList: null,
  290. canEndSelectCondition: null,
  291. canNoSelect: () => true,
  292. selectCardCoroutine: SelectCardCoroutine,
  293. afterSelectCardCoroutine: null,
  294. message: "Select 1 card to return to hand.",
  295. maxCount: 1,
  296. canEndNotMax: false,
  297. isShowOpponent: true,
  298. mode: SelectCardEffect.Mode.AddHand,
  299. root: SelectCardEffect.Root.Custom,
  300. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  301. canLookReverseCard: true,
  302. selectPlayer: card.Owner,
  303. cardEffect: activateClass);
  304. yield return StartCoroutine(selectCardEffect.Activate());
  305. }
  306. else
  307. {
  308. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  309. selectCardEffect.SetUp(
  310. canTargetCondition: CanSelectCardCondition,
  311. canTargetCondition_ByPreSelecetedList: null,
  312. canEndSelectCondition: null,
  313. canNoSelect: () => true,
  314. selectCardCoroutine: SelectCardCoroutine,
  315. afterSelectCardCoroutine: null,
  316. message: "Select 1 card to play.",
  317. maxCount: 1,
  318. canEndNotMax: false,
  319. isShowOpponent: true,
  320. mode: SelectCardEffect.Mode.Custom,
  321. root: SelectCardEffect.Root.Custom,
  322. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  323. canLookReverseCard: true,
  324. selectPlayer: card.Owner,
  325. cardEffect: activateClass);
  326. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  327. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  328. yield return StartCoroutine(selectCardEffect.Activate());
  329. }
  330. SelectCardEffect.Root root = SelectCardEffect.Root.Hand;
  331. if (!toHand)
  332. {
  333. root = SelectCardEffect.Root.DigivolutionCards;
  334. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: selectedCards[0], payCost: false, cardEffect: activateClass))
  335. {
  336. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  337. cardSources: selectedCards,
  338. activateClass: activateClass,
  339. payCost: false,
  340. isTapped: false,
  341. root: root,
  342. activateETB: true));
  343. }
  344. }
  345. }
  346. }
  347. }
  348. #endregion
  349. return cardEffects;
  350. }
  351. }
  352. }