EX10_024.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Kabemon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_024 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alternate Digivolution Requirement
  15. if (timing == EffectTiming.None)
  16. {
  17. static bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasAppmonTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Link
  25. if (timing == EffectTiming.OnDeclaration)
  26. {
  27. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  28. }
  29. #endregion
  30. #region Link Condition
  31. if (timing == EffectTiming.None)
  32. {
  33. static bool PermanentCondition(Permanent targetPermanent)
  34. {
  35. return targetPermanent.TopCard.HasAppmonTraits;
  36. }
  37. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  38. }
  39. #endregion
  40. #region Security
  41. if (timing == EffectTiming.SecuritySkill)
  42. {
  43. cardEffects.Add(CardEffectFactory.PlaySelfDigimonAfterBattleSecurityEffect(card: card));
  44. }
  45. #endregion
  46. #endregion
  47. #region Link Effect
  48. if (timing == EffectTiming.OnAllyAttack)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("By trashing 1 linked card, De-Digivolve 1", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  53. activateClass.SetIsLinkedEffect(true);
  54. cardEffects.Add(activateClass);
  55. string EffectDiscription()
  56. {
  57. return "[When Attacking] By trashing 1 of this Digimon's link cards, <De-Digivolve 1> 1 of your opponent's Digimon. (Trash the top card. You can't trash past level 3 cards.)";
  58. }
  59. bool CanUseCondition(Hashtable hashtable)
  60. {
  61. return CardEffectCommons.IsExistOnBattleArea(card)
  62. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. return CardEffectCommons.IsExistOnBattleArea(card)
  67. && HasLinkedCards(card.PermanentOfThisCard().TopCard.PermanentOfThisCard());
  68. }
  69. bool PermamentCondition(Permanent permanent)
  70. {
  71. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  72. }
  73. bool HasLinkedCards(Permanent permanent)
  74. {
  75. return !permanent.HasNoLinkCards;
  76. }
  77. IEnumerator ActivateCoroutine(Hashtable hashtable)
  78. {
  79. Permanent thisCardPermament = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  80. if (HasLinkedCards(thisCardPermament))
  81. {
  82. CardSource selectedCard = null;
  83. #region Select Link Card
  84. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  85. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  86. selectCardEffect.SetUp(
  87. canTargetCondition: _ => true,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. canNoSelect: () => true,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. message: "Select 1 linked card to trash.",
  94. maxCount: maxCount,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. mode: SelectCardEffect.Mode.Custom,
  98. root: SelectCardEffect.Root.Custom,
  99. customRootCardList: thisCardPermament.LinkedCards,
  100. canLookReverseCard: true,
  101. selectPlayer: card.Owner,
  102. cardEffect: activateClass);
  103. IEnumerator SelectCardCoroutine(CardSource cardSource)
  104. {
  105. selectedCard = cardSource;
  106. yield return null;
  107. }
  108. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  109. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  110. #endregion
  111. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  112. targetPermanent: thisCardPermament,
  113. targetLinkCards: new List<CardSource>() { selectedCard },
  114. activateClass: activateClass,
  115. successProcess: SuccessProcess,
  116. failureProcess: null));
  117. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  118. {
  119. if (trashedLinkCards.Any() && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, PermamentCondition))
  120. {
  121. Permanent selectedPermament = null;
  122. #region Select Opponent Digimon
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, PermamentCondition));
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: PermamentCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: false,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: SelectPermanentCoroutine,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.Custom,
  136. cardEffect: activateClass);
  137. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  138. {
  139. selectedPermament = permanent;
  140. yield return null;
  141. }
  142. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  143. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  144. #endregion
  145. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  146. permanent: selectedPermament,
  147. DegenerationCount: 1,
  148. cardEffect: activateClass).Degeneration());
  149. }
  150. }
  151. }
  152. }
  153. }
  154. #endregion
  155. return cardEffects;
  156. }
  157. }
  158. }