BT25_101.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Divine Arms Version (Omega)
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_101 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  16. bool CardCondition(CardSource cardSource)
  17. {
  18. return cardSource.HasTSTraits;
  19. }
  20. }
  21. #endregion
  22. #region Security
  23. if (timing == EffectTiming.SecuritySkill)
  24. {
  25. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  26. card: card,
  27. cardEffects: ref cardEffects,
  28. effectName: "[Security] By trashing 1 [TS] trait card from your hand, <Draw 2>, After you may link this card or 1 [TS] trait card from your trash to 1 of your Digimon on the field without paying the cost.");
  29. }
  30. #endregion
  31. #region Main
  32. if (timing == EffectTiming.OptionSkill)
  33. {
  34. ActivateClass activateClass = new ActivateClass();
  35. activateClass.SetUpICardEffect("By trashing 1 [TS] trait card from hand, Draw 2, then you may link this card or 1 [TS] trait card in trash to 1 of your digimon without paying cost.", CanUseCondition, card);
  36. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. {
  40. return "[Main] By trashing 1 [TS] trait card from your hand, <Draw 2> After, you may link this card or 1 [TS] trait card from your trash to 1 of your Digimon on the field without paying the cost.";
  41. }
  42. bool CanUseCondition(Hashtable hashtable)
  43. {
  44. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  45. }
  46. bool IsTsTraitCard(CardSource cardSource)
  47. {
  48. return cardSource.HasTSTraits;
  49. }
  50. bool PermanentThisCardCanLinkToCondition(Permanent permanent)
  51. {
  52. return permanent.IsDigimon
  53. && CardEffectCommons.IsOwnerPermanent(permanent, card)
  54. && card.CanLinkToTargetPermanent(permanent, false, true);
  55. }
  56. bool CanLinkTrashCardCondition(CardSource cardSource)
  57. {
  58. return cardSource.HasTSTraits
  59. && cardSource.CanLink(false, true);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsTsTraitCard))
  64. {
  65. CardSource selectedCardToTrash = null;
  66. #region Select Hand Card to Trash
  67. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, IsTsTraitCard));
  69. selectHandEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: IsTsTraitCard,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: true,
  76. canEndNotMax: false,
  77. isShowOpponent: true,
  78. selectCardCoroutine: SelectCardCoroutine,
  79. afterSelectCardCoroutine: null,
  80. mode: SelectHandEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. IEnumerator SelectCardCoroutine(CardSource cardSource)
  83. {
  84. selectedCardToTrash = cardSource;
  85. yield return null;
  86. }
  87. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  88. #endregion
  89. if (selectedCardToTrash != null)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashHandAndProcessAccordingToResult(
  92. player: card.Owner,
  93. hashtable: hashtable,
  94. cardToTrash: selectedCardToTrash,
  95. activateClass: activateClass,
  96. successProcess: SuccessProcess,
  97. failureProcess: null
  98. ));
  99. IEnumerator SuccessProcess(CardSource cardSource)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 2, activateClass).Draw());
  102. bool canSelectThisCard = CardEffectCommons.HasMatchConditionPermanent(PermanentThisCardCanLinkToCondition, true);
  103. bool canSelectTrashCard = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkTrashCardCondition);
  104. if (canSelectThisCard || canSelectTrashCard)
  105. {
  106. #region Setup Location Selection
  107. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  108. if (canSelectThisCard) selectionElements.Add(new(message: $"This Card", value: 1, spriteIndex: 0));
  109. if (canSelectTrashCard) selectionElements.Add(new(message: $"[TS] Trait card from trash", value: 2, spriteIndex: 0));
  110. selectionElements.Add(new(message: $"None", value: 3, spriteIndex: 1));
  111. string selectPlayerMessage = "Will you link a card to 1 digimon on your field?";
  112. string notSelectPlayerMessage = "The opponent is choosing to link a card to 1 digimon on their field.";
  113. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  114. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  115. #endregion
  116. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  117. bool selectThisCard = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  118. if (doLink)
  119. {
  120. Permanent selectedPermament = null;
  121. CardSource selectedCardToLink = null;
  122. IEnumerator SelectPermamentToLinkToCoroutine(Permanent permanent)
  123. {
  124. selectedPermament = permanent;
  125. yield return null;
  126. }
  127. if (selectThisCard)
  128. {
  129. selectedCardToLink = card;
  130. }
  131. else
  132. {
  133. IEnumerator SelectCardToLinkCoroutine(CardSource cardSource)
  134. {
  135. selectedCardToLink = cardSource;
  136. yield return null;
  137. }
  138. #region Select Trash Card to Link
  139. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  140. selectCardEffect.SetUp(
  141. canTargetCondition: CanLinkTrashCardCondition,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. canNoSelect: () => true,
  145. selectCardCoroutine: SelectCardToLinkCoroutine,
  146. afterSelectCardCoroutine: null,
  147. message: "Select 1 [TS] trait card to link",
  148. maxCount: 1,
  149. canEndNotMax: false,
  150. isShowOpponent: true,
  151. mode: SelectCardEffect.Mode.Custom,
  152. root: SelectCardEffect.Root.Trash,
  153. customRootCardList: null,
  154. canLookReverseCard: true,
  155. selectPlayer: card.Owner,
  156. cardEffect: activateClass);
  157. selectCardEffect.SetUpCustomMessage("Select 1 [TS] trait card from your trash to link.", "The opponent is selecting 1 [TS] trait card from their trash to link.");
  158. selectCardEffect.SetUpCustomMessage_ShowCard("Selected card");
  159. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  160. #endregion
  161. }
  162. bool CanLinkChosenCardCondition(Permanent permanent)
  163. {
  164. return permanent.IsDigimon
  165. && CardEffectCommons.IsOwnerPermanent(permanent, card)
  166. && selectedCardToLink .CanLinkToTargetPermanent(permanent, false, true);
  167. }
  168. #region Select Digimon that will gain selected card as link
  169. if (selectedCardToLink != null)
  170. {
  171. if (CardEffectCommons.HasMatchConditionPermanent(CanLinkChosenCardCondition, true))
  172. {
  173. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  174. selectPermanentEffect.SetUp(
  175. selectPlayer: card.Owner,
  176. canTargetCondition: CanLinkChosenCardCondition,
  177. canTargetCondition_ByPreSelecetedList: null,
  178. canEndSelectCondition: null,
  179. maxCount: 1,
  180. canNoSelect: true,
  181. canEndNotMax: false,
  182. selectPermanentCoroutine: SelectPermamentToLinkToCoroutine,
  183. afterSelectPermanentCoroutine: null,
  184. mode: SelectPermanentEffect.Mode.Custom,
  185. cardEffect: activateClass);
  186. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to gain link.", "The opponent is selecting 1 Digimon to gain link.");
  187. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  188. }
  189. #endregion
  190. }
  191. if (selectedPermament != null && selectedCardToLink != null) yield return ContinuousController.instance.StartCoroutine(selectedPermament.AddLinkCard(selectedCardToLink, activateClass));
  192. }
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region Link Effects
  201. #region Link Condition
  202. if (timing == EffectTiming.None)
  203. {
  204. static bool PermanentCondition(Permanent targetPermanent)
  205. {
  206. return targetPermanent.TopCard.EqualsCardName("Vulcanusmon");
  207. }
  208. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  209. }
  210. #endregion
  211. #region Link
  212. if (timing == EffectTiming.OnDeclaration)
  213. {
  214. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  215. }
  216. #endregion
  217. #region Sec Atk +1/Reboot
  218. if (timing == EffectTiming.None)
  219. {
  220. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null, isLinkedEffect: true));
  221. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null, isLinkedEffect: true));
  222. }
  223. #endregion
  224. #region All Turns
  225. if (timing == EffectTiming.WhenRemoveField)
  226. {
  227. ActivateClass activateClass = new ActivateClass();
  228. activateClass.SetUpICardEffect("Trash 1 link card to not leave battle field", CanUseCondition, card);
  229. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  230. activateClass.SetIsSkippable(true);
  231. activateClass.SetIsLinkedEffect(true);
  232. cardEffects.Add(activateClass);
  233. string EffectDescription()
  234. {
  235. return "[All Turns] When this [Vulcanusmon] would leave the battle area, by trashing 1 of its link cards, it doesn't leave.";
  236. }
  237. bool CanUseCondition(Hashtable hashtable)
  238. {
  239. return CardEffectCommons.IsExistLinked(card) &&
  240. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  241. card.PermanentOfThisCard().TopCard.EqualsCardName("Vulcanusmon");
  242. }
  243. bool CanActivateCondition(Hashtable hashtable)
  244. {
  245. return CardEffectCommons.IsExistLinked(card) &&
  246. !card.PermanentOfThisCard().HasNoLinkCards;
  247. }
  248. bool CanSelectCardCondition(CardSource cardSource)
  249. {
  250. return true;
  251. }
  252. IEnumerator ActivateCoroutine(Hashtable hashtable)
  253. {
  254. CardSource selectedLinkCard = null;
  255. Permanent thisPermanent = card.PermanentOfThisCard();
  256. #region Select Link Card to Trash
  257. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  258. selectCardEffect.SetUp(
  259. canTargetCondition: CanSelectCardCondition,
  260. canTargetCondition_ByPreSelecetedList: null,
  261. canEndSelectCondition: null,
  262. canNoSelect: () => true,
  263. selectCardCoroutine: null,
  264. afterSelectCardCoroutine: SelectCardCoroutine,
  265. message: "Select 1 link card to trash.",
  266. maxCount: 1,
  267. canEndNotMax: false,
  268. isShowOpponent: true,
  269. mode: SelectCardEffect.Mode.Custom,
  270. root: SelectCardEffect.Root.LinkedCards,
  271. customRootCardList: thisPermanent.LinkedCards,
  272. canLookReverseCard: true,
  273. selectPlayer: card.Owner,
  274. cardEffect: activateClass);
  275. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  276. {
  277. if (cardSources.Count > 0)
  278. {
  279. selectedLinkCard = cardSources[0];
  280. yield return null;
  281. }
  282. yield return null;
  283. }
  284. selectCardEffect.SetUpCustomMessage("Select 1 link card to trash.", "The opponent is selecting 1 link card to trash.");
  285. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  286. #endregion
  287. if (selectedLinkCard != null)
  288. {
  289. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  290. targetPermanent: thisPermanent,
  291. targetLinkCards: new List<CardSource>() { selectedLinkCard },
  292. activateClass: activateClass,
  293. successProcess: SuccessProcess,
  294. failureProcess: null));
  295. IEnumerator SuccessProcess(List<CardSource> cardSources)
  296. {
  297. thisPermanent.willBeRemoveField = false;
  298. thisPermanent.HideDeleteEffect();
  299. thisPermanent.HideHandBounceEffect();
  300. thisPermanent.HideDeckBounceEffect();
  301. thisPermanent.HideWillRemoveFieldEffect();
  302. yield return null;
  303. }
  304. }
  305. }
  306. }
  307. #endregion
  308. #endregion
  309. return cardEffects;
  310. }
  311. }
  312. }