BT7_040.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. public class BT7_040 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. if (timing == EffectTiming.None)
  14. {
  15. ChangeCostClass changeCostClass = new ChangeCostClass();
  16. changeCostClass.SetUpICardEffect($"Digivolution Cost is", CanUseCondition, card);
  17. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  18. cardEffects.Add(changeCostClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (card.Owner.HandCards.Contains(card))
  22. {
  23. changeCostClass.SetEffectName($"Digivolution Cost is {card.Owner.SecurityCards.Count}");
  24. return true;
  25. }
  26. return false;
  27. }
  28. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  29. {
  30. if (CardSourceCondition(cardSource))
  31. {
  32. if (RootCondition(root))
  33. {
  34. if (PermanentsCondition(targetPermanents))
  35. {
  36. int count = card.Owner.SecurityCards.Count;
  37. if (count <= 0)
  38. {
  39. count = 1;
  40. }
  41. Cost = count;
  42. }
  43. }
  44. }
  45. return Cost;
  46. }
  47. bool PermanentsCondition(List<Permanent> targetPermanents)
  48. {
  49. if (targetPermanents != null)
  50. {
  51. if (targetPermanents.Count(PermanentCondition) >= 1)
  52. {
  53. return true;
  54. }
  55. }
  56. return false;
  57. }
  58. bool PermanentCondition(Permanent targetPermanent)
  59. {
  60. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  61. }
  62. bool CardSourceCondition(CardSource cardSource)
  63. {
  64. if (cardSource.Owner.HandCards.Contains(cardSource))
  65. {
  66. if (cardSource == card)
  67. {
  68. return true;
  69. }
  70. }
  71. return false;
  72. }
  73. bool RootCondition(SelectCardEffect.Root root)
  74. {
  75. return root == SelectCardEffect.Root.Hand;
  76. }
  77. bool isUpDown()
  78. {
  79. return false;
  80. }
  81. }
  82. if (timing == EffectTiming.OnDeclaration)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect("Reduce opponent's Digimon DP", CanUseCondition, card);
  86. activateClass.SetUpActivateClass(null, ActivateCoroutine, 1, false, EffectDiscription());
  87. activateClass.SetHashString("DP-_BT7_040");
  88. cardEffects.Add(activateClass);
  89. string EffectDiscription()
  90. {
  91. return "[Main] <Digi-Burst 2> (Trash 2 of this Digimon's digivolution cards to activate the effect below.) - 1 of your opponent's Digimon gains <Security Attack -2> until the end of your opponent's next turn. (This Digimon checks 2 fewer security cards)";
  92. }
  93. bool CanSelectPermanentCondition(Permanent permanent)
  94. {
  95. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  96. }
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. if (isExistOnField(card))
  100. {
  101. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  102. {
  103. IDigiBurst digiBurst = new IDigiBurst(card.PermanentOfThisCard(), 4, activateClass);
  104. digiBurst.SetUpToMaxCount();
  105. if (digiBurst.CanDigiBurst())
  106. {
  107. return true;
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. if (isExistOnField(card))
  116. {
  117. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  118. {
  119. IDigiBurst digiBurst = new IDigiBurst(card.PermanentOfThisCard(), 4, activateClass);
  120. digiBurst.SetUpToMaxCount();
  121. if (digiBurst.CanDigiBurst())
  122. {
  123. yield return ContinuousController.instance.StartCoroutine(digiBurst.DigiBurst());
  124. int minusDP = 3000 * digiBurst.discardedCards.Count;
  125. if (minusDP >= 1)
  126. {
  127. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  128. {
  129. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: CanSelectPermanentCondition,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: maxCount,
  137. canNoSelect: false,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: SelectPermanentCoroutine,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Custom,
  142. cardEffect: activateClass);
  143. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{minusDP}.", $"The opponent is selecting 1 Digimon that will get DP -{minusDP}.");
  144. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  145. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -minusDP, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. }
  155. }
  156. return cardEffects;
  157. }
  158. }