BT25_045.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. // Onmon
  8. public class BT25_045 : 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.HasAppmonTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 2, permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Link Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. static bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. return targetPermanent.TopCard.HasAppmonTraits;
  29. }
  30. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 1, card: card));
  31. }
  32. #endregion
  33. #region Your Turn
  34. if (timing == EffectTiming.WhenWouldLink)
  35. {
  36. ActivateClass activateClass = new ();
  37. activateClass.SetUpICardEffect("May reduce Link cost by 1", CanUseCondition, card);
  38. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  39. activateClass.SetHashString("BT25_045_YT");
  40. cardEffects.Add(activateClass);
  41. string EffectDescription()
  42. {
  43. return "[Your Turn] [Once Per Turn] When a [Social], [Tool] or [Game] trait card would link to this Digimon, you may reduce the cost by 1.";
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleArea(card)
  48. && CardEffectCommons.IsOwnerTurn(card)
  49. && CardEffectCommons.CanTriggerWhenWouldLink(hashtable, CardCondition, PermanentCondition);
  50. }
  51. bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
  52. bool CardCondition(CardSource cardSource)
  53. {
  54. return cardSource.EqualsTraits("Social")
  55. || cardSource.EqualsTraits("Tool")
  56. || cardSource.EqualsTraits("Game");
  57. }
  58. bool RootCondition(SelectCardEffect.Root root) => true;
  59. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  60. IEnumerator ActivateCoroutine(Hashtable hashtable)
  61. {
  62. card.Owner.UntilCalculateFixedCostEffect.Add((timing) => CardEffectFactory.GrantedReduceLinkCostClass(
  63. card: card,
  64. reducedCost: 1,
  65. cardSourceCondition: CardCondition,
  66. permanentCondition: PermanentCondition,
  67. rootCondition: RootCondition
  68. ));
  69. yield return null;
  70. }
  71. }
  72. #endregion
  73. #region Link
  74. if (timing == EffectTiming.OnDeclaration)
  75. {
  76. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  77. }
  78. #endregion
  79. #region When Linking
  80. if (timing == EffectTiming.WhenLinked)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect("Suspend 1 enemy Digimon", CanUseCondition, card);
  84. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  85. activateClass.SetIsLinkedEffect(true);
  86. cardEffects.Add(activateClass);
  87. string EffectDescription()
  88. {
  89. return "[When Linking] Suspend 1 of your opponent's Digimon.";
  90. }
  91. bool CanSelectPermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  92. bool CanUseCondition(Hashtable hashtable)
  93. {
  94. return CardEffectCommons.CanTriggerWhenLinking(hashtable, null, card);
  95. }
  96. bool CanActivateCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  99. }
  100. IEnumerator ActivateCoroutine(Hashtable hashtable)
  101. {
  102. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  103. {
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: CanSelectPermanentCondition,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: 1,
  111. canNoSelect: false,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: null,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.Tap,
  116. cardEffect: activateClass);
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. }
  119. }
  120. }
  121. #endregion
  122. return cardEffects;
  123. }
  124. }
  125. }