BT23_060.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. //Machinedramon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_060 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel5 &&
  18. targetPermanent.TopCard.HasCSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  22. card: card, condition: null));
  23. }
  24. #endregion
  25. #region Static Effects Security Atk +1, Reboot
  26. if (timing == EffectTiming.None)
  27. {
  28. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(
  29. changeValue: 1,
  30. isInheritedEffect: false,
  31. card: card,
  32. condition: null));
  33. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  34. }
  35. #endregion
  36. #region On Play
  37. if (timing == EffectTiming.OnEnterFieldAnyone)
  38. {
  39. ActivateClass activateClass = new ActivateClass();
  40. activateClass.SetUpICardEffect("<De-Digivolve 1>, then delete 1 with 8000DP or less", CanUseCondition, card);
  41. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  42. cardEffects.Add(activateClass);
  43. string EffectDiscription()
  44. {
  45. return "[On Play] <De-Digivolve 1> 1 of your opponent's Digimon. Then, delete 1 of their Digimon with 8000 DP or less.";
  46. }
  47. bool IsDigimonWithCorrectDP(Permanent permanent)
  48. {
  49. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  50. {
  51. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool CanSelectPermanentCondition(Permanent permanent)
  59. {
  60. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  61. }
  62. bool CanUseCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  69. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  70. }
  71. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  72. {
  73. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  74. {
  75. Permanent selectedPermanent = null;
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: 1,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectTargetCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  90. IEnumerator SelectTargetCoroutine(Permanent permanent)
  91. {
  92. selectedPermanent = permanent;
  93. yield return null;
  94. }
  95. if (selectedPermanent != null)
  96. {
  97. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  98. }
  99. }
  100. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  101. {
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: IsDigimonWithCorrectDP,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: 1,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Destroy,
  114. cardEffect: activateClass);
  115. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  116. }
  117. }
  118. }
  119. #endregion
  120. #region When Digivolving
  121. if (timing == EffectTiming.OnEnterFieldAnyone)
  122. {
  123. ActivateClass activateClass = new ActivateClass();
  124. activateClass.SetUpICardEffect("<De-Digivolve 1>, then delete 1 with 8000DP or less", CanUseCondition, card);
  125. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  126. cardEffects.Add(activateClass);
  127. string EffectDiscription()
  128. {
  129. return "[When Digivolving] <De-Digivolve 1> 1 of your opponent's Digimon. Then, delete 1 of their Digimon with 8000 DP or less.";
  130. }
  131. bool IsDigimonWithCorrectDP(Permanent permanent)
  132. {
  133. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  134. {
  135. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(8000, activateClass))
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. bool CanSelectPermanentCondition(Permanent permanent)
  143. {
  144. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  145. }
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  149. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  150. }
  151. bool CanActivateCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  154. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  155. }
  156. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  157. {
  158. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  159. {
  160. Permanent selectedPermanent = null;
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: CanSelectPermanentCondition,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: 1,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: SelectTargetCoroutine,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Custom,
  173. cardEffect: activateClass);
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  175. IEnumerator SelectTargetCoroutine(Permanent permanent)
  176. {
  177. selectedPermanent = permanent;
  178. yield return null;
  179. }
  180. if (selectedPermanent != null)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  183. }
  184. }
  185. if (CardEffectCommons.HasMatchConditionPermanent(IsDigimonWithCorrectDP))
  186. {
  187. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  188. selectPermanentEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: IsDigimonWithCorrectDP,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: 1,
  194. canNoSelect: false,
  195. canEndNotMax: false,
  196. selectPermanentCoroutine: null,
  197. afterSelectPermanentCoroutine: null,
  198. mode: SelectPermanentEffect.Mode.Destroy,
  199. cardEffect: activateClass);
  200. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  201. }
  202. }
  203. }
  204. #endregion
  205. #region When Attacking
  206. if (timing == EffectTiming.OnAllyAttack)
  207. {
  208. ActivateClass activateClass = new ActivateClass();
  209. activateClass.SetUpICardEffect("Activate 1 [On Play] as an effect of this Digimon", CanUseCondition, card);
  210. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  211. activateClass.SetHashString("WA_BT23-060");
  212. cardEffects.Add(activateClass);
  213. string EffectDiscription()
  214. {
  215. return "[When Attacking] [Once Per Turn] Activate 1 [On Play] effect on a face-up [Zaxon] trait Digimon card in your security stack as an effect of this Digimon.";
  216. }
  217. bool OnPlayEffectSecurityCondition(CardSource cardSource)
  218. {
  219. List<ICardEffect> effects = cardSource.EffectList_ForCard(EffectTiming.OnEnterFieldAnyone, cardSource)
  220. .Clone()
  221. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.EffectDiscription.StartsWith("[On Play]"));
  222. if (effects.Count > 0)
  223. return true;
  224. return false;
  225. }
  226. bool CanSelectCardCondition(CardSource cardSource)
  227. {
  228. return cardSource.EqualsTraits("Zaxon")
  229. && !cardSource.IsFlipped
  230. && OnPlayEffectSecurityCondition(cardSource);
  231. }
  232. bool CanUseCondition(Hashtable hashtable)
  233. {
  234. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  235. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  236. }
  237. bool CanActivateCondition(Hashtable hashtable)
  238. {
  239. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  240. }
  241. IEnumerator ActivateCoroutine(Hashtable hashtable)
  242. {
  243. CardSource selectedCard = null;
  244. if(CardEffectCommons.HasMatchConditionOwnersSecurity(card, CanSelectCardCondition, false))
  245. {
  246. #region Select target card
  247. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  248. selectCardEffect.SetUp(
  249. canTargetCondition: CanSelectCardCondition,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. canNoSelect: () => false,
  253. selectCardCoroutine: SelectCardCoroutine,
  254. afterSelectCardCoroutine: null,
  255. message: "Select 1 card to use their [On Play] effect.",
  256. maxCount: 1,
  257. canEndNotMax: false,
  258. isShowOpponent: true,
  259. mode: SelectCardEffect.Mode.Custom,
  260. root: SelectCardEffect.Root.Security,
  261. customRootCardList: null,
  262. canLookReverseCard: false,
  263. selectPlayer: card.Owner,
  264. cardEffect: activateClass);
  265. selectCardEffect.SetUpCustomMessage(
  266. "Select 1 card to use their [On Play] effect.",
  267. "The opponent is selecting 1 card to use their [On Play] effect.");
  268. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  269. IEnumerator SelectCardCoroutine(CardSource cardSource)
  270. {
  271. selectedCard = cardSource;
  272. yield return null;
  273. }
  274. #endregion
  275. #region Select Effect
  276. if (selectedCard != null)
  277. {
  278. List<ICardEffect> candidateEffects = selectedCard.EffectList_ForCard(EffectTiming.OnEnterFieldAnyone, card)
  279. .Clone()
  280. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.EffectDiscription.StartsWith("[On Play]"));
  281. if (candidateEffects.Count >= 1)
  282. {
  283. ICardEffect selectedEffect = null;
  284. if (candidateEffects.Count == 1)
  285. {
  286. selectedEffect = candidateEffects[0];
  287. }
  288. else
  289. {
  290. List<SkillInfo> skillInfos = candidateEffects
  291. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  292. List<CardSource> cardSources = candidateEffects
  293. .Map(cardEffect => cardEffect.EffectSourceCard);
  294. SelectCardEffect selectCardEffect2 = GManager.instance.GetComponent<SelectCardEffect>();
  295. selectCardEffect2.SetUp(
  296. canTargetCondition: (cardSource) => true,
  297. canTargetCondition_ByPreSelecetedList: null,
  298. canEndSelectCondition: null,
  299. canNoSelect: () => false,
  300. selectCardCoroutine: null,
  301. afterSelectCardCoroutine: null,
  302. message: "Select 1 effect to activate.",
  303. maxCount: 1,
  304. canEndNotMax: false,
  305. isShowOpponent: false,
  306. mode: SelectCardEffect.Mode.Custom,
  307. root: SelectCardEffect.Root.Custom,
  308. customRootCardList: cardSources,
  309. canLookReverseCard: true,
  310. selectPlayer: card.Owner,
  311. cardEffect: activateClass);
  312. selectCardEffect2.SetNotShowCard();
  313. selectCardEffect2.SetUpSkillInfos(skillInfos);
  314. selectCardEffect2.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  315. yield return ContinuousController.instance.StartCoroutine(selectCardEffect2.Activate());
  316. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  317. {
  318. if (selectedIndexes.Count == 1)
  319. {
  320. selectedEffect = candidateEffects[selectedIndexes[0]];
  321. yield return null;
  322. }
  323. }
  324. }
  325. if (selectedEffect != null)
  326. {
  327. Hashtable effectHashtable = CardEffectCommons.OnPlayCheckHashtableOfCard(card);
  328. if (selectedEffect.CanUse(effectHashtable))
  329. {
  330. selectedEffect.SetIsDigimonEffect(true);
  331. yield return ContinuousController.instance.StartCoroutine(
  332. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  333. }
  334. }
  335. }
  336. }
  337. #endregion
  338. }
  339. }
  340. }
  341. #endregion
  342. return cardEffects;
  343. }
  344. }
  345. }