BT8_036.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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 BT8_036 : 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($"Play Cost -1", 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. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardColors.Contains(CardColor.Blue)))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  31. {
  32. if (CardSourceCondition(cardSource))
  33. {
  34. if (RootCondition(root))
  35. {
  36. if (PermanentsCondition(targetPermanents))
  37. {
  38. Cost -= 1;
  39. }
  40. }
  41. }
  42. return Cost;
  43. }
  44. bool PermanentsCondition(List<Permanent> targetPermanents)
  45. {
  46. if (targetPermanents == null)
  47. {
  48. return true;
  49. }
  50. else
  51. {
  52. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. bool CardSourceCondition(CardSource cardSource)
  60. {
  61. return cardSource == card;
  62. }
  63. bool RootCondition(SelectCardEffect.Root root)
  64. {
  65. if (root == SelectCardEffect.Root.Hand)
  66. {
  67. return true;
  68. }
  69. return false;
  70. }
  71. bool isUpDown()
  72. {
  73. return true;
  74. }
  75. }
  76. if (timing == EffectTiming.OnAllyAttack)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("DP -3000", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  81. activateClass.SetIsInheritedEffect(true);
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[When Attacking] If you have a blue Digimon in play, 1 of your opponent's Digimon gets -3000 DP for the turn.";
  86. }
  87. bool CanSelectPermanentCondition(Permanent permanent)
  88. {
  89. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. if (CardEffectCommons.IsExistOnBattleArea(card))
  98. {
  99. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  100. {
  101. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardColors.Contains(CardColor.Blue)))
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  110. {
  111. if (isExistOnField(card))
  112. {
  113. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  114. {
  115. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  116. {
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: CanSelectPermanentCondition,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: SelectPermanentCoroutine,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -3000.", "The opponent is selecting 1 Digimon that will get DP -3000.");
  132. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  133. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  136. }
  137. }
  138. }
  139. }
  140. }
  141. }
  142. return cardEffects;
  143. }
  144. }