EX11_042.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // MockingBirdmon
  4. namespace DCGO.CardEffects.EX11
  5. {
  6. public class EX11_042 : 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 OP / 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 On Play
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  114. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  115. cardEffects.Add(activateClass);
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  119. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  120. }
  121. }
  122. #endregion
  123. #region When Digivolving
  124. if (timing == EffectTiming.OnEnterFieldAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  128. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  129. cardEffects.Add(activateClass);
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  133. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. }
  136. #endregion
  137. #region Your Turn
  138. if (timing == EffectTiming.WhenLinked)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Delete an opponent's 5 cost or less Digimon", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  143. activateClass.SetHashString("EX11_042_YT");
  144. cardEffects.Add(activateClass);
  145. string EffectDescription() => "[Your Turn] [Once Per Turn] When this Digimon gets linked, delete 1 of your opponent's Digimon with a play cost of 5 or less.";
  146. bool CanUseCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  149. && CardEffectCommons.CanTriggerWhenLinked(hashtable, PermanentCondition, null)
  150. && CardEffectCommons.IsOwnerTurn(card);
  151. }
  152. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  153. bool CanActivateCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  156. }
  157. bool CanSelectPermanentCondition(Permanent permanent)
  158. {
  159. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  160. && permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 5;
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  165. {
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectPermanentCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: 1,
  173. canNoSelect: false,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: null,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Destroy,
  178. cardEffect: activateClass);
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. }
  181. }
  182. }
  183. #endregion
  184. #region ESS - Redirect
  185. if (timing == EffectTiming.OnAllyAttack)
  186. {
  187. ActivateClass activateClass = new ActivateClass();
  188. activateClass.SetUpICardEffect("You may change the attack target to this Digimon.", CanUseCondition, card);
  189. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  190. activateClass.SetHashString("Redirect_EX11_042");
  191. activateClass.SetIsInheritedEffect(true);
  192. cardEffects.Add(activateClass);
  193. string EffectDiscription()
  194. {
  195. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  196. }
  197. bool IsOpponentDigimon(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  204. && CardEffectCommons.IsOpponentTurn(card)
  205. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  206. }
  207. bool CanActivateCondition(Hashtable hashtable)
  208. {
  209. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  210. }
  211. IEnumerator ActivateCoroutine(Hashtable hashtable)
  212. {
  213. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  214. activateClass,
  215. false,
  216. card.PermanentOfThisCard()));
  217. }
  218. }
  219. #endregion
  220. return cardEffects;
  221. }
  222. }
  223. }