BT3_039.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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_039 : 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("Security Attack -2", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[When Digivolving] 1 of your opponent's Digimon gains <Security Attack -2> (This Digimon checks 2 fewer security cards) until the end of your opponent's next turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleArea(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: maxCount,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get Security Attack -2.", "The opponent is selecting 1 Digimon that will get Security Attack -2.");
  61. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  62. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  63. {
  64. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: permanent, changeValue: -2, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  65. }
  66. }
  67. }
  68. }
  69. if (timing == EffectTiming.OnAllyAttack)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Play 1 Digimon from hand", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  74. activateClass.SetIsInheritedEffect(true);
  75. cardEffects.Add(activateClass);
  76. string EffectDiscription()
  77. {
  78. return "[When Attacking] If you have 3 or fewer security cards, you may play 1 yellow level 3 Digimon card from your hand without paying its memory cost.";
  79. }
  80. bool CanSelectCardCondition(CardSource cardSource)
  81. {
  82. if (cardSource.IsDigimon)
  83. {
  84. if (cardSource.HasCardColor(CardColor.Yellow))
  85. {
  86. if (cardSource.Level == 3)
  87. {
  88. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  89. {
  90. if (cardSource.HasLevel)
  91. {
  92. return true;
  93. }
  94. }
  95. }
  96. }
  97. }
  98. return false;
  99. }
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  103. }
  104. bool CanActivateCondition(Hashtable hashtable)
  105. {
  106. if (CardEffectCommons.IsExistOnBattleArea(card))
  107. {
  108. if (card.Owner.HandCards.Count >= 1)
  109. {
  110. if (card.Owner.SecurityCards.Count <= 3)
  111. {
  112. return true;
  113. }
  114. }
  115. }
  116. return false;
  117. }
  118. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  119. {
  120. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  121. {
  122. List<CardSource> selectedCards = new List<CardSource>();
  123. int maxCount = 1;
  124. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  125. selectHandEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectCardCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: maxCount,
  131. canNoSelect: true,
  132. canEndNotMax: false,
  133. isShowOpponent: true,
  134. selectCardCoroutine: SelectCardCoroutine,
  135. afterSelectCardCoroutine: null,
  136. mode: SelectHandEffect.Mode.Custom,
  137. cardEffect: activateClass);
  138. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  139. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  140. yield return StartCoroutine(selectHandEffect.Activate());
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. selectedCards.Add(cardSource);
  144. yield return null;
  145. }
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  147. cardSources: selectedCards,
  148. activateClass: activateClass,
  149. payCost: false,
  150. isTapped: false,
  151. root: SelectCardEffect.Root.Hand,
  152. activateETB: true));
  153. }
  154. }
  155. }
  156. return cardEffects;
  157. }
  158. }