BT15_081.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_081 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  15. changeValue: 2,
  16. isInheritedEffect: false,
  17. card: card,
  18. condition: null));
  19. }
  20. #region Alternate Digivolution Requirement
  21. if (timing == EffectTiming.None)
  22. {
  23. bool PermanentCondition(Permanent targetPermanent)
  24. {
  25. if (targetPermanent.TopCard.CardNames.Contains("Leviamon"))
  26. {
  27. return true;
  28. }
  29. return false;
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  32. permanentCondition: PermanentCondition,
  33. digivolutionCost: 2,
  34. ignoreDigivolutionRequirement: false,
  35. card: card,
  36. condition: null));
  37. }
  38. #endregion
  39. #region All Turns - When opponent plays digimon/tamer
  40. if (timing == EffectTiming.OnEnterFieldAnyone)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("Digivolve 1 [Leviamon (X Antibody)] from trash", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  45. cardEffects.Add(activateClass);
  46. string EffectDiscription()
  47. {
  48. return "[Trash] [All Turns] When an effect play an opponent's Digimon or Tamer, 1 of your [Leviamon] or 1 of your Digimon with [X Antibody] in its digivolution cards may digivolve into this card without paying the cost.";
  49. }
  50. #region Opponent Digimon/Tamer Played/card is in trash condition
  51. bool PermanentCondition(Permanent permanent)
  52. {
  53. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  54. {
  55. if (permanent.TopCard.IsDigimon || permanent.TopCard.IsTamer)
  56. {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. if (CardEffectCommons.IsExistOnTrash(card))
  65. {
  66. if (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition))
  67. {
  68. if (CardEffectCommons.IsByEffect(hashtable, null))
  69. {
  70. return true;
  71. }
  72. }
  73. }
  74. return false;
  75. }
  76. #endregion
  77. #region Selectable Digimon Conditions
  78. bool CanSelectPermanentCondition(Permanent permanent)
  79. {
  80. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  81. {
  82. if (CanSelectCardCondition(permanent.TopCard))
  83. {
  84. if (card.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root: SelectCardEffect.Root.Trash))
  85. {
  86. return true;
  87. }
  88. }
  89. }
  90. return false;
  91. }
  92. bool CanSelectCardCondition(CardSource cardSource)
  93. {
  94. if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
  95. {
  96. if (cardSource.CardNames.Contains("Leviamon"))
  97. {
  98. return true;
  99. }
  100. if (cardSource.PermanentOfThisCard().DigivolutionCards.Count((CS) => CS.CardNames.Contains("X Antibody") || CS.CardNames.Contains("XAntibody")) >= 1)
  101. {
  102. return cardSource.Level == 5 && cardSource.HasCardColor(CardColor.Purple);
  103. }
  104. }
  105. return false;
  106. }
  107. #endregion
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. if (CardEffectCommons.IsExistOnTrash(card))
  111. {
  112. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  113. {
  114. return true;
  115. }
  116. }
  117. return false;
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  120. {
  121. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  122. {
  123. Permanent selectedPermanent = null;
  124. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  125. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  126. selectPermanentEffect.SetUp(
  127. selectPlayer: card.Owner,
  128. canTargetCondition: CanSelectPermanentCondition,
  129. canTargetCondition_ByPreSelecetedList: null,
  130. canEndSelectCondition: null,
  131. maxCount: maxCount,
  132. canNoSelect: true,
  133. canEndNotMax: false,
  134. selectPermanentCoroutine: SelectPermanentCoroutine,
  135. afterSelectPermanentCoroutine: null,
  136. mode: SelectPermanentEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will digivolve.", "The opponent is selecting 1 Digimon that will digivolve.");
  139. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  140. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  141. {
  142. selectedPermanent = permanent;
  143. yield return null;
  144. }
  145. if (selectedPermanent != null)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  148. targetPermanent: selectedPermanent,
  149. cardCondition: null,
  150. payCost: false,
  151. reduceCostTuple: null,
  152. fixedCostTuple: null,
  153. ignoreDigivolutionRequirementFixedCost: -1,
  154. isHand: false,
  155. activateClass: activateClass,
  156. successProcess: null,
  157. ignoreSelection: true));
  158. }
  159. }
  160. }
  161. }
  162. #endregion
  163. #region When Digivolving
  164. if (timing == EffectTiming.OnEnterFieldAnyone)
  165. {
  166. ActivateClass activateClass = new ActivateClass();
  167. activateClass.SetUpICardEffect("Delete 1 Tamer and 1 level 3, 5, and 7 Digimon", CanUseCondition, card);
  168. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  169. cardEffects.Add(activateClass);
  170. string EffectDiscription()
  171. {
  172. return "[When Digivolving] If your opponent has as many or more total Digimon and Tamers as you, delete 1 of your opponent's Tamers. Then, delete 1 of your opponent's level 3, 1 of their level 5 and 1 of their level 7 Digimon.";
  173. }
  174. #region Card select conditions
  175. bool CanSelectTamerCondition(Permanent permanent)
  176. {
  177. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  178. {
  179. if (permanent.TopCard.IsTamer)
  180. {
  181. return true;
  182. }
  183. }
  184. return false;
  185. }
  186. bool CanSelectLevel3Condition(Permanent permanent)
  187. {
  188. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  189. {
  190. if (permanent.TopCard.HasLevel)
  191. {
  192. if (permanent.Level == 3)
  193. {
  194. return true;
  195. }
  196. }
  197. }
  198. return false;
  199. }
  200. bool CanSelectLevel5Condition(Permanent permanent)
  201. {
  202. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  203. {
  204. if (permanent.TopCard.HasLevel)
  205. {
  206. if (permanent.Level == 5)
  207. {
  208. return true;
  209. }
  210. }
  211. }
  212. return false;
  213. }
  214. bool CanSelectLevel7Condition(Permanent permanent)
  215. {
  216. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  217. {
  218. if (permanent.TopCard.HasLevel)
  219. {
  220. if (permanent.Level == 7)
  221. {
  222. return true;
  223. }
  224. }
  225. }
  226. return false;
  227. }
  228. #endregion
  229. bool PermanentCondition(Permanent permanent)
  230. {
  231. return (permanent.IsDigimon || permanent.IsTamer);
  232. }
  233. bool CanUseCondition(Hashtable hashtable)
  234. {
  235. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  236. }
  237. bool CanActivateCondition(Hashtable hashtable)
  238. {
  239. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  240. }
  241. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  242. {
  243. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  244. {
  245. List<Permanent> selectedPermanents = new List<Permanent>();
  246. if (card.Owner.GetBattleAreaPermanents().Count(PermanentCondition) <= card.Owner.Enemy.GetBattleAreaPermanents().Count(PermanentCondition))
  247. {
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectTamerCondition))
  249. {
  250. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectTamerCondition));
  251. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  252. selectPermanentEffect.SetUp(
  253. selectPlayer: card.Owner,
  254. canTargetCondition: CanSelectTamerCondition,
  255. canTargetCondition_ByPreSelecetedList: null,
  256. canEndSelectCondition: null,
  257. maxCount: maxCount,
  258. canNoSelect: false,
  259. canEndNotMax: false,
  260. selectPermanentCoroutine: SelectPermanentCoroutine,
  261. afterSelectPermanentCoroutine: null,
  262. mode: SelectPermanentEffect.Mode.Custom,
  263. cardEffect: activateClass);
  264. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to delete.", "The opponent is selecting 1 Tamer to delete.");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. }
  267. }
  268. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevel3Condition))
  269. {
  270. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectLevel3Condition));
  271. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  272. selectPermanentEffect.SetUp(
  273. selectPlayer: card.Owner,
  274. canTargetCondition: CanSelectLevel3Condition,
  275. canTargetCondition_ByPreSelecetedList: null,
  276. canEndSelectCondition: null,
  277. maxCount: maxCount,
  278. canNoSelect: false,
  279. canEndNotMax: false,
  280. selectPermanentCoroutine: SelectPermanentCoroutine,
  281. afterSelectPermanentCoroutine: null,
  282. mode: SelectPermanentEffect.Mode.Custom,
  283. cardEffect: activateClass);
  284. selectPermanentEffect.SetUpCustomMessage("Select 1 level 3 Digimon to delete.", "The opponent is selecting 1 level 3 Digimon to delete.");
  285. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  286. }
  287. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevel5Condition))
  288. {
  289. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectLevel5Condition));
  290. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  291. selectPermanentEffect.SetUp(
  292. selectPlayer: card.Owner,
  293. canTargetCondition: CanSelectLevel5Condition,
  294. canTargetCondition_ByPreSelecetedList: null,
  295. canEndSelectCondition: null,
  296. maxCount: maxCount,
  297. canNoSelect: false,
  298. canEndNotMax: false,
  299. selectPermanentCoroutine: SelectPermanentCoroutine,
  300. afterSelectPermanentCoroutine: null,
  301. mode: SelectPermanentEffect.Mode.Custom,
  302. cardEffect: activateClass);
  303. selectPermanentEffect.SetUpCustomMessage("Select 1 level 5 Digimon to delete.", "The opponent is selecting 1 level 5 Digimon to delete.");
  304. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  305. }
  306. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectLevel7Condition))
  307. {
  308. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectLevel7Condition));
  309. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  310. selectPermanentEffect.SetUp(
  311. selectPlayer: card.Owner,
  312. canTargetCondition: CanSelectLevel7Condition,
  313. canTargetCondition_ByPreSelecetedList: null,
  314. canEndSelectCondition: null,
  315. maxCount: maxCount,
  316. canNoSelect: false,
  317. canEndNotMax: false,
  318. selectPermanentCoroutine: SelectPermanentCoroutine,
  319. afterSelectPermanentCoroutine: null,
  320. mode: SelectPermanentEffect.Mode.Custom,
  321. cardEffect: activateClass);
  322. selectPermanentEffect.SetUpCustomMessage("Select 1 level 7 Digimon to delete.", "The opponent is selecting 1 level 7 Digimon to delete.");
  323. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  324. }
  325. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  326. {
  327. selectedPermanents.Add(permanent);
  328. yield return null;
  329. }
  330. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(
  331. selectedPermanents,
  332. CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  333. }
  334. }
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }