ST13_02.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 ST13_02 : 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("Place this Digimon under your Digimon's digivolution cards to reveal deck top", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[On Play] By placing this Digimon under 1 of your other Digimon that's black or has [Legend-Arms] in its traits as its bottom digivolution card, reveal the top card of your deck. If that card is a Digimon card with [Legend-Arms] in its traits and a play cost of 7 or less, you may play it without paying its memory cost. Add the rest to your hand.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  26. {
  27. if (permanent != card.PermanentOfThisCard())
  28. {
  29. if (!permanent.IsToken)
  30. {
  31. if (permanent.TopCard.CardTraits.Contains("Legend-Arms"))
  32. {
  33. return true;
  34. }
  35. if (permanent.TopCard.CardColors.Contains(CardColor.Black))
  36. {
  37. return true;
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
  44. bool CanSelectCardCondition(CardSource cardSource)
  45. {
  46. if (cardSource.IsDigimon)
  47. {
  48. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  49. {
  50. if (cardSource.GetCostItself <= 7 && cardSource.HasPlayCost)
  51. {
  52. if (cardSource.CardTraits.Contains("Legend-Arms"))
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. bool CanUseCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  64. }
  65. bool CanActivateCondition(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.IsExistOnBattleArea(card))
  68. {
  69. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  70. {
  71. return true;
  72. }
  73. }
  74. return false;
  75. }
  76. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  77. {
  78. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. bool added = false;
  81. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: CanSelectPermanentCondition,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: maxCount,
  89. canNoSelect: true,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: SelectPermanentCoroutine,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Custom,
  94. cardEffect: activateClass);
  95. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  96. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  97. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  98. {
  99. Permanent selectedPermanent = permanent;
  100. if (selectedPermanent != null)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(new IPlacePermanentToDigivolutionCards(new List<Permanent[]>() { new Permanent[] { card.PermanentOfThisCard(), selectedPermanent } }, false, activateClass).PlacePermanentToDigivolutionCards());
  103. if (CardEffectCommons.IsExistOnBattleArea(card))
  104. {
  105. if (selectedPermanent.DigivolutionCards.Contains(card))
  106. {
  107. added = true;
  108. }
  109. }
  110. }
  111. }
  112. if (added)
  113. {
  114. yield return new WaitForSeconds(0.1f);
  115. List<CardSource> selectedCards = new List<CardSource>();
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  117. revealCount: 1,
  118. simplifiedSelectCardConditions:
  119. new SimplifiedSelectCardConditionClass[]
  120. {
  121. new SimplifiedSelectCardConditionClass(
  122. canTargetCondition:CanSelectCardCondition,
  123. message: "Select 1 Digimon card with [Legend-Arms] in its traits and a play cost of 7 or less to play.",
  124. mode: SelectCardEffect.Mode.Custom,
  125. maxCount: 1,
  126. selectCardCoroutine: SelectCardCoroutine),
  127. },
  128. remainingCardsPlace: RemainingCardsPlace.AddHand,
  129. activateClass: activateClass,
  130. canNoSelect: true
  131. ));
  132. IEnumerator SelectCardCoroutine(CardSource cardSource)
  133. {
  134. selectedCards.Add(cardSource);
  135. yield return null;
  136. }
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  138. cardSources: selectedCards,
  139. activateClass: activateClass,
  140. payCost: false,
  141. isTapped: false,
  142. root: SelectCardEffect.Root.Library,
  143. activateETB: true));
  144. }
  145. }
  146. }
  147. }
  148. if (timing == EffectTiming.OnAllyAttack)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("Delete 1 Digimon with 3000 DP or less", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  153. activateClass.SetIsInheritedEffect(true);
  154. cardEffects.Add(activateClass);
  155. string EffectDiscription()
  156. {
  157. return "[When Attacking] If you have a Digimon that's black or has [Legend-Arms] in its traits in play, delete 1 of your opponent's Digimon with 3000 DP or less.";
  158. }
  159. bool CanSelectPermanentCondition(Permanent permanent)
  160. {
  161. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  162. {
  163. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(3000, activateClass))
  164. {
  165. return true;
  166. }
  167. }
  168. return false;
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  173. }
  174. bool CanActivateCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleArea(card))
  177. {
  178. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  179. {
  180. if (card.Owner.GetBattleAreaDigimons().Count(permanent => permanent.TopCard.CardTraits.Contains("Legend-Arms") || permanent.TopCard.CardColors.Contains(CardColor.Black)) >= 1)
  181. {
  182. return true;
  183. }
  184. }
  185. }
  186. return false;
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  191. {
  192. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  193. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  194. selectPermanentEffect.SetUp(
  195. selectPlayer: card.Owner,
  196. canTargetCondition: CanSelectPermanentCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. maxCount: maxCount,
  200. canNoSelect: false,
  201. canEndNotMax: false,
  202. selectPermanentCoroutine: null,
  203. afterSelectPermanentCoroutine: null,
  204. mode: SelectPermanentEffect.Mode.Destroy,
  205. cardEffect: activateClass);
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. }
  208. }
  209. }
  210. return cardEffects;
  211. }
  212. }