EX10_016.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. namespace DCGO.CardEffects.EX10
  6. {
  7. public class EX10_016 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Requirements
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel2 &&
  18. targetPermanent.TopCard.HasAppmonTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Link Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. static bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.HasAppmonTraits;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  31. }
  32. #endregion
  33. #region Link
  34. if (timing == EffectTiming.OnDeclaration)
  35. {
  36. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  37. }
  38. #endregion
  39. #region Your Turn
  40. if (timing == EffectTiming.WhenLinked)
  41. {
  42. ActivateClass activateClass = new ActivateClass();
  43. activateClass.SetUpICardEffect("Suspend 1 Digimon", CanUseCondition, card);
  44. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  45. activateClass.SetHashString("YT_EX10-016");
  46. cardEffects.Add(activateClass);
  47. string EffectDiscription()
  48. {
  49. return "[Your Turn] [Once Per Turn] When this Digimon gets linked, you may suspend 1 of your opponent's Digimon.";
  50. }
  51. bool CanUseCondition(Hashtable hashtable)
  52. {
  53. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  54. && CardEffectCommons.CanTriggerWhenLinked(hashtable, perm => perm == card.PermanentOfThisCard(), null);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  59. CardEffectCommons.IsOwnerTurn(card);
  60. }
  61. bool CanSelectPermanentCondition(Permanent permanent)
  62. {
  63. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  68. {
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: CanSelectPermanentCondition,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: 1,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: null,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Tap,
  81. cardEffect: activateClass);
  82. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  83. }
  84. }
  85. }
  86. #endregion
  87. #region When Attacking - Link
  88. if (timing == EffectTiming.OnAllyAttack)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("Suspend 2 digimon", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  93. activateClass.SetIsLinkedEffect(true);
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. {
  97. return "[When Attacking] By trashing 1 of this Digimon's link cards, suspend 2 of your opponent's Digimon.";
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  102. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  107. !card.PermanentOfThisCard().HasNoLinkCards;
  108. }
  109. bool CanSelectPermanentCondition(Permanent permanent)
  110. {
  111. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. Permanent thisCardPermament = card.PermanentOfThisCard();
  116. CardSource selectedCard = null;
  117. #region Select Link Card
  118. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: _ => true,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => true,
  125. selectCardCoroutine: SelectCardCoroutine,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 linked card to trash.",
  128. maxCount: maxCount,
  129. canEndNotMax: false,
  130. isShowOpponent: true,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.Custom,
  133. customRootCardList: thisCardPermament.LinkedCards,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. IEnumerator SelectCardCoroutine(CardSource cardSource)
  138. {
  139. selectedCard = cardSource;
  140. yield return null;
  141. }
  142. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  143. yield return StartCoroutine(selectCardEffect.Activate());
  144. #endregion
  145. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  146. targetPermanent: thisCardPermament,
  147. targetLinkCards: new List<CardSource>() { selectedCard },
  148. activateClass: activateClass,
  149. successProcess: SuccessProcess,
  150. failureProcess: null));
  151. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  152. {
  153. if (trashedLinkCards.Any())
  154. {
  155. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  156. {
  157. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: null,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Tap,
  170. cardEffect: activateClass);
  171. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  172. }
  173. }
  174. }
  175. }
  176. }
  177. #endregion
  178. return cardEffects;
  179. }
  180. }
  181. }