BT3_014.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 BT3_014 : 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.OnEnterFieldAnyone)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Change original DP to 1000", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] Change the original DP of 1 of your opponent's level 4 or lower Digimon to 1000 for the turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent.Level <= 4)
  28. {
  29. if (permanent.TopCard.HasLevel)
  30. {
  31. return true;
  32. }
  33. }
  34. }
  35. return false;
  36. }
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. if (CardEffectCommons.IsExistOnBattleArea(card))
  44. {
  45. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  46. {
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  53. {
  54. if (isExistOnField(card))
  55. {
  56. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: null,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to change original DP.", "The opponent is selecting 1 Digimon to change original DP.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  77. {
  78. Permanent selectedPermanent = permanent;
  79. if (selectedPermanent != null)
  80. {
  81. ChangeBaseDPClass changeDPClass = new ChangeBaseDPClass();
  82. changeDPClass.SetUpICardEffect("Origin DP is 1000", CanUseCondition1, card);
  83. changeDPClass.SetUpChangeBaseDPClass(changeDPFunc: ChangeDP, permanentCondition: permanentCondition, isUpDownFunc: _isUpDown, isMinusDPFunc: () => false);
  84. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => changeDPClass);
  85. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  86. {
  87. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  88. }
  89. bool CanUseCondition1(Hashtable hashtable)
  90. {
  91. if (selectedPermanent.TopCard != null)
  92. {
  93. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  94. {
  95. return true;
  96. }
  97. }
  98. return false;
  99. }
  100. int ChangeDP(Permanent permanent, int DP)
  101. {
  102. if (permanentCondition(permanent))
  103. {
  104. DP = 1000;
  105. }
  106. return DP;
  107. }
  108. bool permanentCondition(Permanent permanent)
  109. {
  110. if (permanent != null)
  111. {
  112. if (permanent.TopCard != null)
  113. {
  114. if (permanent == selectedPermanent)
  115. {
  116. return true;
  117. }
  118. }
  119. }
  120. return false;
  121. }
  122. bool _isUpDown()
  123. {
  124. return false;
  125. }
  126. }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. if (timing == EffectTiming.None)
  134. {
  135. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  136. changeCardColorClass.SetUpICardEffect($"Also treated as yellow", CanUseCondition, card);
  137. changeCardColorClass.SetUpChangeCardColorClass(ChangeCardColors: ChangeCardColors);
  138. cardEffects.Add(changeCardColorClass);
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. if (CardEffectCommons.IsExistOnBattleArea(card))
  142. {
  143. if (CardEffectCommons.IsOwnerTurn(card))
  144. {
  145. return true;
  146. }
  147. }
  148. return false;
  149. }
  150. List<CardColor> ChangeCardColors(CardSource cardSource, List<CardColor> CardColors)
  151. {
  152. if (cardSource == card)
  153. {
  154. CardColors.Add(CardColor.Yellow);
  155. }
  156. return CardColors;
  157. }
  158. }
  159. return cardEffects;
  160. }
  161. }