EX11_029.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // turbomon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_029 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alt Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Maquinamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Shared WM / WD
  22. string SharedEffectName = "Link [Maquinamon] from hand or digivolution cards for free.";
  23. string SharedEffectDescription(string tag) => $"[{tag}] You may link 1 [Maquinamon] from your hand or this Digimon's digivolution cards to 1 of your Digimon without paying the cost.";
  24. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  25. bool IsLinkableMaquinamonCard(CardSource cardSource)
  26. {
  27. return cardSource.EqualsCardName("Maquinamon")
  28. && cardSource.CanLink(false);
  29. }
  30. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  31. {
  32. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, IsLinkableMaquinamonCard);
  33. bool validDigivolutionCard = card.PermanentOfThisCard().DigivolutionCards.Some(IsLinkableMaquinamonCard);
  34. if (validHandCard || validDigivolutionCard)
  35. {
  36. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  37. if (validHandCard)
  38. {
  39. selectionElements.Add(new (message: $"Link Maquinamon from hand", value : 1, spriteIndex: 0));
  40. }
  41. if (validDigivolutionCard)
  42. {
  43. selectionElements.Add(new (message: $"Link Maquinamon from this Digimon's Digivolution Cards", value : 2, spriteIndex: 0));
  44. };
  45. selectionElements.Add(new (message: $"Don't link", value: 3, spriteIndex: 1));
  46. string selectPlayerMessage = "Will you link a Maquinamon?";
  47. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  48. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  49. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  50. bool doLink = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  51. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  52. if (doLink)
  53. {
  54. CardSource selectedCard = null;
  55. IEnumerator SelectCardCoroutine(CardSource cardSource)
  56. {
  57. selectedCard = cardSource;
  58. yield return null;
  59. }
  60. if (fromHand)
  61. {
  62. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  63. selectHandEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: IsLinkableMaquinamonCard,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: 1,
  69. canNoSelect: true,
  70. canEndNotMax: false,
  71. isShowOpponent: true,
  72. selectCardCoroutine: SelectCardCoroutine,
  73. afterSelectCardCoroutine: null,
  74. mode: SelectHandEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectHandEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  77. yield return StartCoroutine(selectHandEffect.Activate());
  78. }
  79. else
  80. {
  81. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  82. selectCardEffect.SetUp(
  83. canTargetCondition: IsLinkableMaquinamonCard,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. canNoSelect: () => true,
  87. selectCardCoroutine: SelectCardCoroutine,
  88. afterSelectCardCoroutine: null,
  89. message: "Select 1 card to link.",
  90. maxCount: 1,
  91. canEndNotMax: false,
  92. isShowOpponent: true,
  93. mode: SelectCardEffect.Mode.Custom,
  94. root: SelectCardEffect.Root.Custom,
  95. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  96. canLookReverseCard: true,
  97. selectPlayer: card.Owner,
  98. cardEffect: activateClass);
  99. selectCardEffect.SetUpCustomMessage("Select 1 card to link.", "The opponent is selecting 1 card to link.");
  100. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Cards");
  101. yield return StartCoroutine(selectCardEffect.Activate());
  102. }
  103. if (selectedCard != null)
  104. {
  105. bool CanSelectDigimon(Permanent permanent)
  106. {
  107. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  108. return selectedCard.CanLinkToTargetPermanent(permanent, false);
  109. return false;
  110. }
  111. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectDigimon))
  112. {
  113. Permanent selectedPermanent = null;
  114. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  115. selectPermanentEffect.SetUp(
  116. selectPlayer: card.Owner,
  117. canTargetCondition: CanSelectDigimon,
  118. canTargetCondition_ByPreSelecetedList: null,
  119. canEndSelectCondition: null,
  120. maxCount: 1,
  121. canNoSelect: true,
  122. canEndNotMax: false,
  123. selectPermanentCoroutine: SelectPermanentCoroutine,
  124. afterSelectPermanentCoroutine: null,
  125. mode: SelectPermanentEffect.Mode.Custom,
  126. cardEffect: activateClass);
  127. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to add link", "The opponent is selecting 1 digimon to add link");
  128. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  129. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  130. {
  131. selectedPermanent = permanent;
  132. yield return null;
  133. }
  134. if (selectedPermanent != null)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(selectedCard, activateClass));
  137. }
  138. }
  139. }
  140. }
  141. }
  142. }
  143. #endregion
  144. #region When Moving
  145. if (timing == EffectTiming.OnMove)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  149. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Moving"));
  150. cardEffects.Add(activateClass);
  151. bool PermanentCondition(Permanent permanent)
  152. {
  153. return permanent == card.PermanentOfThisCard();
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  158. CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition);
  159. }
  160. }
  161. #endregion
  162. #region When Digivolving
  163. if (timing == EffectTiming.OnEnterFieldAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  167. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  168. cardEffects.Add(activateClass);
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  172. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  173. }
  174. }
  175. #endregion
  176. #region Your Turn
  177. if (timing == EffectTiming.WhenLinked)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect("Play 1 [Unchained] form hand or trash", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  182. activateClass.SetHashString("EX11_029_YT");
  183. cardEffects.Add(activateClass);
  184. string EffectDescription() => "[Your Turn] [Once Per Turn] When this Digimon gets linked, if you have 1 or fewer Tamers, you may play 1 [Unchained] from your hand or trash without paying the cost.";
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  188. && CardEffectCommons.IsOwnerTurn(card)
  189. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  190. }
  191. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  192. bool CanActivateCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  195. && CardEffectCommons.MatchConditionOwnersPermanentCount(card, permanent => permanent.IsTamer) <= 1
  196. && (CardEffectCommons.HasMatchConditionOwnersHand(card, IsUnchained)
  197. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsUnchained));
  198. }
  199. bool IsUnchained(CardSource cardSource) => cardSource.EqualsCardName("Unchained");
  200. IEnumerator ActivateCoroutine(Hashtable hashtable)
  201. {
  202. bool isValidHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsUnchained);
  203. bool isValidTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsUnchained);
  204. if (isValidHand && isValidTrash)
  205. {
  206. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  207. {
  208. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  209. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  210. };
  211. string selectPlayerMessage1 = "From which area do you select a card?";
  212. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  213. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  214. }
  215. else
  216. {
  217. GManager.instance.userSelectionManager.SetBool(isValidHand);
  218. }
  219. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  220. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  221. List<CardSource> selectedCards = new List<CardSource>();
  222. IEnumerator SelectCardCoroutine(CardSource cardSource)
  223. {
  224. selectedCards.Add(cardSource);
  225. yield return null;
  226. }
  227. if(fromHand)
  228. {
  229. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  230. selectHandEffect.SetUp(
  231. selectPlayer: card.Owner,
  232. canTargetCondition: IsUnchained,
  233. canTargetCondition_ByPreSelecetedList: null,
  234. canEndSelectCondition: null,
  235. maxCount: 1,
  236. canNoSelect: true,
  237. canEndNotMax: false,
  238. isShowOpponent: true,
  239. selectCardCoroutine: SelectCardCoroutine,
  240. afterSelectCardCoroutine: null,
  241. mode: SelectHandEffect.Mode.Custom,
  242. cardEffect: activateClass);
  243. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  244. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  245. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  246. if (selectedCards.Count > 0)
  247. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  248. }
  249. else
  250. {
  251. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  252. selectCardEffect.SetUp(
  253. canTargetCondition: IsUnchained,
  254. canTargetCondition_ByPreSelecetedList: null,
  255. canEndSelectCondition: null,
  256. canNoSelect: () => true,
  257. selectCardCoroutine: SelectCardCoroutine,
  258. afterSelectCardCoroutine: null,
  259. message: "Select 1 card to play",
  260. maxCount: 1,
  261. canEndNotMax: false,
  262. isShowOpponent: true,
  263. mode: SelectCardEffect.Mode.Custom,
  264. root: SelectCardEffect.Root.Trash,
  265. customRootCardList: null,
  266. canLookReverseCard: true,
  267. selectPlayer: card.Owner,
  268. cardEffect: activateClass);
  269. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  270. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  271. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  272. if (selectedCards.Count > 0)
  273. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  274. }
  275. }
  276. }
  277. #endregion
  278. #region ESS - Piercing
  279. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  280. {
  281. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  282. }
  283. #endregion
  284. return cardEffects;
  285. }
  286. }
  287. }