EX10_015.cs 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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_015 : 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.HasSaveText;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Digixros
  24. if (timing == EffectTiming.None)
  25. {
  26. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  27. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros", CanUseCondition, card);
  28. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  29. addDigiXrosConditionClass.SetNotShowUI(true);
  30. cardEffects.Add(addDigiXrosConditionClass);
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return true;
  34. }
  35. DigiXrosCondition GetDigiXros(CardSource cardSource)
  36. {
  37. if (cardSource == card)
  38. {
  39. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition, "Digimon card with <Save> in text");
  40. bool CanSelectCardCondition(CardSource cardSource)
  41. {
  42. if (cardSource != null)
  43. {
  44. if (cardSource.Owner == card.Owner)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (cardSource.HasSaveText)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. return false;
  56. }
  57. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  58. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  59. return digiXrosCondition;
  60. }
  61. return null;
  62. }
  63. }
  64. #endregion
  65. #region Save
  66. if (timing == EffectTiming.OnDestroyedAnyone)
  67. {
  68. cardEffects.Add(CardEffectFactory.SaveEffect(card: card));
  69. }
  70. #endregion
  71. #region Start of Your Main Phase
  72. if (timing == EffectTiming.OnStartMainPhase)
  73. {
  74. ActivateClass activateClass = new ActivateClass();
  75. activateClass.SetUpICardEffect("Trash 1, Draw 1, Suspend 1 Digimon", CanUseCondition, card);
  76. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  77. cardEffects.Add(activateClass);
  78. string EffectDiscription()
  79. {
  80. return "[Start of Your Main Phase] By trashing 1 card with <Save> in its text from your hand, <Draw 1> (Draw 1 card from your deck.) and suspend 1 of your opponent's Digimon.";
  81. }
  82. bool CanUseCondition(Hashtable hashtable)
  83. {
  84. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  85. CardEffectCommons.IsOwnerTurn(card);
  86. }
  87. bool CanActivateCondition(Hashtable hashtable)
  88. {
  89. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  90. card.Owner.HandCards.Any(x => x.HasSaveText);
  91. }
  92. bool DiscardWithSave(CardSource source)
  93. {
  94. return source.HasSaveText;
  95. }
  96. bool CanSelectPermanentCondition(Permanent permanent)
  97. {
  98. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  99. }
  100. IEnumerator ActivateCoroutine(Hashtable hashtable)
  101. {
  102. bool discarded = false;
  103. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  104. selectHandEffect.SetUp(
  105. selectPlayer: card.Owner,
  106. canTargetCondition: DiscardWithSave,
  107. canTargetCondition_ByPreSelecetedList: null,
  108. canEndSelectCondition: null,
  109. maxCount: 1,
  110. canNoSelect: true,
  111. canEndNotMax: false,
  112. isShowOpponent: true,
  113. selectCardCoroutine: null,
  114. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  115. mode: SelectHandEffect.Mode.Discard,
  116. cardEffect: activateClass);
  117. yield return StartCoroutine(selectHandEffect.Activate());
  118. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  119. {
  120. if (cardSources.Count == 1)
  121. {
  122. discarded = true;
  123. yield return null;
  124. }
  125. }
  126. if (discarded)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  129. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  130. {
  131. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  132. selectPermanentEffect.SetUp(
  133. selectPlayer: card.Owner,
  134. canTargetCondition: CanSelectPermanentCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. maxCount: 1,
  138. canNoSelect: false,
  139. canEndNotMax: false,
  140. selectPermanentCoroutine: null,
  141. afterSelectPermanentCoroutine: null,
  142. mode: SelectPermanentEffect.Mode.Tap,
  143. cardEffect: activateClass);
  144. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  145. }
  146. }
  147. }
  148. }
  149. #endregion
  150. #region ESS - Piercing
  151. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  152. {
  153. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: true, card: card, condition: null));
  154. }
  155. #endregion
  156. return cardEffects;
  157. }
  158. }
  159. }