BT22_075.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Fakemon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_075 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("Sup.");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region App Fusion (Roamon, Effecmon)
  23. if (timing == EffectTiming.None)
  24. {
  25. cardEffects.Add(CardEffectFactory.AddAppfuseMethodByName(new List<string>() { "Roamon", "Effecmon" }, card));
  26. }
  27. #endregion
  28. #region Retaliation
  29. if (timing == EffectTiming.OnDestroyedAnyone)
  30. {
  31. cardEffects.Add(CardEffectFactory.RetaliationSelfEffect(isInheritedEffect: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region On Play/When Digivolving shared
  35. bool CanLinkCondition(CardSource cardSource)
  36. {
  37. return cardSource.HasLevel && cardSource.Level <= 4 && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  38. }
  39. bool CanActivateConditionShared(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  42. (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition) ||
  43. card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition));
  44. }
  45. #endregion
  46. #region On Play
  47. if (timing == EffectTiming.OnEnterFieldAnyone)
  48. {
  49. ActivateClass activateClass = new ActivateClass();
  50. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  51. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  52. cardEffects.Add(activateClass);
  53. string EffectDescription()
  54. {
  55. return "[On Play] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  64. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition);
  65. if (canSelectSources || canSelectTrash)
  66. {
  67. if (canSelectTrash && canSelectSources)
  68. {
  69. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  70. {
  71. new(message: "From trash", value: true, spriteIndex: 0),
  72. new(message: "From sources", value: false, spriteIndex: 1),
  73. };
  74. string selectPlayerMessage = "From which area do you select a card?";
  75. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  76. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  77. }
  78. else
  79. {
  80. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  81. }
  82. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  83. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  84. List<CardSource> selectedCards = new List<CardSource>();
  85. IEnumerator SelectCardCoroutine(CardSource cardSource)
  86. {
  87. selectedCards.Add(cardSource);
  88. yield return null;
  89. }
  90. if (fromTrash)
  91. {
  92. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  93. selectCardEffect.SetUp(
  94. canTargetCondition: CanLinkCondition,
  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.Trash,
  106. customRootCardList: null,
  107. canLookReverseCard: true,
  108. selectPlayer: card.Owner,
  109. cardEffect: activateClass);
  110. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  111. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  112. yield return StartCoroutine(selectCardEffect.Activate());
  113. }
  114. else
  115. {
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: CanLinkCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => true,
  122. selectCardCoroutine: SelectCardCoroutine,
  123. afterSelectCardCoroutine: null,
  124. message: "Select 1 digivolution card to link.",
  125. maxCount: 1,
  126. canEndNotMax: false,
  127. isShowOpponent: true,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.DigivolutionCards,
  130. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  135. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  136. yield return StartCoroutine(selectCardEffect.Activate());
  137. }
  138. if (selectedCards.Count >= 1)
  139. {
  140. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  141. }
  142. }
  143. }
  144. }
  145. #endregion
  146. #region When Digivolving
  147. if (timing == EffectTiming.OnEnterFieldAnyone)
  148. {
  149. ActivateClass activateClass = new ActivateClass();
  150. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  151. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  152. cardEffects.Add(activateClass);
  153. string EffectDescription()
  154. {
  155. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  156. }
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  164. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Any(CanLinkCondition);
  165. if (canSelectSources || canSelectTrash)
  166. {
  167. if (canSelectTrash && canSelectSources)
  168. {
  169. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  170. {
  171. new(message: "From trash", value: true, spriteIndex: 0),
  172. new(message: "From sources", value: false, spriteIndex: 1),
  173. };
  174. string selectPlayerMessage = "From which area do you select a card?";
  175. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  176. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  177. }
  178. else
  179. {
  180. GManager.instance.userSelectionManager.SetBool(canSelectTrash);
  181. }
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  183. bool fromTrash = GManager.instance.userSelectionManager.SelectedBoolValue;
  184. List<CardSource> selectedCards = new List<CardSource>();
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCards.Add(cardSource);
  188. yield return null;
  189. }
  190. if (fromTrash)
  191. {
  192. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  193. selectCardEffect.SetUp(
  194. canTargetCondition: CanLinkCondition,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. canNoSelect: () => true,
  198. selectCardCoroutine: SelectCardCoroutine,
  199. afterSelectCardCoroutine: null,
  200. message: "Select 1 card to link.",
  201. maxCount: 1,
  202. canEndNotMax: false,
  203. isShowOpponent: true,
  204. mode: SelectCardEffect.Mode.Custom,
  205. root: SelectCardEffect.Root.Trash,
  206. customRootCardList: null,
  207. canLookReverseCard: true,
  208. selectPlayer: card.Owner,
  209. cardEffect: activateClass);
  210. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  211. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  212. yield return StartCoroutine(selectCardEffect.Activate());
  213. }
  214. else
  215. {
  216. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  217. selectCardEffect.SetUp(
  218. canTargetCondition: CanLinkCondition,
  219. canTargetCondition_ByPreSelecetedList: null,
  220. canEndSelectCondition: null,
  221. canNoSelect: () => true,
  222. selectCardCoroutine: SelectCardCoroutine,
  223. afterSelectCardCoroutine: null,
  224. message: "Select 1 digivolution card to link.",
  225. maxCount: 1,
  226. canEndNotMax: false,
  227. isShowOpponent: true,
  228. mode: SelectCardEffect.Mode.Custom,
  229. root: SelectCardEffect.Root.DigivolutionCards,
  230. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  231. canLookReverseCard: true,
  232. selectPlayer: card.Owner,
  233. cardEffect: activateClass);
  234. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  235. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  236. yield return StartCoroutine(selectCardEffect.Activate());
  237. }
  238. if (selectedCards.Count >= 1)
  239. {
  240. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  241. }
  242. }
  243. }
  244. }
  245. #endregion
  246. #region All Turns
  247. if (timing == EffectTiming.WhenRemoveField)
  248. {
  249. List<Permanent> removedPermanents = new List<Permanent>();
  250. ActivateClass activateClass = new ActivateClass();
  251. activateClass.SetUpICardEffect("Play 1 of this Digimon's link cards", CanUseCondition, card);
  252. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  253. activateClass.SetHashString("AllTurns_BT22_075");
  254. cardEffects.Add(activateClass);
  255. string EffectDescription()
  256. {
  257. return
  258. "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, you may play 1 of this Digimon's link cards without paying the cost.";
  259. }
  260. bool CanUseCondition(Hashtable hashtable)
  261. {
  262. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  263. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  264. }
  265. bool CanActivateCondition(Hashtable hashtable)
  266. {
  267. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  268. !card.PermanentOfThisCard().HasNoLinkCards;
  269. }
  270. bool CanSelectCardCondition(CardSource cardSource)
  271. {
  272. return CardEffectCommons.CanPlayAsNewPermanent(cardSource,false,activateClass,SelectCardEffect.Root.LinkedCards);
  273. }
  274. IEnumerator ActivateCoroutine(Hashtable hashtable)
  275. {
  276. Permanent thisPermanent = card.PermanentOfThisCard();
  277. CardSource playCard = null;
  278. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  279. selectCardEffect.SetUp(
  280. canTargetCondition: CanSelectCardCondition,
  281. canTargetCondition_ByPreSelecetedList: null,
  282. canEndSelectCondition: null,
  283. canNoSelect: () => true,
  284. selectCardCoroutine: SelectCardCoroutine,
  285. afterSelectCardCoroutine: null,
  286. message: "Select 1 link card to play.",
  287. maxCount: 1,
  288. canEndNotMax: false,
  289. isShowOpponent: true,
  290. mode: SelectCardEffect.Mode.Custom,
  291. root: SelectCardEffect.Root.LinkedCards,
  292. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  293. canLookReverseCard: true,
  294. selectPlayer: card.Owner,
  295. cardEffect: activateClass);
  296. selectCardEffect.SetUpCustomMessage("Select 1 link card to play.", "The opponent is selecting 1 link card to play.");
  297. yield return StartCoroutine(selectCardEffect.Activate());
  298. IEnumerator SelectCardCoroutine(CardSource cardSource)
  299. {
  300. playCard = cardSource;
  301. yield return null;
  302. }
  303. if (playCard)
  304. {
  305. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().RemoveLinkedCard(playCard, trashCard: false));
  306. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  307. cardSources: new List<CardSource> { playCard },
  308. activateClass: activateClass,
  309. payCost: false,
  310. isTapped: false,
  311. root: SelectCardEffect.Root.LinkedCards,
  312. activateETB: true));
  313. }
  314. }
  315. }
  316. #endregion
  317. #region Linking
  318. if (timing == EffectTiming.None)
  319. {
  320. bool PermanentCondition(Permanent permanent)
  321. {
  322. return permanent.TopCard.HasAppmonTraits;
  323. }
  324. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  325. }
  326. if (timing == EffectTiming.OnDeclaration)
  327. {
  328. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  329. }
  330. #endregion
  331. #region Scapegoat - Linked
  332. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  333. {
  334. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: null,isLinkedEffect:true));
  335. }
  336. #endregion
  337. return cardEffects;
  338. }
  339. }
  340. }