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.IsLevel6
  19. && (targetPermanent.TopCard.EqualsTraits("Blue Flare")
  20. || targetPermanent.TopCard.EqualsTraits("Xros Heart"));
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  23. }
  24. #endregion
  25. #region Shared OP / WD / WA
  26. string SharedHashString = "AD1_006_OP_WD_WA";
  27. string SharedEffectName = "May bottom deck an opponent's Digimon with same or less DP as this. May unsuspend";
  28. 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.";
  29. bool SharedCanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleArea(card)
  32. && (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon)
  33. || card.PermanentOfThisCard().IsSuspended);
  34. }
  35. bool IsWeakerEnemyDigimon(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  38. && permanent.HasDP
  39. && permanent.DP <= card.PermanentOfThisCard().DP;
  40. }
  41. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  42. {
  43. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsWeakerEnemyDigimon))
  44. {
  45. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  46. selectPermanentEffect.SetUp(
  47. selectPlayer: card.Owner,
  48. canTargetCondition: IsWeakerEnemyDigimon,
  49. canTargetCondition_ByPreSelecetedList: null,
  50. canEndSelectCondition: null,
  51. maxCount: 1,
  52. canNoSelect: true,
  53. canEndNotMax: false,
  54. selectPermanentCoroutine: null,
  55. afterSelectPermanentCoroutine: null,
  56. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  57. cardEffect: activateClass);
  58. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  59. }
  60. Permanent permanent = card.PermanentOfThisCard();
  61. if (permanent.IsSuspended && permanent.CanUnsuspend)
  62. {
  63. string selectPlayerMessage = "Will you unsuspend this card?";
  64. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  65. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  66. {
  67. new SelectionElement<bool>(message: $"Yes", value: false, spriteIndex: 0),
  68. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  69. };
  70. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  71. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  72. bool unsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  73. if (unsuspend)
  74. {
  75. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(
  76. new List<Permanent>() { permanent },
  77. activateClass).Unsuspend());
  78. }
  79. }
  80. }
  81. #endregion
  82. #region On Play
  83. if (timing == EffectTiming.OnEnterFieldAnyone)
  84. {
  85. ActivateClass activateClass = new ActivateClass();
  86. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  87. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  88. activateClass.SetHashString(SharedHashString);
  89. cardEffects.Add(activateClass);
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.IsExistOnBattleArea(card)
  93. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  94. }
  95. }
  96. #endregion
  97. #region When Digivolving
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  102. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  103. activateClass.SetHashString(SharedHashString);
  104. cardEffects.Add(activateClass);
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleArea(card)
  108. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  109. }
  110. }
  111. #endregion
  112. #region When Attacking
  113. if (timing == EffectTiming.OnAllyAttack)
  114. {
  115. ActivateClass activateClass = new ActivateClass();
  116. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  117. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  118. activateClass.SetHashString(SharedHashString);
  119. cardEffects.Add(activateClass);
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleArea(card)
  123. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  124. }
  125. }
  126. #endregion
  127. #region All Turns
  128. if (timing == EffectTiming.WhenRemoveField)
  129. {
  130. ActivateClass activateClass = new ActivateClass();
  131. 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);
  132. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  133. cardEffects.Add(activateClass);
  134. string EffectDescription()
  135. => "[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.";
  136. bool CanUseCondition(Hashtable hashtable)
  137. {
  138. return CardEffectCommons.IsExistOnBattleArea(card)
  139. && CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card)
  140. && !CardEffectCommons.IsLeavingForDigiXros(hashtable);
  141. }
  142. bool IsXrosHeartOrBlueFlare(CardSource cardSource)
  143. {
  144. return cardSource.IsDigimon
  145. && (cardSource.EqualsTraits("Blue Flare") || cardSource.EqualsTraits("Xros Heart"));
  146. }
  147. bool CanPlayXrosHeartOrBlueFlare(CardSource cardSource)
  148. {
  149. return IsXrosHeartOrBlueFlare(cardSource)
  150. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  151. }
  152. bool CanSelectSaveTamerPermanentCondition(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  155. && permanent.IsTamer;
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  160. && card.PermanentOfThisCard().DigivolutionCards.Some(IsXrosHeartOrBlueFlare);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. bool placedCards = false;
  165. #region Place up to 4 cards under a tamer
  166. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectSaveTamerPermanentCondition))
  167. {
  168. List<CardSource> selectedCards = new List<CardSource>();
  169. int maxCount = Math.Min(4, card.PermanentOfThisCard().DigivolutionCards.Count(IsXrosHeartOrBlueFlare));
  170. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  171. selectCardEffect.SetUp(
  172. canTargetCondition: IsXrosHeartOrBlueFlare,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. canNoSelect: () => true,
  176. selectCardCoroutine: SelectCardCoroutine,
  177. afterSelectCardCoroutine: null,
  178. message: "Select digivolution cards to place under 1 of your Tamers.",
  179. maxCount: maxCount,
  180. canEndNotMax: true,
  181. isShowOpponent: true,
  182. mode: SelectCardEffect.Mode.Custom,
  183. root: SelectCardEffect.Root.DigivolutionCards,
  184. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  185. canLookReverseCard: true,
  186. selectPlayer: card.Owner,
  187. cardEffect: activateClass);
  188. selectCardEffect.SetUpCustomMessage(
  189. "Select digivolution cards to place under 1 of your Tamers.",
  190. "The opponent is selecting digivolution cards to place under 1 of your Tamers.");
  191. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  192. yield return StartCoroutine(selectCardEffect.Activate());
  193. IEnumerator SelectCardCoroutine(CardSource cardSource)
  194. {
  195. selectedCards.Add(cardSource);
  196. yield return null;
  197. }
  198. Permanent selectedPermanent = null;
  199. if (selectedCards.Count > 0)
  200. {
  201. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  202. selectPermanentEffect.SetUp(
  203. selectPlayer: card.Owner,
  204. canTargetCondition: CanSelectSaveTamerPermanentCondition,
  205. canTargetCondition_ByPreSelecetedList: null,
  206. canEndSelectCondition: null,
  207. maxCount: 1,
  208. canNoSelect: true,
  209. canEndNotMax: false,
  210. selectPermanentCoroutine: SelectPermanentCoroutine,
  211. afterSelectPermanentCoroutine: null,
  212. mode: SelectPermanentEffect.Mode.Custom,
  213. cardEffect: activateClass);
  214. selectPermanentEffect.SetUpCustomMessage("Select 1 Tamer to place the chosen cards under.",
  215. "The opponent is selecting 1 Tamer to place the chosen cards under.");
  216. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  217. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  218. {
  219. selectedPermanent = permanent;
  220. yield return null;
  221. }
  222. if (selectedPermanent != null)
  223. {
  224. placedCards = true;
  225. yield return ContinuousController.instance.StartCoroutine(
  226. selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  227. }
  228. }
  229. }
  230. #endregion
  231. #region Play 1 card
  232. if (placedCards && 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: () => false,
  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. }