EX11_040.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Mulemon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_040 : 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 OP / 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 On Play
  145. if (timing == EffectTiming.OnEnterFieldAnyone)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  149. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  150. cardEffects.Add(activateClass);
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  154. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  155. }
  156. }
  157. #endregion
  158. #region When Digivolving
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  163. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  164. cardEffects.Add(activateClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  168. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  169. }
  170. }
  171. #endregion
  172. #region Your Turn
  173. if (timing == EffectTiming.WhenLinked)
  174. {
  175. ActivateClass activateClass = new ActivateClass();
  176. activateClass.SetUpICardEffect("Play 1 [Unchained] form hand or trash", CanUseCondition, card);
  177. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  178. activateClass.SetHashString("EX11_040_YT");
  179. cardEffects.Add(activateClass);
  180. 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.";
  181. bool CanUseCondition(Hashtable hashtable)
  182. {
  183. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  184. && CardEffectCommons.IsOwnerTurn(card)
  185. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null);
  186. }
  187. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  191. && CardEffectCommons.MatchConditionOwnersPermanentCount(card, permanent => permanent.IsTamer) <= 1
  192. && (CardEffectCommons.HasMatchConditionOwnersHand(card, IsUnchained)
  193. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsUnchained));
  194. }
  195. bool IsUnchained(CardSource cardSource) => cardSource.EqualsCardName("Unchained");
  196. IEnumerator ActivateCoroutine(Hashtable hashtable)
  197. {
  198. bool isValidHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsUnchained);
  199. bool isValidTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsUnchained);
  200. if (isValidHand && isValidTrash)
  201. {
  202. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  203. {
  204. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  205. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  206. };
  207. string selectPlayerMessage1 = "From which area do you select a card?";
  208. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  209. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  210. }
  211. else
  212. {
  213. GManager.instance.userSelectionManager.SetBool(isValidHand);
  214. }
  215. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  216. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  217. List<CardSource> selectedCards = new List<CardSource>();
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCards.Add(cardSource);
  221. yield return null;
  222. }
  223. if(fromHand)
  224. {
  225. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  226. selectHandEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: IsUnchained,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: true,
  233. canEndNotMax: false,
  234. isShowOpponent: true,
  235. selectCardCoroutine: SelectCardCoroutine,
  236. afterSelectCardCoroutine: null,
  237. mode: SelectHandEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  240. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  241. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  242. if (selectedCards.Count > 0)
  243. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  244. }
  245. else
  246. {
  247. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  248. selectCardEffect.SetUp(
  249. canTargetCondition: IsUnchained,
  250. canTargetCondition_ByPreSelecetedList: null,
  251. canEndSelectCondition: null,
  252. canNoSelect: () => true,
  253. selectCardCoroutine: SelectCardCoroutine,
  254. afterSelectCardCoroutine: null,
  255. message: "Select 1 card to play",
  256. maxCount: 1,
  257. canEndNotMax: false,
  258. isShowOpponent: true,
  259. mode: SelectCardEffect.Mode.Custom,
  260. root: SelectCardEffect.Root.Trash,
  261. customRootCardList: null,
  262. canLookReverseCard: true,
  263. selectPlayer: card.Owner,
  264. cardEffect: activateClass);
  265. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  266. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  267. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  268. if (selectedCards.Count > 0)
  269. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  270. }
  271. }
  272. }
  273. #endregion
  274. #region ESS - Reboot
  275. if (timing == EffectTiming.None)
  276. {
  277. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  278. }
  279. #endregion
  280. return cardEffects;
  281. }
  282. }
  283. }