BT12_039.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT12
  6. {
  7. public class BT12_039 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasSaveText && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.None)
  21. {
  22. ChangeCostClass changeCostClass = new ChangeCostClass();
  23. changeCostClass.SetUpICardEffect($"Play Cost -3", CanUseCondition, card);
  24. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  25. cardEffects.Add(changeCostClass);
  26. bool CanUseCondition(Hashtable hashtable)
  27. {
  28. if (card.Owner.HandCards.Contains(card))
  29. {
  30. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, (permanent) => permanent.IsDigimon && permanent.HasSecurityAttackChanges))
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  38. {
  39. if (CardSourceCondition(cardSource))
  40. {
  41. if (RootCondition(root))
  42. {
  43. if (PermanentsCondition(targetPermanents))
  44. {
  45. Cost -= 3;
  46. }
  47. }
  48. }
  49. return Cost;
  50. }
  51. bool PermanentsCondition(List<Permanent> targetPermanents)
  52. {
  53. if (targetPermanents == null)
  54. {
  55. return true;
  56. }
  57. else
  58. {
  59. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CardSourceCondition(CardSource cardSource)
  67. {
  68. return cardSource == card;
  69. }
  70. bool RootCondition(SelectCardEffect.Root root)
  71. {
  72. if (root == SelectCardEffect.Root.Hand)
  73. {
  74. return true;
  75. }
  76. return false;
  77. }
  78. bool isUpDown()
  79. {
  80. return true;
  81. }
  82. }
  83. if (timing == EffectTiming.OnAllyAttack)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect("Security Attack -1", CanUseCondition, card);
  87. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  88. activateClass.SetIsInheritedEffect(true);
  89. activateClass.SetHashString("SecurityAttack-1_BT12_039");
  90. cardEffects.Add(activateClass);
  91. string EffectDiscription()
  92. {
  93. return "[When Attacking][Once Per Turn] 1 of your opponent's Digimon gains <Security Attack -1> until the end of your opponent's turn. (This Digimon checks 1 fewer security cards.)";
  94. }
  95. bool CanSelectPermanentCondition(Permanent permanent)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  98. }
  99. bool CanUseCondition(Hashtable hashtable)
  100. {
  101. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  102. }
  103. bool CanActivateCondition(Hashtable hashtable)
  104. {
  105. if (CardEffectCommons.IsExistOnBattleArea(card))
  106. {
  107. return true;
  108. }
  109. return false;
  110. }
  111. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  112. {
  113. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  114. {
  115. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  116. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  117. selectPermanentEffect.SetUp(
  118. selectPlayer: card.Owner,
  119. canTargetCondition: CanSelectPermanentCondition,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. maxCount: maxCount,
  123. canNoSelect: false,
  124. canEndNotMax: false,
  125. selectPermanentCoroutine: SelectPermanentCoroutine,
  126. afterSelectPermanentCoroutine: null,
  127. mode: SelectPermanentEffect.Mode.Custom,
  128. cardEffect: activateClass);
  129. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -1.", "The opponent is selecting 1 Digimon that will get Security Attack -1.");
  130. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  131. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  132. {
  133. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -1, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  134. }
  135. }
  136. }
  137. }
  138. return cardEffects;
  139. }
  140. }
  141. }