BT8_010.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_010 : 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.Yellow)))
  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("Delete 1 Digimon with 5000 DP or less", 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 yellow Digimon in play, delete 1 of your opponent's Digimon with 5000 DP or less.";
  86. }
  87. bool CanSelectPermanentCondition(Permanent permanent)
  88. {
  89. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  90. {
  91. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(5000, activateClass))
  92. {
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  107. {
  108. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent.TopCard.CardColors.Contains(CardColor.Yellow)))
  109. {
  110. return true;
  111. }
  112. }
  113. }
  114. return false;
  115. }
  116. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  117. {
  118. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  119. {
  120. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  121. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  122. selectPermanentEffect.SetUp(
  123. selectPlayer: card.Owner,
  124. canTargetCondition: CanSelectPermanentCondition,
  125. canTargetCondition_ByPreSelecetedList: null,
  126. canEndSelectCondition: null,
  127. maxCount: maxCount,
  128. canNoSelect: false,
  129. canEndNotMax: false,
  130. selectPermanentCoroutine: null,
  131. afterSelectPermanentCoroutine: null,
  132. mode: SelectPermanentEffect.Mode.Destroy,
  133. cardEffect: activateClass);
  134. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  135. }
  136. }
  137. }
  138. return cardEffects;
  139. }
  140. }