BT4_017.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 BT4_017 : 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. ChangeCardColorClass changeCardColorClass = new ChangeCardColorClass();
  16. changeCardColorClass.SetUpICardEffect($"Also treated as yellow", CanUseCondition, card);
  17. changeCardColorClass.SetUpChangeCardColorClass(ChangeCardColors: ChangeCardColors);
  18. cardEffects.Add(changeCardColorClass);
  19. bool CanUseCondition(Hashtable hashtable)
  20. {
  21. if (CardEffectCommons.IsExistOnBattleArea(card))
  22. {
  23. if (CardEffectCommons.IsOwnerTurn(card))
  24. {
  25. return true;
  26. }
  27. }
  28. return false;
  29. }
  30. List<CardColor> ChangeCardColors(CardSource cardSource, List<CardColor> CardColors)
  31. {
  32. if (cardSource == card)
  33. {
  34. CardColors.Add(CardColor.Yellow);
  35. }
  36. return CardColors;
  37. }
  38. }
  39. if (timing == EffectTiming.OnDeclaration)
  40. {
  41. ActivateClass activateClass = new ActivateClass();
  42. activateClass.SetUpICardEffect("Play 1 Tamer from hand", CanUseCondition, card);
  43. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  44. cardEffects.Add(activateClass);
  45. string EffectDiscription()
  46. {
  47. return "[Main] <Digi-Burst 2> (Trash 2 of this Digimon's digivolution cards to activate the effect below.) - You may play a red or yellow Tamer card with a play cost of 4 or less from your hand without paying its memory cost.";
  48. }
  49. bool CanSelectCardCondition(CardSource cardSource)
  50. {
  51. if (cardSource != null)
  52. {
  53. if (cardSource.IsTamer)
  54. {
  55. if (cardSource.Owner == card.Owner)
  56. {
  57. if (cardSource.HasCardColor(CardColor.Red) || cardSource.HasCardColor(CardColor.Yellow))
  58. {
  59. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  60. {
  61. if (cardSource.GetCostItself <= 4)
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. bool CanUseCondition(Hashtable hashtable)
  73. {
  74. if (CardEffectCommons.IsExistOnBattleArea(card))
  75. {
  76. if (new IDigiBurst(card.PermanentOfThisCard(), 2, activateClass).CanDigiBurst())
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  84. {
  85. if (isExistOnField(card))
  86. {
  87. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  88. {
  89. if (new IDigiBurst(card.PermanentOfThisCard(), 2, activateClass).CanDigiBurst())
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(new IDigiBurst(card.PermanentOfThisCard(), 2, activateClass).DigiBurst());
  92. if (card.Owner.HandCards.Count(CanSelectCardCondition) >= 1)
  93. {
  94. List<CardSource> selectedCards = new List<CardSource>();
  95. int maxCount = 1;
  96. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  97. selectHandEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: false,
  105. isShowOpponent: true,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. mode: SelectHandEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  111. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  112. yield return StartCoroutine(selectHandEffect.Activate());
  113. IEnumerator SelectCardCoroutine(CardSource cardSource)
  114. {
  115. selectedCards.Add(cardSource);
  116. yield return null;
  117. }
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Hand, activateETB: true));
  119. }
  120. }
  121. }
  122. }
  123. }
  124. }
  125. if (timing == EffectTiming.OnAllyAttack)
  126. {
  127. ActivateClass activateClass = new ActivateClass();
  128. activateClass.SetUpICardEffect("DP -2000", CanUseCondition, card);
  129. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  130. activateClass.SetIsInheritedEffect(true);
  131. cardEffects.Add(activateClass);
  132. string EffectDiscription()
  133. {
  134. return "[When Attacking] If you have a Tamer in play, 1 of your opponent's Digimon gets -2000 DP for the turn.";
  135. }
  136. bool CanSelectPermanentCondition(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  149. {
  150. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer))
  151. {
  152. return true;
  153. }
  154. }
  155. }
  156. return false;
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  159. {
  160. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  161. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: CanSelectPermanentCondition,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: maxCount,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: SelectPermanentCoroutine,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Custom,
  173. cardEffect: activateClass);
  174. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -2000.", "The opponent is selecting 1 Digimon that will get DP -2000.");
  175. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  176. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  177. {
  178. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -2000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  179. }
  180. }
  181. }
  182. return cardEffects;
  183. }
  184. }