BT25_026.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Crescemon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_026 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasTSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 4, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Shared OP/WD
  23. string SharedEffectName = "Trash 3 bottom sources of 1 enemy digimon, 1 enemy digimon with no sources can't suspend until end of their turn";
  24. CardEffectFactory.ActivateClassesForSharedEffects
  25. (ref cardEffects, timing, card,
  26. SharedEffectName,
  27. SharedActivateCoroutine,
  28. SharedEffectDescription,
  29. optional: false,
  30. onPlay: true,
  31. whenDigivolving: true);
  32. string SharedEffectDescription(string tag)
  33. {
  34. return $"[{tag}] Trash the bottom 3 digivolution cards of 1 of your opponent's Digimon. Then, 1 of their Digimon with no digivolution cards can't suspend until their turn ends.";
  35. }
  36. bool CanSelectPermanentCondition(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  39. }
  40. bool OpponentsDigimonWithoutSources(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  43. && permanent.DigivolutionCards.Count == 0;
  44. }
  45. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  46. {
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: 1,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to trash digivolution cards from.",
  61. "The opponent is selecting 1 Digimon to trash digivolution cards from.");
  62. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  63. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(
  66. CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(
  67. targetPermanent: permanent,
  68. trashCount: 3,
  69. isFromTop: false,
  70. activateClass: activateClass));
  71. }
  72. if (CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimonWithoutSources))
  73. {
  74. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  75. selectPermanentEffect1.SetUp(
  76. selectPlayer: card.Owner,
  77. canTargetCondition: OpponentsDigimonWithoutSources,
  78. canTargetCondition_ByPreSelecetedList: null,
  79. canEndSelectCondition: null,
  80. maxCount: 1,
  81. canNoSelect: false,
  82. canEndNotMax: false,
  83. selectPermanentCoroutine: null,
  84. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  85. mode: SelectPermanentEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectPermanentEffect1.SetUpCustomMessage("Select 1 Digimon to gain can't suspend until end of opponent's turn.", "The opponent is selecting 1 Digimon that will gain can't suspend until end of opponent's turn.");
  88. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  89. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotSuspendPlayerEffect(
  92. permanentCondition: (permanent) => permanent == permanents[0],
  93. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  94. activateClass: activateClass,
  95. isOnlyActivePhase: false,
  96. effectName: "Can't Suspend"
  97. ));
  98. }
  99. }
  100. }
  101. #endregion
  102. #region Your Turn
  103. if (timing == EffectTiming.OnEnterFieldAnyone)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Digivolve into [Dianamon] in trash for 2 less", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  108. activateClass.SetIsSkippable(true);
  109. cardEffects.Add(activateClass);
  110. string EffectDescription() => "[Your Turn] When your Digimon are played or digivolve, if any of them are red, this Digimon may digivolve into [Dianamon] in the trash with the cost reduced by 2.";
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.IsExistOnBattleArea(card)
  114. && CardEffectCommons.IsOwnerTurn(card)
  115. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  116. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  117. }
  118. bool CanActivateCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleArea(card)
  121. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition)
  122. && HasValidColor(hashtable);
  123. }
  124. bool HasValidColor(Hashtable hashtable)
  125. {
  126. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  127. return hashtables.Map(CardEffectCommons.GetPermanentFromHashtable).Any(HasCorrectColorPermanent);
  128. }
  129. bool HasCorrectColorPermanent(Permanent permanent)
  130. {
  131. return PermanentCondition(permanent)
  132. && permanent.TopCard.CardColors.Contains(CardColor.Red);
  133. }
  134. bool PermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  137. }
  138. bool CanSelectCardCondition(CardSource cardSource)
  139. {
  140. return cardSource.EqualsCardName("Dianamon");
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable hashtable)
  143. {
  144. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  145. targetPermanent: card.PermanentOfThisCard(),
  146. cardCondition: CanSelectCardCondition,
  147. payCost: true,
  148. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  149. fixedCostTuple: null,
  150. ignoreDigivolutionRequirementFixedCost: -1,
  151. isHand: false,
  152. activateClass: activateClass,
  153. successProcess: null));
  154. }
  155. }
  156. #endregion
  157. #region Inherited
  158. if (timing == EffectTiming.None)
  159. {
  160. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  161. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be changed.", CanUseCondition, card);
  162. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  163. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  164. cardEffects.Add(canNotSwitchAttackTargetClass);
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  168. CardEffectCommons.IsOwnerTurn(card);
  169. }
  170. bool PermanentCondition(Permanent permanent)
  171. {
  172. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  173. }
  174. }
  175. #endregion
  176. return cardEffects;
  177. }
  178. }
  179. }