BT22_035.cs 18 KB

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