BT22_057.cs 9.1 KB

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