BT23_023.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Whamon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_023 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.HasCSTraits
  19. && targetPermanent.TopCard.HasLevel
  20. && targetPermanent.TopCard.IsLevel4;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region AT Shared
  32. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass, bool IsTopCard)
  33. {
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. return cardSource.IsDigimon
  37. && cardSource.HasLevel && cardSource.Level <= 4
  38. && (cardSource.HasCSTraits || cardSource.HasCardColor(CardColor.Blue))
  39. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  40. }
  41. Permanent thisPermament = null;
  42. if (IsTopCard) thisPermament = card.PermanentOfThisCard();
  43. else thisPermament = card.PermanentOfThisCard().TopCard.PermanentOfThisCard();
  44. if (thisPermament.StackCards.Exists(CanSelectCardCondition))
  45. {
  46. CardSource selectedCard = null;
  47. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  48. int maxCount = Math.Min(1, thisPermament.StackCards.Count(CanSelectCardCondition));
  49. selectCardEffect.SetUp(
  50. canTargetCondition: CanSelectCardCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. canNoSelect: () => false,
  54. selectCardCoroutine: SelectCardCoroutine,
  55. afterSelectCardCoroutine: null,
  56. message: "Select 1 digivolution card to play.",
  57. maxCount: maxCount,
  58. canEndNotMax: false,
  59. isShowOpponent: true,
  60. mode: SelectCardEffect.Mode.Custom,
  61. root: SelectCardEffect.Root.Custom,
  62. customRootCardList: thisPermament.DigivolutionCards,
  63. canLookReverseCard: true,
  64. selectPlayer: card.Owner,
  65. cardEffect: activateClass);
  66. IEnumerator SelectCardCoroutine(CardSource cardSource)
  67. {
  68. selectedCard = cardSource;
  69. yield return null;
  70. }
  71. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.", "The opponent is selecting 1 digivolution card to play.");
  72. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  73. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  74. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  75. cardSources: new List<CardSource>() { selectedCard },
  76. activateClass: activateClass,
  77. payCost: false,
  78. isTapped: false,
  79. root: SelectCardEffect.Root.DigivolutionCards,
  80. activateETB: true)
  81. );
  82. }
  83. }
  84. #endregion
  85. #region All Turns - OPT
  86. if (timing == EffectTiming.WhenRemoveField)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Play 1 level 4 or lower Blue or [CS] digimon from sources", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass, true), 1, true, EffectDiscription());
  91. activateClass.SetHashString("BT23-023_AT");
  92. cardEffects.Add(activateClass);
  93. string EffectDiscription()
  94. {
  95. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, you may play 1 level 4 or lower blue or [CS] trait Digimon card from its digivolution cards without paying the cost.";
  96. }
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  100. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  105. }
  106. }
  107. #endregion
  108. #region ESS - All Turns - OPT
  109. if (timing == EffectTiming.WhenRemoveField)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("Play 1 level 4 or lower Blue or [CS] digimon from sources", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass, false), 1, true, EffectDiscription());
  114. activateClass.SetIsInheritedEffect(true);
  115. activateClass.SetHashString("BT23-023_ESS_AT");
  116. cardEffects.Add(activateClass);
  117. string EffectDiscription()
  118. {
  119. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area other than by your effects, you may play 1 level 4 or lower blue or [CS] trait Digimon card from its digivolution cards without paying the cost.";
  120. }
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnField(card)
  124. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, ThisPermamentCondition);
  125. }
  126. bool CanActivateCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.IsExistOnField(card);
  129. }
  130. bool ThisPermamentCondition(Permanent permanent)
  131. {
  132. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  133. && permanent.StackCards.Contains(card);
  134. }
  135. }
  136. #endregion
  137. return cardEffects;
  138. }
  139. }
  140. }