P_202.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Tyrannomon
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_202 : 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.HasDMTraits;
  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 Training
  29. if (timing == EffectTiming.OnDeclaration)
  30. {
  31. cardEffects.Add(CardEffectFactory.TrainingEffect(card));
  32. }
  33. #endregion
  34. #region Your Turn - OPT
  35. if (timing == EffectTiming.BeforePayCost)
  36. {
  37. ActivateClass activateClass = new ActivateClass();
  38. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  39. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  40. activateClass.SetHashString("P_202_YT");
  41. cardEffects.Add(activateClass);
  42. string EffectDiscription()
  43. {
  44. return "[Your Turn] [Once Per Turn] When any of your suspended Digimon would digivolve into a Digimon card with [Tyrannomon] in its name or the [Dinosaur] or [Ver.1] trait, reduce the digivolution cost by 1.";
  45. }
  46. bool CanUseCondition(Hashtable hashtable)
  47. {
  48. if (CardEffectCommons.IsExistOnBattleArea(card))
  49. {
  50. if (CardEffectCommons.IsOwnerTurn(card))
  51. {
  52. if (CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanActivateCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleArea(card);
  63. }
  64. bool PermanentCondition(Permanent permanent)
  65. {
  66. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  67. && permanent.IsSuspended;
  68. }
  69. bool CardCondition(CardSource cardSource)
  70. {
  71. return cardSource.IsDigimon &&
  72. cardSource.ContainsCardName("Tyrannomon") || cardSource.EqualsTraits("Dinosaur") || cardSource.HasVer1Traits;
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  75. {
  76. #region Reduce Cost Setup
  77. bool CanUseCondition1(Hashtable hashtable)
  78. {
  79. return true;
  80. }
  81. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  82. {
  83. if (CardCondition(cardSource))
  84. {
  85. if (RootCondition(root))
  86. {
  87. if (PermanentsCondition(targetPermanents))
  88. {
  89. Cost -= 1;
  90. }
  91. }
  92. }
  93. return Cost;
  94. }
  95. bool PermanentsCondition(List<Permanent> targetPermanents)
  96. {
  97. if (targetPermanents != null)
  98. {
  99. if (targetPermanents.Count(PermanentCondition) >= 1)
  100. {
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. bool RootCondition(SelectCardEffect.Root root)
  107. {
  108. return true;
  109. }
  110. bool isUpDown()
  111. {
  112. return true;
  113. }
  114. #endregion
  115. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  116. ChangeCostClass changeCostClass = new ChangeCostClass();
  117. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  118. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  119. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  120. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  121. }
  122. }
  123. #endregion
  124. #region Piercing - ESS
  125. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  126. {
  127. cardEffects.Add(CardEffectFactory.PierceSelfEffect(
  128. isInheritedEffect: true,
  129. card: card,
  130. condition: null)
  131. );
  132. }
  133. #endregion
  134. return cardEffects;
  135. }
  136. }
  137. }