AD1_006.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Shoutmon X7
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_006 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolve Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Blue Flare")
  19. || targetPermanent.TopCard.EqualsTraits("Xros Heart");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 6, permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP / WD / WA
  25. string SharedHashString = "AD1_006_OP_WD_WA";
  26. string SharedEffectName = "May bottom deck an opponent's Digimon with same or less DP as this. May unsuspend";
  27. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may return 1 of your opponent's Digimon with as much or less DP as this Digimon to the bottom of the deck. Then, this Digimon may unsuspend.";
  28. bool SharedCanActivateCondition(Hashtable hashtable)
  29. {
  30. return CardEffectCommons.IsExistOnBattleArea(card)
  31. && (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon)
  32. || card.PermanentOfThisCard().IsSuspended);
  33. }
  34. bool IsWeakerEnemyDigimon(Permanent permanent)
  35. {
  36. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  37. && permanent.HasDP
  38. && permanent.DP <= card.PermanentOfThisCard().DP;
  39. }
  40. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  41. {
  42. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon))
  43. {
  44. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  45. selectPermanentEffect.SetUp(
  46. selectPlayer: card.Owner,
  47. canTargetCondition: IsWeakerEnemyDigimon,
  48. canTargetCondition_ByPreSelecetedList: null,
  49. canEndSelectCondition: null,
  50. maxCount: 1,
  51. canNoSelect: true,
  52. canEndNotMax: false,
  53. selectPermanentCoroutine: null,
  54. afterSelectPermanentCoroutine: null,
  55. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  56. cardEffect: activateClass);
  57. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  58. }
  59. Permanent permanent = card.PermanentOfThisCard();
  60. if (permanent.IsSuspended && permanent.CanUnsuspend)
  61. {
  62. string selectPlayerMessage = "Will you unsuspend this card?";
  63. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  64. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  65. {
  66. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  67. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  68. };
  69. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  70. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  71. bool unsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  72. if (unsuspend)
  73. {
  74. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  75. new List<Permanent>() { permanent },
  76. activateClass).Unsuspend());
  77. }
  78. }
  79. }
  80. #endregion
  81. #region On Play
  82. if (timing == EffectTiming.OnEnterFieldAnyone)
  83. {
  84. ActivateClass activateClass = new ActivateClass();
  85. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  86. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  87. activateClass.SetHashString(SharedHashString);
  88. cardEffects.Add(activateClass);
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleArea(card)
  92. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  93. }
  94. }
  95. #endregion
  96. #region When Digivolving
  97. if (timing == EffectTiming.OnEnterFieldAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  101. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  102. activateClass.SetHashString(SharedHashString);
  103. cardEffects.Add(activateClass);
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleArea(card)
  107. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  108. }
  109. }
  110. #endregion
  111. #region When Attacking
  112. if (timing == EffectTiming.OnAllyAttack)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  117. activateClass.SetHashString(SharedHashString);
  118. cardEffects.Add(activateClass);
  119. bool CanUseCondition(Hashtable hashtable)
  120. {
  121. return CardEffectCommons.IsExistOnBattleArea(card)
  122. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  123. }
  124. }
  125. #endregion
  126. #region All Turns
  127. if (timing == EffectTiming.WhenRemoveField)
  128. {
  129. ActivateClass activateClass = new ActivateClass();
  130. activateClass.SetUpICardEffect("Place up to 4 [Xros Heart] or [Blue Flare] Digimon from this Digimon's digivolution cards under a tamer, then play 1 more for free", CanUseCondition, card);
  131. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  132. cardEffects.Add(activateClass);
  133. string EffectDescription()
  134. => "[All Turns] When this Digimon would leave the battle area other than by DigiXros, from this Digimon's digivolution cards, you may place up to 4 [Xros Heart] or [Blue Flare] trait Digimon cards under 1 of your Tamers and play 1 such card without paying the cost.";
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleArea(card)
  138. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  139. && !CardEffectCommons.IsLeavingForDigiXros(hashtable);
  140. }
  141. bool IsXrosHeartOrBlueFlare(CardSource cardSource)
  142. {
  143. return cardSource.IsDigimon
  144. && (cardSource.EqualsTraits("Blue Flare") || cardSource.EqualsTraits("Xros Heart"));
  145. }
  146. bool CanPlayXrosHeartOrBlueFlare(CardSource cardSource)
  147. {
  148. return IsXrosHeartOrBlueFlare(cardSource)
  149. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  150. }
  151. bool CanSelectSaveTamerPermanentCondition(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  154. && permanent.IsTamer;
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  159. && card.PermanentOfThisCard().DigivolutionCards.Some(IsXrosHeartOrBlueFlare);
  160. }
  161. IEnumerator ActivateCoroutine(Hashtable hashtable)
  162. {
  163. bool placedCards = false;
  164. #region Place up to 4 cards under a tamer
  165. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectSaveTamerPermanentCondition))
  166. {
  167. List<CardSource> selectedCards = new List<CardSource>();
  168. int maxCount = Math.Min(4, card.PermanentOfThisCard().DigivolutionCards.Count(IsXrosHeartOrBlueFlare));
  169. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  170. selectCardEffect.SetUp(
  171. canTargetCondition: IsXrosHeartOrBlueFlare,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. canNoSelect: () => true,
  175. selectCardCoroutine: SelectCardCoroutine,
  176. afterSelectCardCoroutine: null,
  177. message: "Select digivolution cards to place under 1 of your Tamers.",
  178. maxCount: maxCount,
  179. canEndNotMax: true,
  180. isShowOpponent: true,
  181. mode: SelectCardEffect.Mode.Custom,
  182. root: SelectCardEffect.Root.DigivolutionCards,
  183. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  184. canLookReverseCard: true,
  185. selectPlayer: card.Owner,
  186. cardEffect: activateClass);
  187. selectCardEffect.SetUpCustomMessage(
  188. "Select digivolution cards to place under 1 of your Tamers.",
  189. "The opponent is selecting digivolution cards to place under 1 of your Tamers.");
  190. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  191. yield return StartCoroutine(selectCardEffect.Activate());
  192. IEnumerator SelectCardCoroutine(CardSource cardSource)
  193. {
  194. selectedCards.Add(cardSource);
  195. yield return null;
  196. }
  197. Permanent selectedPermanent = null;
  198. if (selectedCards.Count > 0)
  199. {
  200. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: CanSelectSaveTamerPermanentCondition,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: 1,
  207. canNoSelect: true,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: SelectPermanentCoroutine,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Custom,
  212. cardEffect: activateClass);
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to place the chosen cards under.",
  214. "The opponent is selecting 1 Tamer to place the chosen cards under.");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  217. {
  218. selectedPermanent = permanent;
  219. yield return null;
  220. }
  221. if (selectedPermanent != null)
  222. {
  223. placedCards = true;
  224. yield return ContinuousController.instance.StartCoroutine(
  225. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  226. }
  227. }
  228. }
  229. #endregion
  230. #region Play 1 card
  231. if ((placedCards || !CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectSaveTamerPermanentCondition))
  232. && card.PermanentOfThisCard().DigivolutionCards.Some(CanPlayXrosHeartOrBlueFlare))
  233. {
  234. List<CardSource> selectedCards = new List<CardSource>();
  235. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  236. selectCardEffect.SetUp(
  237. canTargetCondition: CanPlayXrosHeartOrBlueFlare,
  238. canTargetCondition_ByPreSelecetedList: null,
  239. canEndSelectCondition: null,
  240. canNoSelect: () => !placedCards,
  241. selectCardCoroutine: SelectCardCoroutine,
  242. afterSelectCardCoroutine: null,
  243. message: "Select 1 digivolution card to play.",
  244. maxCount: 1,
  245. canEndNotMax: false,
  246. isShowOpponent: true,
  247. mode: SelectCardEffect.Mode.Custom,
  248. root: SelectCardEffect.Root.DigivolutionCards,
  249. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  250. canLookReverseCard: true,
  251. selectPlayer: card.Owner,
  252. cardEffect: activateClass);
  253. selectCardEffect.SetUpCustomMessage(
  254. "Select 1 digivolution card to play.",
  255. "The opponent is selecting 1 digivolution card to play.");
  256. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  257. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  258. IEnumerator SelectCardCoroutine(CardSource cardSource)
  259. {
  260. selectedCards.Add(cardSource);
  261. yield return null;
  262. }
  263. if (selectedCards.Count > 0) yield return ContinuousController.instance.StartCoroutine(
  264. CardEffectCommons.PlayPermanentCards(
  265. cardSources: selectedCards,
  266. activateClass: activateClass,
  267. payCost: false,
  268. isTapped: false,
  269. root: SelectCardEffect.Root.DigivolutionCards,
  270. activateETB: true));
  271. }
  272. #endregion
  273. }
  274. }
  275. #endregion
  276. #region Digixros
  277. if (timing == EffectTiming.None)
  278. {
  279. cardEffects.Add(CardEffectFactory.DigiXrosEffectFromNames(card, 2, null,
  280. "OmniShoutmon",
  281. "ZeigGreymon",
  282. "Ballistamon",
  283. "Dorulumon",
  284. "Starmons",
  285. "Sparrowmon"));
  286. }
  287. #endregion
  288. return cardEffects;
  289. }
  290. }
  291. }