BT18_015.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT18
  5. {
  6. public class BT18_015 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 && targetPermanent.TopCard.ContainsTraits("Composite");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  19. permanentCondition: PermanentCondition,
  20. digivolutionCost: 3,
  21. ignoreDigivolutionRequirement: false,
  22. card: card,
  23. condition: null)
  24. );
  25. }
  26. #endregion
  27. #region When Digivolving
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Delete your 1 Digimon to delete 1 of opponent's Digimon with the lowest DP", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Digivolving] By deleting 1 of your Digimon, delete 1 of your opponent's Digimon with the lowest DP.";
  37. }
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  41. }
  42. bool CanSelectPermanentCondition1(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  49. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  50. return false;
  51. }
  52. bool CanActivateCondition(Hashtable hashtable)
  53. {
  54. if (CardEffectCommons.IsExistOnBattleArea(card))
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  57. {
  58. return true;
  59. }
  60. }
  61. return false;
  62. }
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  66. {
  67. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: SelectPermanentCoroutine,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Custom,
  80. cardEffect: activateClass);
  81. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  84. {
  85. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  86. IEnumerator SuccessProcess()
  87. {
  88. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  89. {
  90. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: CanSelectPermanentCondition1,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: false,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: null,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Destroy,
  102. cardEffect: activateClass);
  103. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. #endregion
  111. #region When Attacking
  112. if (timing == EffectTiming.OnAllyAttack)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect("Delete your 1 Digimon to delete 1 of opponent's Digimon with the lowest DP", CanUseCondition, card);
  116. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  117. cardEffects.Add(activateClass);
  118. string EffectDiscription()
  119. {
  120. return "[When Attacking] By deleting 1 of your Digimon, delete 1 of your opponent's Digimon with the lowest DP.";
  121. }
  122. bool CanSelectPermanentCondition(Permanent permanent)
  123. {
  124. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  125. }
  126. bool CanSelectPermanentCondition1(Permanent permanent)
  127. {
  128. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  129. }
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  133. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  134. return false;
  135. }
  136. bool CanActivateCondition(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  141. {
  142. return true;
  143. }
  144. }
  145. return false;
  146. }
  147. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  148. {
  149. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  150. {
  151. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectPermanentCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: maxCount,
  159. canNoSelect: true,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: SelectPermanentCoroutine,
  162. afterSelectPermanentCoroutine: null,
  163. mode: SelectPermanentEffect.Mode.Custom,
  164. cardEffect: activateClass);
  165. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  170. IEnumerator SuccessProcess()
  171. {
  172. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition1))
  173. {
  174. maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition1));
  175. selectPermanentEffect.SetUp(
  176. selectPlayer: card.Owner,
  177. canTargetCondition: CanSelectPermanentCondition1,
  178. canTargetCondition_ByPreSelecetedList: null,
  179. canEndSelectCondition: null,
  180. maxCount: maxCount,
  181. canNoSelect: false,
  182. canEndNotMax: false,
  183. selectPermanentCoroutine: null,
  184. afterSelectPermanentCoroutine: null,
  185. mode: SelectPermanentEffect.Mode.Destroy,
  186. cardEffect: activateClass);
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. }
  189. }
  190. }
  191. }
  192. }
  193. }
  194. #endregion
  195. #region On Deletion
  196. if (timing == EffectTiming.OnDestroyedAnyone)
  197. {
  198. ActivateClass activateClass = new ActivateClass();
  199. activateClass.SetUpICardEffect("DNA into [Millenniummon]", CanUseCondition, card);
  200. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  201. cardEffects.Add(activateClass);
  202. string EffectDiscription()
  203. {
  204. return "[On Deletion] 1 of your [Machinedramon] in play and 1 [Kimeramon] in the trash may DNA Digivolve into [Millenniummon] in the hand.";
  205. }
  206. bool HasMachinedramon(Permanent permanent)
  207. {
  208. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  209. permanent.TopCard.EqualsCardName("Machinedramon");
  210. }
  211. bool HasKimeramon(CardSource source)
  212. {
  213. return CardEffectCommons.IsExistOnTrash(source) &&
  214. source.EqualsCardName("Kimeramon");
  215. }
  216. bool HasMillenniummon(CardSource source)
  217. {
  218. return CardEffectCommons.IsExistOnHand(source) &&
  219. source.EqualsCardName("Millenniummon") &&
  220. source.jogressCondition.Count > 0;
  221. }
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  225. }
  226. bool CanActivateCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  229. CardEffectCommons.HasMatchConditionPermanent(HasMachinedramon) &&
  230. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasKimeramon) &&
  231. CardEffectCommons.HasMatchConditionOwnersHand(card, HasMillenniummon);
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable hashtable)
  234. {
  235. CardSource dnaTarget = null;
  236. Permanent selectedPermanent = null;
  237. CardSource selectedCardSource = null;
  238. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  239. selectHandEffect.SetUp(
  240. selectPlayer: card.Owner,
  241. canTargetCondition: HasMillenniummon,
  242. canTargetCondition_ByPreSelecetedList: null,
  243. canEndSelectCondition: null,
  244. maxCount: 1,
  245. canNoSelect: false,
  246. canEndNotMax: false,
  247. isShowOpponent: true,
  248. selectCardCoroutine: SelectDNACardCoroutine,
  249. afterSelectCardCoroutine: null,
  250. mode: SelectHandEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. selectHandEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.", "The opponent is selecting 1 Digimon to DNA digivolve.");
  253. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  254. IEnumerator SelectDNACardCoroutine(CardSource source)
  255. {
  256. dnaTarget = source;
  257. yield return null;
  258. }
  259. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  260. selectPermanentEffect.SetUp(
  261. selectPlayer: card.Owner,
  262. canTargetCondition: HasMachinedramon,
  263. canTargetCondition_ByPreSelecetedList: null,
  264. canEndSelectCondition: null,
  265. maxCount: 1,
  266. canNoSelect: false,
  267. canEndNotMax: false,
  268. selectPermanentCoroutine: SelectPermanentCoroutine,
  269. afterSelectPermanentCoroutine: null,
  270. mode: SelectPermanentEffect.Mode.Custom,
  271. cardEffect: activateClass);
  272. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to DNA digivolve.", "The opponent is selecting 1 Digimon to DNA digivolve.");
  273. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  274. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  275. {
  276. selectedPermanent = permanent;
  277. yield return null;
  278. }
  279. if (selectedPermanent != null)
  280. {
  281. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  282. selectCardEffect.SetUp(
  283. canTargetCondition: HasKimeramon,
  284. canTargetCondition_ByPreSelecetedList: null,
  285. canEndSelectCondition: null,
  286. canNoSelect: () => false,
  287. selectCardCoroutine: SelectCardCoroutine,
  288. afterSelectCardCoroutine: null,
  289. message: "Select 1 Digimon to DNA digivolve.",
  290. maxCount: 1,
  291. canEndNotMax: false,
  292. isShowOpponent: false,
  293. mode: SelectCardEffect.Mode.Custom,
  294. root: SelectCardEffect.Root.Trash,
  295. customRootCardList: null,
  296. canLookReverseCard: true,
  297. selectPlayer: card.Owner,
  298. cardEffect: activateClass);
  299. selectCardEffect.SetNotShowCard();
  300. selectCardEffect.SetNotAddLog();
  301. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  302. }
  303. IEnumerator SelectCardCoroutine(CardSource cardSource)
  304. {
  305. selectedCardSource = cardSource;
  306. yield return null;
  307. }
  308. if (selectedCardSource != null)
  309. {
  310. #region play card from trash
  311. Permanent playedPermanent = null;
  312. int frameID = selectedCardSource.PreferredFrame().FrameID;
  313. if (0 <= frameID && frameID < card.Owner.fieldCardFrames.Count)
  314. {
  315. playedPermanent = new Permanent(new List<CardSource>() { selectedCardSource }) { IsSuspended = false };
  316. yield return ContinuousController.instance.StartCoroutine(CardObjectController.CreateNewPermanent(playedPermanent, frameID));
  317. }
  318. #endregion
  319. int[] JogressEvoRootsFrameIDs = { playedPermanent.PermanentFrame.FrameID, selectedPermanent.PermanentFrame.FrameID };
  320. if (dnaTarget.CanPlayJogress(true))
  321. {
  322. PlayCardClass playCard = new PlayCardClass(
  323. cardSources: new List<CardSource>() { dnaTarget },
  324. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  325. payCost: true,
  326. targetPermanent: null,
  327. isTapped: false,
  328. root: SelectCardEffect.Root.Hand,
  329. activateETB: true);
  330. playCard.SetJogress(JogressEvoRootsFrameIDs);
  331. yield return ContinuousController.instance.StartCoroutine(playCard.PlayCard());
  332. }
  333. else
  334. {
  335. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddTrashCard(selectedCardSource));
  336. }
  337. }
  338. }
  339. }
  340. #endregion
  341. #region Inherit - Sec+1
  342. if (timing == EffectTiming.None)
  343. {
  344. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  345. }
  346. #endregion
  347. return cardEffects;
  348. }
  349. }
  350. }