EX10_029.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //EX10 Warpmon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_029 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Security
  14. if (timing == EffectTiming.SecuritySkill)
  15. {
  16. cardEffects.Add(CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect(card: card));
  17. }
  18. #endregion
  19. #region Alternative Digivolution Condition
  20. if (timing == EffectTiming.None)
  21. {
  22. bool PermanentCondition(Permanent targetPermanent)
  23. {
  24. return targetPermanent.TopCard.HasStandardAppTraits;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region Link Condition
  30. if (timing == EffectTiming.None)
  31. {
  32. static bool PermanentCondition(Permanent targetPermanent)
  33. {
  34. return targetPermanent.TopCard.HasAppmonTraits;
  35. }
  36. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  37. }
  38. #endregion
  39. #region Link
  40. if (timing == EffectTiming.OnDeclaration)
  41. {
  42. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  43. }
  44. #endregion
  45. #region Blocker
  46. if (timing == EffectTiming.None)
  47. {
  48. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  49. isInheritedEffect: false,
  50. card: card,
  51. condition: null));
  52. }
  53. #endregion
  54. #region When Linked
  55. if (timing == EffectTiming.WhenLinked)
  56. {
  57. ActivateClass activateClass = new ActivateClass();
  58. activateClass.SetUpICardEffect("De-digivolve protection", CanUseCondition, card);
  59. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  60. activateClass.SetIsLinkedEffect(true);
  61. cardEffects.Add(activateClass);
  62. string EffectDescription() => "[When Linking] By trashing 1 of this Digimon's link cards, <De-Digivolve> effects don't affect 1 of your Digimon until your opponent's turn ends.";
  63. bool CanUseCondition(Hashtable hashtable)
  64. {
  65. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  66. }
  67. bool CanActivateCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  70. !card.PermanentOfThisCard().HasNoLinkCards;
  71. }
  72. bool CanSelectPermanentCondition(Permanent permanent)
  73. {
  74. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable hashtable)
  77. {
  78. Permanent thisCardPermament = card.PermanentOfThisCard();
  79. CardSource selectedCard = null;
  80. #region Select Link Card
  81. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  82. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  83. selectCardEffect.SetUp(
  84. canTargetCondition: _ => true,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. canNoSelect: () => true,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. message: "Select 1 linked card to trash.",
  91. maxCount: maxCount,
  92. canEndNotMax: false,
  93. isShowOpponent: true,
  94. mode: SelectCardEffect.Mode.Custom,
  95. root: SelectCardEffect.Root.Custom,
  96. customRootCardList: thisCardPermament.LinkedCards,
  97. canLookReverseCard: true,
  98. selectPlayer: card.Owner,
  99. cardEffect: activateClass);
  100. IEnumerator SelectCardCoroutine(CardSource cardSource)
  101. {
  102. selectedCard = cardSource;
  103. yield return null;
  104. }
  105. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  106. yield return StartCoroutine(selectCardEffect.Activate());
  107. #endregion
  108. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  109. targetPermanent: thisCardPermament,
  110. targetLinkCards: new List<CardSource>() { selectedCard },
  111. activateClass: activateClass,
  112. successProcess: SuccessProcess,
  113. failureProcess: null));
  114. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  115. {
  116. if (trashedLinkCards.Any())
  117. {
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  119. {
  120. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  121. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  122. Permanent selectedPermanent = null;
  123. selectPermanentEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectPermanentCondition,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: false,
  130. canEndNotMax: false,
  131. selectPermanentCoroutine: SelectPermanentCoroutine,
  132. afterSelectPermanentCoroutine: null,
  133. mode: SelectPermanentEffect.Mode.Custom,
  134. cardEffect: activateClass);
  135. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  136. {
  137. selectedPermanent = permanent;
  138. yield return null;
  139. }
  140. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain De-digivolve immunity.", "The opponent is selecting 1 Digimon to gain De-digivolve immunity.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. if (selectedPermanent != null)
  143. {
  144. #region De-digivolve immunity
  145. bool CanUseImmunityCondition(Hashtable hashtable1)
  146. {
  147. return selectedPermanent.TopCard != null;
  148. }
  149. bool PermanentImmunityCondition(Permanent permanent)
  150. {
  151. return permanent == selectedPermanent;
  152. }
  153. ImmuneFromDeDigivolveClass immuneFromDeDigivolveClass = new ImmuneFromDeDigivolveClass();
  154. immuneFromDeDigivolveClass.SetUpICardEffect("Isn't affected by <De-Digivolve>", CanUseImmunityCondition, selectedPermanent.TopCard);
  155. immuneFromDeDigivolveClass.SetUpImmuneFromDeDigivolveClass(PermanentCondition: PermanentImmunityCondition);
  156. selectedPermanent.UntilOpponentTurnEndEffects.Add((_timing) => immuneFromDeDigivolveClass);
  157. #endregion
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. #endregion
  165. return cardEffects;
  166. }
  167. }
  168. }