BT25_017.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Flaremon
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_017 : 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 = "May attack, then by trashing 1 from hand, delete 1 enemy digimon with 7000 DP or less";
  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}] This Digimon may attack. Then, by trashing 1 card in your hand, delete 1 of your opponent's Digimon with 7000 DP or less.";
  35. }
  36. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  37. {
  38. bool CanSelectPermanentCondition(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  41. && permanent.HasDP
  42. && permanent.DP <= card.Owner.MaxDP_DeleteEffect(7000, activateClass);
  43. }
  44. if (card.PermanentOfThisCard().CanAttack(activateClass))
  45. {
  46. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  47. selectAttackEffect.SetUp(
  48. attacker: card.PermanentOfThisCard(),
  49. canAttackPlayerCondition: () => true,
  50. defenderCondition: _ => true,
  51. cardEffect: activateClass);
  52. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  53. }
  54. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  55. selectHandEffect.SetUp(
  56. selectPlayer: card.Owner,
  57. canTargetCondition: (cardSource) => true,
  58. canTargetCondition_ByPreSelecetedList: null,
  59. canEndSelectCondition: null,
  60. maxCount: 1,
  61. canNoSelect: true,
  62. canEndNotMax: false,
  63. isShowOpponent: true,
  64. selectCardCoroutine: null,
  65. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  66. mode: SelectHandEffect.Mode.Discard,
  67. cardEffect: activateClass);
  68. yield return StartCoroutine(selectHandEffect.Activate());
  69. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  70. {
  71. if (cardSources.Count >= 1 && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  72. {
  73. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  74. selectPermanentEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectPermanentCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: 1,
  80. canNoSelect: false,
  81. canEndNotMax: false,
  82. selectPermanentCoroutine: null,
  83. afterSelectPermanentCoroutine: null,
  84. mode: SelectPermanentEffect.Mode.Destroy,
  85. cardEffect: activateClass);
  86. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  87. }
  88. }
  89. }
  90. #endregion
  91. #region Your Turn
  92. if (timing == EffectTiming.OnEnterFieldAnyone)
  93. {
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect("Digivolve into [Apollomon] in hand for 2 less", CanUseCondition, card);
  96. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  97. activateClass.SetIsSkippable(true);
  98. cardEffects.Add(activateClass);
  99. string EffectDescription() => "[Your Turn] When your Digimon are played or digivolve, if any of them are blue, this Digimon may digivolve into [Apollomon] in the hand with the cost reduced by 2.";
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.IsExistOnBattleArea(card)
  103. && CardEffectCommons.IsOwnerTurn(card)
  104. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  105. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  106. }
  107. bool CanActivateCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.IsExistOnBattleArea(card)
  110. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  111. && HasValidColor(hashtable);
  112. }
  113. bool HasValidColor(Hashtable hashtable)
  114. {
  115. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  116. return hashtables.Map(CardEffectCommons.GetPermanentFromHashtable).Any(HasCorrectColorPermanent);
  117. }
  118. bool HasCorrectColorPermanent(Permanent permanent)
  119. {
  120. return PermanentCondition(permanent)
  121. && permanent.TopCard.CardColors.Contains(CardColor.Blue);
  122. }
  123. bool PermanentCondition(Permanent permanent)
  124. {
  125. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  126. }
  127. bool CanSelectCardCondition(CardSource cardSource)
  128. {
  129. return cardSource.EqualsCardName("Apollomon");
  130. }
  131. IEnumerator ActivateCoroutine(Hashtable hashtable)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  134. targetPermanent: card.PermanentOfThisCard(),
  135. cardCondition: CanSelectCardCondition,
  136. payCost: true,
  137. reduceCostTuple: (reduceCost: 2, reduceCostCardCondition: null),
  138. fixedCostTuple: null,
  139. ignoreDigivolutionRequirementFixedCost: -1,
  140. isHand: true,
  141. activateClass: activateClass,
  142. successProcess: null));
  143. }
  144. }
  145. #endregion
  146. #region Inherited Security A. +1
  147. if (timing == EffectTiming.None) cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  148. #endregion
  149. return cardEffects;
  150. }
  151. }
  152. }