EX11_033.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Maneuvremon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_033 : 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.IsLevel4 && targetPermanent.TopCard.HasText("Maquinamon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Shared WM / WD
  22. string SharedEffectName = "Play [Maquinamon] from hand or from Link cards for free.";
  23. string SharedEffectDescription(string tag) => $"[{tag}] You may play 1 [Maquinamon] from your hand or this Digimon's link cards without paying the cost.";
  24. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  25. bool IsMaquinamonCard(CardSource cardSource)
  26. {
  27. return cardSource.EqualsCardName("Maquinamon");
  28. }
  29. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  30. {
  31. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, IsMaquinamonCard);
  32. bool validLinkCard = card.PermanentOfThisCard().LinkedCards.Some(IsMaquinamonCard);
  33. if (validHandCard || validLinkCard)
  34. {
  35. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  36. if (validHandCard)
  37. {
  38. selectionElements.Add(new (message: $"Play Maquinamon from hand", value : 1, spriteIndex: 0));
  39. }
  40. if (validLinkCard)
  41. {
  42. selectionElements.Add(new (message: $"Play Maquinamon from this Digimon's Link Cards", value : 2, spriteIndex: 0));
  43. };
  44. selectionElements.Add( new (message: $"Don't play", value: 3, spriteIndex: 1));
  45. string selectPlayerMessage = "Will you play a Maquinamon?";
  46. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  47. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  48. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  49. bool doPlay = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  50. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  51. if (doPlay)
  52. {
  53. List<CardSource> selectedCards = new List<CardSource>();
  54. IEnumerator SelectCardCoroutine(CardSource cardSource)
  55. {
  56. selectedCards.Add(cardSource);
  57. yield return null;
  58. }
  59. if (fromHand)
  60. {
  61. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  62. selectHandEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: IsMaquinamonCard,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: 1,
  68. canNoSelect: true,
  69. canEndNotMax: false,
  70. isShowOpponent: true,
  71. selectCardCoroutine: SelectCardCoroutine,
  72. afterSelectCardCoroutine: null,
  73. mode: SelectHandEffect.Mode.Custom,
  74. cardEffect: activateClass);
  75. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  76. yield return StartCoroutine(selectHandEffect.Activate());
  77. if (selectedCards.Count > 0)
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  79. }
  80. else
  81. {
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: IsMaquinamonCard,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => true,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. message: "Select 1 card to play.",
  91. maxCount: 1,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Custom,
  96. customRootCardList: card.PermanentOfThisCard().LinkedCards,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  101. yield return StartCoroutine(selectCardEffect.Activate());
  102. if (selectedCards.Count > 0)
  103. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.LinkedCards, activateETB: true));
  104. }
  105. }
  106. }
  107. }
  108. #endregion
  109. #region When Moving
  110. if (timing == EffectTiming.OnMove)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  114. activateClass.SetUpActivateClass(SharedCanActivateCondition, (hashTable) => SharedActivateCoroutine(hashTable, activateClass), -1, false, SharedEffectDescription("When Moving"));
  115. cardEffects.Add(activateClass);
  116. bool PermanentCondition(Permanent permanent)
  117. {
  118. return permanent == card.PermanentOfThisCard();
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  123. CardEffectCommons.CanTriggerOnMove(hashtable, PermanentCondition);
  124. }
  125. }
  126. #endregion
  127. #region When Digivolving
  128. if (timing == EffectTiming.OnEnterFieldAnyone)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  132. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  133. cardEffects.Add(activateClass);
  134. bool CanUseCondition(Hashtable hashtable)
  135. {
  136. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  137. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  138. }
  139. }
  140. #endregion
  141. #region Your Turn
  142. if (timing == EffectTiming.WhenLinked)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("Suspend 1 opponent's Digimon. 1 of their Digimon can't unsuspend.", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  147. activateClass.SetHashString("EX11_033_YT");
  148. cardEffects.Add(activateClass);
  149. string EffectDescription() => "[Your Turn] [Once Per Turn] When this Digimon gets linked, suspend 1 of your opponent's Digimon. Then, 1 of their Digimon can't unsuspend until their turns ends.";
  150. bool CanUseCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  153. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null)
  154. && CardEffectCommons.IsOwnerTurn(card);
  155. }
  156. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  160. }
  161. bool CanSelectPermanentCondition(Permanent permanent)
  162. {
  163. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  164. }
  165. IEnumerator ActivateCoroutine(Hashtable hashtable)
  166. {
  167. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  168. {
  169. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  170. selectPermanentEffect1.SetUp(
  171. selectPlayer: card.Owner,
  172. canTargetCondition: CanSelectPermanentCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. maxCount: 1,
  176. canNoSelect: false,
  177. canEndNotMax: false,
  178. selectPermanentCoroutine: null,
  179. afterSelectPermanentCoroutine: null,
  180. mode: SelectPermanentEffect.Mode.Tap,
  181. cardEffect: activateClass);
  182. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to Suspend.", "The opponent is selecting 1 Digimon to Suspend.");
  183. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  184. SelectPermanentEffect selectPermanentEffect2 = GManager.instance.GetComponent<SelectPermanentEffect>();
  185. selectPermanentEffect2 = GManager.instance.GetComponent<SelectPermanentEffect>();
  186. selectPermanentEffect2.SetUp(
  187. selectPlayer: card.Owner,
  188. canTargetCondition: CanSelectPermanentCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. maxCount: 1,
  192. canNoSelect: false,
  193. canEndNotMax: false,
  194. selectPermanentCoroutine: SelectPermanentCoroutine,
  195. afterSelectPermanentCoroutine: null,
  196. mode: SelectPermanentEffect.Mode.Custom,
  197. cardEffect: activateClass);
  198. selectPermanentEffect2.SetUpCustomMessage("Select 1 Digimon that can't unsuspend.", "The opponent is selecting 1 Digimon that can't unsuspend.");
  199. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect2.Activate());
  200. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  201. {
  202. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCantUnsuspendUntilOpponentTurnEnd(
  203. targetPermanent: permanent,
  204. activateClass: activateClass
  205. ));
  206. }
  207. }
  208. }
  209. }
  210. #endregion
  211. #region ESS
  212. if (timing == EffectTiming.OnEndBattle)
  213. {
  214. ActivateClass activateClass = new ActivateClass();
  215. activateClass.SetUpICardEffect("Unsuspend this Digimon", CanUseCondition, card);
  216. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  217. activateClass.SetIsInheritedEffect(true);
  218. activateClass.SetHashString("EX11_033_AT_ESS");
  219. cardEffects.Add(activateClass);
  220. string EffectDescription() => "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, this Digimon may unsuspend.";
  221. bool CanUseCondition(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.IsExistOnBattleArea(card))
  224. {
  225. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  226. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  227. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(
  228. hashtable: hashtable,
  229. winnerCondition: WinnerCondition,
  230. loserCondition: LoserCondition,
  231. isOnlyWinnerSurvive: true))
  232. {
  233. return true;
  234. }
  235. }
  236. return false;
  237. }
  238. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  239. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  240. {
  241. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  242. new List<Permanent>() { card.PermanentOfThisCard() },
  243. activateClass).Unsuspend());
  244. }
  245. }
  246. #endregion
  247. return cardEffects;
  248. }
  249. }
  250. }