BT24_077.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. // Revivemon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_077 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition - Sup.
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasSuperAppTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Link Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. static bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.HasAppmonTraits;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  31. }
  32. #endregion
  33. #region App Fusion (Raidramon, Dezipmon)
  34. if (timing == EffectTiming.None)
  35. {
  36. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Raidramon", "Dezipmon" }, card));
  37. }
  38. #endregion
  39. #region Link
  40. if (timing == EffectTiming.OnDeclaration)
  41. {
  42. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  43. }
  44. #endregion
  45. #region Blocker
  46. if (timing == EffectTiming.None)
  47. {
  48. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  49. }
  50. #endregion
  51. #region Shared WD / OD
  52. string SharedEffectName() => "Link level 4 or lower from trash or this digimon";
  53. string SharedEffectDescription(string tag) => $"[{tag}] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  54. bool CanSelectLinkCard(CardSource cardSource)
  55. {
  56. return cardSource.IsDigimon
  57. && cardSource.HasLevel
  58. && cardSource.Level <= 4
  59. && cardSource.CanLink(false);
  60. }
  61. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  62. {
  63. bool hasInTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectLinkCard);
  64. bool hasInSources = card.PermanentOfThisCard() != null && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectLinkCard) > 0;
  65. bool selectedRoot = false;
  66. CardSource selectedCard = null;
  67. if (hasInTrash || hasInSources)
  68. {
  69. if (hasInTrash && hasInSources)
  70. {
  71. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  72. {
  73. new SelectionElement<bool>(message: $"From This Digimon", value: true, spriteIndex: 0),
  74. new SelectionElement<bool>(message: $"From Trash", value: false, spriteIndex: 1),
  75. };
  76. string selectPlayerMessage = "Choose where to get the digimon from";
  77. string notSelectPlayerMessage = "The opponent is choosing effects.";
  78. GManager.instance.userSelectionManager.SetBoolSelection(
  79. selectionElements: selectionElements, selectPlayer: card.Owner,
  80. selectPlayerMessage: selectPlayerMessage,
  81. notSelectPlayerMessage: notSelectPlayerMessage);
  82. yield return ContinuousController.instance.StartCoroutine(GManager.instance
  83. .userSelectionManager.WaitForEndSelect());
  84. selectedRoot = GManager.instance.userSelectionManager.SelectedBoolValue;
  85. }
  86. else if (hasInSources)
  87. {
  88. selectedRoot = true;
  89. }
  90. if (selectedRoot)
  91. {
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanSelectLinkCard,
  95. canTargetCondition_ByPreSelecetedList: null,
  96. canEndSelectCondition: null,
  97. canNoSelect: () => true,
  98. selectCardCoroutine: SelectCardCoroutine,
  99. afterSelectCardCoroutine: null,
  100. message: "Select 1 card to link.",
  101. maxCount: 1,
  102. canEndNotMax: false,
  103. isShowOpponent: true,
  104. mode: SelectCardEffect.Mode.Custom,
  105. root: SelectCardEffect.Root.DigivolutionCards,
  106. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. selectCardEffect.SetUpCustomMessage("Select 1 card to link", "The opponent is selecting 1 card to link");
  111. yield return StartCoroutine(selectCardEffect.Activate());
  112. }
  113. else
  114. {
  115. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  116. selectCardEffect.SetUp(
  117. canTargetCondition: CanSelectLinkCard,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. canNoSelect: () => true,
  121. selectCardCoroutine: SelectCardCoroutine,
  122. afterSelectCardCoroutine: null,
  123. message: "Select 1 card to link.",
  124. maxCount: 1,
  125. canEndNotMax: false,
  126. isShowOpponent: true,
  127. mode: SelectCardEffect.Mode.Custom,
  128. root: SelectCardEffect.Root.Trash,
  129. customRootCardList: null,
  130. canLookReverseCard: true,
  131. selectPlayer: card.Owner,
  132. cardEffect: activateClass);
  133. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  134. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  135. yield return StartCoroutine(selectCardEffect.Activate());
  136. }
  137. }
  138. IEnumerator SelectCardCoroutine(CardSource cardSource)
  139. {
  140. selectedCard = cardSource;
  141. yield return null;
  142. }
  143. if (selectedCard != null)
  144. {
  145. bool CanSelectDigimon(Permanent permanent)
  146. {
  147. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  148. return selectedCard.CanLinkToTargetPermanent(permanent, false);
  149. return false;
  150. }
  151. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimon))
  152. {
  153. Permanent selectedPermanent = null;
  154. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectDigimon));
  155. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  156. selectPermanentEffect.SetUp(
  157. selectPlayer: card.Owner,
  158. canTargetCondition: CanSelectDigimon,
  159. canTargetCondition_ByPreSelecetedList: null,
  160. canEndSelectCondition: null,
  161. maxCount: maxCount,
  162. canNoSelect: true,
  163. canEndNotMax: false,
  164. selectPermanentCoroutine: SelectPermanentCoroutine,
  165. afterSelectPermanentCoroutine: null,
  166. mode: SelectPermanentEffect.Mode.Custom,
  167. cardEffect: activateClass);
  168. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to add link", "The opponent is selecting 1 digimon to add link");
  169. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  170. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  171. {
  172. selectedPermanent = permanent;
  173. yield return null;
  174. }
  175. if (selectedPermanent != null)
  176. {
  177. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(selectedCard, activateClass));
  178. }
  179. }
  180. }
  181. }
  182. #endregion
  183. #region Shared When Digivolving
  184. if (timing == EffectTiming.OnEnterFieldAnyone)
  185. {
  186. ActivateClass activateClass = new ActivateClass();
  187. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  188. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  189. cardEffects.Add(activateClass);
  190. bool CanUseCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  193. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  194. }
  195. bool CanActivateCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  198. }
  199. }
  200. #endregion
  201. #region Shared On Deletion
  202. if (timing == EffectTiming.OnDestroyedAnyone)
  203. {
  204. ActivateClass activateClass = new ActivateClass();
  205. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  206. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("On Deletion"));
  207. cardEffects.Add(activateClass);
  208. bool CanUseCondition(Hashtable hashtable)
  209. {
  210. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  211. }
  212. bool CanActivateCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  215. }
  216. }
  217. #endregion
  218. #region On Deletion
  219. if (timing == EffectTiming.OnDestroyedAnyone)
  220. {
  221. ActivateClass activateClass = new ActivateClass();
  222. activateClass.SetUpICardEffect("Play 1 lvl 4- [Appmon] from trash", CanUseCondition, card);
  223. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  224. cardEffects.Add(activateClass);
  225. string EffectDescription() => "[On Deletion] You may play 1 level 4 or lower [Appmon] trait Digimon card from your trash without paying the cost.";
  226. bool CanUseCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  229. }
  230. bool CanActivateCondition(Hashtable hashtable)
  231. {
  232. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  233. }
  234. bool CanPlayCardCondition(CardSource cardSource)
  235. {
  236. return cardSource.IsDigimon
  237. && cardSource.HasLevel
  238. && cardSource.Level <= 4
  239. && cardSource.HasAppmonTraits
  240. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  241. }
  242. IEnumerator ActivateCoroutine(Hashtable hashtable)
  243. {
  244. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanPlayCardCondition));
  245. List<CardSource> selectedCards = new List<CardSource>();
  246. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  247. selectCardEffect.SetUp(
  248. canTargetCondition: CanPlayCardCondition,
  249. canTargetCondition_ByPreSelecetedList: null,
  250. canEndSelectCondition: null,
  251. canNoSelect: () => true,
  252. selectCardCoroutine: SelectCardCoroutine,
  253. afterSelectCardCoroutine: null,
  254. message: "Select 1 card to play.",
  255. maxCount: maxCount,
  256. canEndNotMax: false,
  257. isShowOpponent: true,
  258. mode: SelectCardEffect.Mode.Custom,
  259. root: SelectCardEffect.Root.Trash,
  260. customRootCardList: null,
  261. canLookReverseCard: true,
  262. selectPlayer: card.Owner,
  263. cardEffect: activateClass);
  264. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  265. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  266. yield return StartCoroutine(selectCardEffect.Activate());
  267. IEnumerator SelectCardCoroutine(CardSource cardSource)
  268. {
  269. selectedCards.Add(cardSource);
  270. yield return null;
  271. }
  272. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  273. }
  274. }
  275. #endregion
  276. #region Link When Linking
  277. if (timing == EffectTiming.WhenLinked)
  278. {
  279. ActivateClass activateClass = new ActivateClass();
  280. activateClass.SetUpICardEffect("Delete 1 lowest DP Digimon", CanUseCondition, card);
  281. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  282. activateClass.SetIsLinkedEffect(true);
  283. cardEffects.Add(activateClass);
  284. string EffectDiscription()
  285. {
  286. return "[When Linking] Delete 1 of your opponent's Digimon with the lowest DP.";
  287. }
  288. bool CanUseCondition(Hashtable hashtable)
  289. {
  290. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  291. && CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  292. }
  293. bool DeletionTargetCondition(Permanent permanent)
  294. {
  295. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  296. }
  297. bool CanActivateCondition(Hashtable hashtable)
  298. {
  299. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  300. }
  301. IEnumerator ActivateCoroutine(Hashtable hashtable)
  302. {
  303. if(CardEffectCommons.HasMatchConditionOpponentsPermanent(card, DeletionTargetCondition))
  304. {
  305. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  306. int maxCount = 1;
  307. selectPermanentEffect.SetUp(
  308. selectPlayer: card.Owner,
  309. canTargetCondition: DeletionTargetCondition,
  310. canTargetCondition_ByPreSelecetedList: null,
  311. canEndSelectCondition: null,
  312. maxCount: maxCount,
  313. canNoSelect: false,
  314. canEndNotMax: false,
  315. selectPermanentCoroutine: null,
  316. afterSelectPermanentCoroutine: null,
  317. mode: SelectPermanentEffect.Mode.Destroy,
  318. cardEffect: activateClass);
  319. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  320. }
  321. }
  322. }
  323. #endregion
  324. return cardEffects;
  325. }
  326. }
  327. }