EX7_027.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX7
  4. {
  5. public class EX7_027 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Overclock
  11. if (timing == EffectTiming.OnEndTurn)
  12. {
  13. cardEffects.Add(CardEffectFactory.OverclockSelfEffect(trait: "Puppet", isInheritedEffect: false, card: card,
  14. condition: null));
  15. }
  16. #endregion
  17. #region When Digivolving
  18. if (timing == EffectTiming.OnEnterFieldAnyone)
  19. {
  20. ActivateClass activateClass = new ActivateClass();
  21. activateClass.SetUpICardEffect("Play 1 level 3 [Puppet] Digimon", CanUseCondition, card);
  22. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  23. cardEffects.Add(activateClass);
  24. string EffectDescription()
  25. {
  26. return
  27. "[When Digivolving] You may play 1 level 3 Digimon card with the [Puppet] trait from your hand without paying the cost.";
  28. }
  29. bool CanUseCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  32. }
  33. bool IsLevel3PuppetCardCondition(CardSource cardSource)
  34. {
  35. return cardSource.IsDigimon &&
  36. cardSource.HasLevel &&
  37. cardSource.IsLevel3 &&
  38. cardSource.ContainsTraits("Puppet") &&
  39. CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  44. CardEffectCommons.HasMatchConditionOwnersHand(card, IsLevel3PuppetCardCondition);
  45. }
  46. IEnumerator ActivateCoroutine(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.HasMatchConditionOwnersHand(card, IsLevel3PuppetCardCondition))
  49. {
  50. List<CardSource> selectedCards = new List<CardSource>();
  51. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  52. selectHandEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: IsLevel3PuppetCardCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: true,
  59. canEndNotMax: false,
  60. isShowOpponent: true,
  61. selectCardCoroutine: SelectCardCoroutine,
  62. afterSelectCardCoroutine: null,
  63. mode: SelectHandEffect.Mode.Custom,
  64. cardEffect: activateClass);
  65. selectHandEffect.SetUpCustomMessage("Select 1 Digimon card to play.",
  66. "The opponent is selecting 1 Digimon card to play.");
  67. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  68. yield return StartCoroutine(selectHandEffect.Activate());
  69. IEnumerator SelectCardCoroutine(CardSource cardSource)
  70. {
  71. selectedCards.Add(cardSource);
  72. yield return null;
  73. }
  74. yield return ContinuousController.instance.StartCoroutine(
  75. CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass,
  76. payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  77. }
  78. }
  79. }
  80. #endregion
  81. #region All Turns - ESS
  82. if (timing == EffectTiming.WhenRemoveField)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Delete 1 of your other Digimon to prevent this Digimon from leaving",
  86. CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  88. activateClass.SetIsInheritedEffect(true);
  89. activateClass.SetHashString("Substitute_EX7_027");
  90. cardEffects.Add(activateClass);
  91. string EffectDescription()
  92. {
  93. return
  94. "[All Turns][Once Per Turn] When this Digimon would leave the battle area other than by one of your effects, by deleting 1 of your Tokens or 1 of your other Digimon with the [Puppet] trait, prevent it from leaving.";
  95. }
  96. bool CanSelectPermanentCondition(Permanent permanent)
  97. {
  98. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  99. permanent != card.PermanentOfThisCard() &&
  100. (permanent.IsToken || permanent.TopCard.ContainsTraits("Puppet"));
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  105. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card) &&
  106. !CardEffectCommons.IsByEffect(hashtable, cardEffect => CardEffectCommons.IsOwnerEffect(cardEffect, card));
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  111. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable hashtable)
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  116. {
  117. Permanent thisCardPermanent = card.PermanentOfThisCard();
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: 1,
  125. canNoSelect: true,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: SelectPermanentCoroutine,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  132. "The opponent is selecting 1 Digimon to delete.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(
  137. CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  138. targetPermanents: new List<Permanent>() { permanent },
  139. activateClass: activateClass,
  140. successProcess: _ => SuccessProcess(),
  141. failureProcess: null));
  142. IEnumerator SuccessProcess()
  143. {
  144. thisCardPermanent.willBeRemoveField = false;
  145. thisCardPermanent.HideDeleteEffect();
  146. thisCardPermanent.HideHandBounceEffect();
  147. thisCardPermanent.HideDeckBounceEffect();
  148. thisCardPermanent.HideWillRemoveFieldEffect();
  149. yield return null;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. #endregion
  156. return cardEffects;
  157. }
  158. }
  159. }