BT24_060.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Hisyaryumon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_060 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.HasDigiPoliceTraits
  20. || targetPermanent.TopCard.HasSeekersTraits);
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region When Attacking
  26. if (timing == EffectTiming.OnAllyAttack)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Reveal the top 3 cards of deck, digivolve into 1", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[When Attacking] Reveal the top 3 cards of your deck. This Digimon may digivolve into a [DigiPolice] or [SEEKERS] trait Digimon card among them without paying the cost. Return the rest to the top or bottom of the deck.";
  35. }
  36. bool CanSelectCardCondition(CardSource cardSource)
  37. {
  38. return cardSource.IsDigimon
  39. && (cardSource.HasSeekersTraits
  40. || cardSource.HasDigiPoliceTraits)
  41. && cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass);
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.IsExistOnBattleArea(card)
  46. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleArea(card)
  51. && card.Owner.LibraryCards.Count >= 1;
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. CardSource selectedCard = null;
  56. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SimplifiedRevealDeckTopCardsAndSelect(
  57. revealCount: 3,
  58. simplifiedSelectCardConditions:
  59. new SimplifiedSelectCardConditionClass[]
  60. {
  61. new SimplifiedSelectCardConditionClass(
  62. canTargetCondition:CanSelectCardCondition,
  63. message: "Select 1 Digimon card to digivolve to.",
  64. mode: SelectCardEffect.Mode.Custom,
  65. maxCount: 1,
  66. selectCardCoroutine: SelectCardCoroutine),
  67. },
  68. remainingCardsPlace: RemainingCardsPlace.DeckTopOrBottom,
  69. activateClass: activateClass,
  70. canNoSelect: true
  71. ));
  72. IEnumerator SelectCardCoroutine(CardSource cardSource)
  73. {
  74. selectedCard = cardSource;
  75. yield return null;
  76. }
  77. if (selectedCard != null)
  78. {
  79. if (selectedCard.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(new PlayCardClass(
  82. cardSources: new List<CardSource>(){selectedCard},
  83. hashtable: CardEffectCommons.CardEffectHashtable(activateClass),
  84. payCost: false,
  85. targetPermanent: card.PermanentOfThisCard(),
  86. isTapped: false,
  87. root: SelectCardEffect.Root.Library,
  88. activateETB: true).PlayCard());
  89. }
  90. }
  91. }
  92. }
  93. #endregion
  94. #region All Turns
  95. if (timing == EffectTiming.OnAddDigivolutionCards)
  96. {
  97. ActivateClass activateClass = new ActivateClass();
  98. activateClass.SetUpICardEffect("Suspend 1 opp then this may attack digimon", CanUseCondition, card);
  99. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  100. cardEffects.Add(activateClass);
  101. string EffectDescription()
  102. {
  103. return "[All Turns] When Tamer cards are placed in this Digimon's digivolution cards, suspend 1 of your opponent's Digimon. Then, this Digimon may attack your opponent's Digimon.";
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  108. CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  109. hashtable: hashtable,
  110. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  111. cardEffectCondition: null,
  112. cardCondition: cardSource =>
  113. cardSource.IsTamer);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  118. }
  119. bool CanSelectPermamentCondition(Permanent permanant)
  120. {
  121. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanant, card);
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermamentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: false,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: null,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.Tap,
  138. cardEffect: activateClass);
  139. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend", "Opponent is selecting 1 digimon to suspend");
  140. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  141. if (card.PermanentOfThisCard().CanAttack(activateClass))
  142. {
  143. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  144. selectAttackEffect.SetUp(
  145. attacker: card.PermanentOfThisCard(),
  146. canAttackPlayerCondition: () => false,
  147. defenderCondition: _ => true,
  148. cardEffect: activateClass);
  149. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  150. }
  151. }
  152. }
  153. #endregion
  154. #region Inherited
  155. if (timing == EffectTiming.WhenRemoveField)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("By playing tamer, card doesn't leave", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  160. activateClass.SetHashString("BT24_060_ESS");
  161. activateClass.SetIsInheritedEffect(true);
  162. cardEffects.Add(activateClass);
  163. string EffectDiscription()
  164. {
  165. return "[All Turns] [Once Per Turn] When any of your [DigiPolice] or [SEEKERS] trait Digimon would leave the battle area, by playing 1 [DigiPolice] or [SEEKERS] trait Tamer card from this Digimon's digivolution cards without paying the cost, they don't leave.";
  166. }
  167. bool CanUseCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  170. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  171. }
  172. bool CanActivateCondition(Hashtable hashtable)
  173. {
  174. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  175. && card.PermanentOfThisCard().DigivolutionCards.Any(CanSelectCardCondition);
  176. }
  177. bool PermanentCondition(Permanent permanent)
  178. {
  179. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  180. && permanent.TopCard.IsDigimon
  181. && (permanent.TopCard.HasSeekersTraits
  182. || permanent.TopCard.HasDigiPoliceTraits);
  183. }
  184. bool CanSelectCardCondition(CardSource cardSource)
  185. {
  186. return cardSource.IsTamer
  187. && (cardSource.HasSeekersTraits
  188. || cardSource.HasDigiPoliceTraits)
  189. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  190. }
  191. IEnumerator ActivateCoroutine(Hashtable hashtable)
  192. {
  193. bool success = false;
  194. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  195. selectCardEffect.SetUp(
  196. canTargetCondition: CanSelectCardCondition,
  197. canTargetCondition_ByPreSelecetedList: null,
  198. canEndSelectCondition: null,
  199. canNoSelect: () => true,
  200. selectCardCoroutine: SelectCardCoroutine,
  201. afterSelectCardCoroutine: null,
  202. message: "Select 1 card to Play.",
  203. maxCount: 1,
  204. canEndNotMax: false,
  205. isShowOpponent: true,
  206. mode: SelectCardEffect.Mode.Custom,
  207. root: SelectCardEffect.Root.Custom,
  208. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  209. canLookReverseCard: false,
  210. selectPlayer: card.Owner,
  211. cardEffect: activateClass);
  212. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play");
  213. yield return StartCoroutine(selectCardEffect.Activate());
  214. IEnumerator SelectCardCoroutine(CardSource cardSource)
  215. {
  216. if (cardSource != null) {
  217. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  218. new List<CardSource>() { cardSource },
  219. activateClass: activateClass,
  220. payCost: false,
  221. isTapped: false,
  222. root: SelectCardEffect.Root.DigivolutionCards,
  223. activateETB: true));
  224. success = true;
  225. }
  226. }
  227. if(success)
  228. {
  229. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  230. .Filter(PermanentCondition);
  231. foreach (Permanent permanent in protectedPermanents)
  232. {
  233. permanent.willBeRemoveField = false;
  234. permanent.HideDeleteEffect();
  235. permanent.HideHandBounceEffect();
  236. permanent.HideDeckBounceEffect();
  237. permanent.HideWillRemoveFieldEffect();
  238. }
  239. }
  240. }
  241. }
  242. #endregion
  243. return cardEffects;
  244. }
  245. }
  246. }