BT17_051.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. namespace DCGO.CardEffects.BT17
  7. {
  8. public class BT17_051 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Argomon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region On Play/When Digivolving Shared
  24. int maxLevel()
  25. {
  26. int max = 4;
  27. max += (int)Mathf.Floor(card.PermanentOfThisCard().DigivolutionCards.Count((source) => source.EqualsCardName("Argomon")) / 2);
  28. return max;
  29. }
  30. bool IsLevel5orLowerArgomon(CardSource source)
  31. {
  32. if (source.IsDigimon || source.IsDigiEgg)
  33. {
  34. if (source.HasLevel && source.Level <= 5)
  35. {
  36. if (source.EqualsCardName("Argomon"))
  37. {
  38. return true;
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectOpponentsDigimon(Permanent permanent)
  45. {
  46. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  47. {
  48. if (permanent.TopCard.Level <= maxLevel())
  49. {
  50. if (permanent.TopCard.HasLevel)
  51. {
  52. return true;
  53. }
  54. }
  55. }
  56. return false;
  57. }
  58. #endregion
  59. #region On Play
  60. if (timing == EffectTiming.OnEnterFieldAnyone)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Place up to 4, Then delete up to 4 levels total digimon", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[On Play] You may place up to 4 level 5 or lower [Argomon] from your trash as this Digimon's bottom digivolution cards. Then, delete up to 4 levels' total worth of your opponent’s Digimon. For every 2 [Argomon] in this Digimon's digivolution cards, add 1 to the maximum total level you may choose with this effect.";
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  73. }
  74. bool CanActivateCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  77. }
  78. IEnumerator ActivateCoroutine(Hashtable hashtable)
  79. {
  80. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsLevel5orLowerArgomon))
  81. {
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: IsLevel5orLowerArgomon,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => true,
  88. selectCardCoroutine: null,
  89. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  90. message: "Select cards to place as the bottom digivolution sources",
  91. maxCount: 4,
  92. canEndNotMax: true,
  93. isShowOpponent: false,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Trash,
  96. customRootCardList: null,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  101. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  102. {
  103. if (cardSources.Count > 0)
  104. {
  105. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  106. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(cardSources, activateClass));
  107. }
  108. }
  109. }
  110. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon) >= 1)
  111. {
  112. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon);
  113. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  114. selectPermanentEffect.SetUp(
  115. selectPlayer: card.Owner,
  116. canTargetCondition: CanSelectOpponentsDigimon,
  117. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  118. canEndSelectCondition: CanEndSelectCondition,
  119. maxCount: maxCount,
  120. canNoSelect: false,
  121. canEndNotMax: true,
  122. selectPermanentCoroutine: null,
  123. afterSelectPermanentCoroutine: null,
  124. mode: SelectPermanentEffect.Mode.Destroy,
  125. cardEffect: activateClass);
  126. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  127. bool CanEndSelectCondition(List<Permanent> permanents)
  128. {
  129. if (permanents.Count <= 0)
  130. {
  131. return false;
  132. }
  133. int sumCost = 0;
  134. foreach (Permanent permanent1 in permanents)
  135. {
  136. sumCost += permanent1.TopCard.Level;
  137. }
  138. if (sumCost > maxLevel())
  139. {
  140. return false;
  141. }
  142. return true;
  143. }
  144. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  145. {
  146. int sumCost = 0;
  147. foreach (Permanent permanent1 in permanents)
  148. {
  149. sumCost += permanent1.TopCard.Level;
  150. }
  151. sumCost += permanent.TopCard.Level;
  152. if (sumCost > maxLevel())
  153. {
  154. return false;
  155. }
  156. return true;
  157. }
  158. }
  159. }
  160. }
  161. #endregion
  162. #region When Digivolving
  163. if (timing == EffectTiming.OnEnterFieldAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Place up to 4, Then delete up to 4 levels total digimon", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  168. cardEffects.Add(activateClass);
  169. string EffectDiscription()
  170. {
  171. return "[When Digivolving] You may place up to 4 level 5 or lower [Argomon] from your trash as this Digimon's bottom digivolution cards. Then, delete up to 4 levels' total worth of your opponent’s Digimon. For every 2 [Argomon] in this Digimon's digivolution cards, add 1 to the maximum total level you may choose with this effect.";
  172. }
  173. bool CanUseCondition(Hashtable hashtable)
  174. {
  175. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsLevel5orLowerArgomon))
  184. {
  185. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  186. selectCardEffect.SetUp(
  187. canTargetCondition: IsLevel5orLowerArgomon,
  188. canTargetCondition_ByPreSelecetedList: null,
  189. canEndSelectCondition: null,
  190. canNoSelect: () => true,
  191. selectCardCoroutine: null,
  192. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  193. message: "Select cards to place as the bottom digivolution sources",
  194. maxCount: 4,
  195. canEndNotMax: true,
  196. isShowOpponent: false,
  197. mode: SelectCardEffect.Mode.Custom,
  198. root: SelectCardEffect.Root.Trash,
  199. customRootCardList: null,
  200. canLookReverseCard: true,
  201. selectPlayer: card.Owner,
  202. cardEffect: activateClass);
  203. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  204. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  205. {
  206. if (cardSources.Count > 0)
  207. {
  208. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  209. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(cardSources, activateClass));
  210. }
  211. }
  212. }
  213. if (card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon) >= 1)
  214. {
  215. int maxCount = card.Owner.Enemy.GetBattleAreaPermanents().Count(CanSelectOpponentsDigimon);
  216. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  217. selectPermanentEffect.SetUp(
  218. selectPlayer: card.Owner,
  219. canTargetCondition: CanSelectOpponentsDigimon,
  220. canTargetCondition_ByPreSelecetedList: CanTargetCondition_ByPreSelecetedList,
  221. canEndSelectCondition: CanEndSelectCondition,
  222. maxCount: maxCount,
  223. canNoSelect: false,
  224. canEndNotMax: true,
  225. selectPermanentCoroutine: null,
  226. afterSelectPermanentCoroutine: null,
  227. mode: SelectPermanentEffect.Mode.Destroy,
  228. cardEffect: activateClass);
  229. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  230. bool CanEndSelectCondition(List<Permanent> permanents)
  231. {
  232. if (permanents.Count <= 0)
  233. {
  234. return false;
  235. }
  236. int sumCost = 0;
  237. foreach (Permanent permanent1 in permanents)
  238. {
  239. sumCost += permanent1.TopCard.Level;
  240. }
  241. if (sumCost > maxLevel())
  242. {
  243. return false;
  244. }
  245. return true;
  246. }
  247. bool CanTargetCondition_ByPreSelecetedList(List<Permanent> permanents, Permanent permanent)
  248. {
  249. int sumCost = 0;
  250. foreach (Permanent permanent1 in permanents)
  251. {
  252. sumCost += permanent1.TopCard.Level;
  253. }
  254. sumCost += permanent.TopCard.Level;
  255. if (sumCost > maxLevel())
  256. {
  257. return false;
  258. }
  259. return true;
  260. }
  261. }
  262. }
  263. }
  264. #endregion
  265. #region All Turns
  266. if (timing == EffectTiming.None)
  267. {
  268. int count()
  269. {
  270. return (int)Mathf.Floor(card.PermanentOfThisCard().DigivolutionCards.Count((source) => source.EqualsCardName("Argomon")) / 2);
  271. }
  272. bool Condition()
  273. {
  274. if (count() >= 1)
  275. return true;
  276. return false;
  277. }
  278. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  279. changeValue: () => 1000 * count(),
  280. isInheritedEffect: false,
  281. card: card,
  282. condition: Condition));
  283. }
  284. #endregion
  285. #region Opponent's Turn
  286. if (timing == EffectTiming.None)
  287. {
  288. bool PermanentCondition(Permanent permanent)
  289. {
  290. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  291. {
  292. if (permanent.IsTamer)
  293. {
  294. return true;
  295. }
  296. }
  297. return false;
  298. }
  299. bool CanUseCondition()
  300. {
  301. if (CardEffectCommons.IsExistOnBattleArea(card))
  302. {
  303. if (!CardEffectCommons.IsOwnerTurn(card))
  304. return true;
  305. }
  306. return false;
  307. }
  308. string effectName = "[Opponent's Turn] None of your opponent's Tamers can unsuspend.";
  309. cardEffects.Add(CardEffectFactory.CantUnsuspendStaticEffect(
  310. permanentCondition: PermanentCondition,
  311. isInheritedEffect: false,
  312. card: card, condition: CanUseCondition,
  313. effectName: effectName));
  314. }
  315. #endregion
  316. return cardEffects;
  317. }
  318. }
  319. }