AD1_012.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // CresGarurumon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_012 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternative Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.ContainsCardName("Garurumon")
  19. || targetPermanent.TopCard.EqualsTraits("ADVENTURE");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. level: 5,
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 3,
  25. ignoreDigivolutionRequirement: false,
  26. card: card,
  27. condition: null)
  28. );
  29. }
  30. #endregion
  31. #region Alliance and Evade
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  37. {
  38. cardEffects.Add(CardEffectFactory.EvadeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  39. }
  40. #endregion
  41. #region Shared OP / WD / WA
  42. string SharedHashString = "AD1_012_OP_WD_WA";
  43. string SharedEffectName = "You may return 1 lowest level opponent to hand. This and 1 [Greymon] may unsuspend";
  44. string SharedEffectDescription(string tag)
  45. => $"[{tag}] [Once Per Turn] You may return 1 of your opponent's lowest level Digimon to the hand. Then, this Digimon and 1 of your Digimon with [Greymon] in its name may unsuspend.";
  46. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  47. bool IsOpponentsLowestLevel(Permanent permanent) => CardEffectCommons.IsMinLevel(permanent, card.Owner.Enemy);
  48. bool IsOwnGreymon(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  51. && permanent.TopCard.ContainsCardName("Greymon")
  52. && permanent.IsSuspended;
  53. }
  54. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  55. {
  56. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsOpponentsLowestLevel))
  57. {
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: IsOpponentsLowestLevel,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: 1,
  65. canNoSelect: true,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: null,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Bounce,
  70. cardEffect: activateClass);
  71. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to return to hand", "The opponent is selecting 1 Digimon to return to hand");
  72. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  73. }
  74. string selectPlayerMessage = "Will you unsuspend your digimon?";
  75. string notSelectPlayerMessage = "The opponent is choosing if they will unsuspend.";
  76. List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
  77. {
  78. new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
  79. new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
  80. };
  81. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  82. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  83. bool unsuspend = GManager.instance.userSelectionManager.SelectedBoolValue;
  84. if (unsuspend)
  85. {
  86. List<Permanent> selectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
  87. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwnGreymon))
  88. {
  89. SelectPermanentEffect selectPermanentEffect =
  90. GManager.instance.GetComponent<SelectPermanentEffect>();
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: IsOwnGreymon,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: 1,
  97. canNoSelect: false,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: SelectPermanentCoroutine,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. selectPermanentEffect.SetUpCustomMessage("Select 1 Greymon to unsuspend with this card.", "The opponent is selecting 1 Digimon to unsuspend.");
  104. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  105. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  106. {
  107. selectedPermanents.Add(permanent);
  108. yield return null;
  109. }
  110. }
  111. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(selectedPermanents, activateClass).Unsuspend());
  112. }
  113. }
  114. #endregion
  115. #region On Play
  116. if (timing == EffectTiming.OnEnterFieldAnyone)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  120. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("On Play"));
  121. activateClass.SetHashString(SharedHashString);
  122. cardEffects.Add(activateClass);
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleArea(card)
  126. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  127. }
  128. }
  129. #endregion
  130. #region When Digivolving
  131. if (timing == EffectTiming.OnEnterFieldAnyone)
  132. {
  133. ActivateClass activateClass = new ActivateClass();
  134. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  135. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Digivolving"));
  136. activateClass.SetHashString(SharedHashString);
  137. cardEffects.Add(activateClass);
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleArea(card)
  141. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  142. }
  143. }
  144. #endregion
  145. #region When Attacking
  146. if (timing == EffectTiming.OnAllyAttack)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  150. activateClass.SetUpActivateClass(SharedCanActivateCondition,(hash) => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDescription("When Attacking"));
  151. activateClass.SetHashString(SharedHashString);
  152. cardEffects.Add(activateClass);
  153. bool CanUseCondition(Hashtable hashtable)
  154. {
  155. return CardEffectCommons.IsExistOnBattleArea(card)
  156. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  157. }
  158. }
  159. #endregion
  160. #region Opponent's Turn
  161. if (timing == EffectTiming.OnAllyAttack)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("You may DNA digivolve. Then you may change the attack target to 1 Digimon.", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  166. activateClass.SetHashString("Redirect_AD1_012");
  167. cardEffects.Add(activateClass);
  168. string EffectDescription()
  169. => "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, 2 of your Digimon may DNA digivolve into [Omnimon Alter-S] in the hand. Then, you may change the attack target to 1 of your Digimon.";
  170. bool IsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  174. && CardEffectCommons.IsOpponentTurn(card)
  175. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  176. }
  177. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  178. bool CanSelectDNACardCondition(CardSource cardSource)
  179. {
  180. return cardSource.IsDigimon
  181. && cardSource.CanPlayJogress(true)
  182. && cardSource.EqualsCardName("Omnimon Alter-S");
  183. }
  184. bool IsOwnDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  185. IEnumerator ActivateCoroutine(Hashtable hashtable)
  186. {
  187. #region DNA digivolve
  188. yield return ContinuousController.instance.StartCoroutine(
  189. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  190. CanSelectDNACardCondition,
  191. payCost: true,
  192. isHand: true,
  193. activateClass
  194. ));
  195. #endregion
  196. #region redirect attack
  197. Permanent selectedPermanent = null;
  198. SelectPermanentEffect selectPermanentEffect =
  199. GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: IsOwnDigimon,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: 1,
  206. canNoSelect: true,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: SelectPermanentCoroutine,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Custom,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to change the attack target to.", "The opponent is selecting 1 Digimon to change the attack target to.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  215. {
  216. selectedPermanent = permanent;
  217. yield return null;
  218. }
  219. if (selectedPermanent != null)
  220. {
  221. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  222. activateClass,
  223. false,
  224. selectedPermanent));
  225. }
  226. #endregion
  227. }
  228. }
  229. #endregion
  230. #region Assembly
  231. if (timing == EffectTiming.None)
  232. {
  233. string cardName1 = "WereGarurumon: Sagittarius Mode";
  234. string cardName2 = "Garurumon";
  235. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  236. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  237. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  238. addAssemblyConditionClass.SetNotShowUI(true);
  239. cardEffects.Add(addAssemblyConditionClass);
  240. bool CanUseCondition(Hashtable hashtable)
  241. {
  242. return true;
  243. }
  244. AssemblyCondition GetAssembly(CardSource cardSource)
  245. {
  246. if (cardSource == card)
  247. {
  248. AssemblyConditionElement element1 = new AssemblyConditionElement(CanSelectCardCondition1, selectMessage: $"[{cardName1}]", elementCount: 1);
  249. AssemblyConditionElement element2 = new AssemblyConditionElement(CanSelectCardCondition2, selectMessage: $"[{cardName2}]", elementCount: 1);
  250. bool CanSelectCardCondition1(CardSource cardSource)
  251. {
  252. return cardSource != null &&
  253. cardSource.Owner == card.Owner &&
  254. cardSource.IsDigimon &&
  255. cardSource.EqualsCardName(cardName1);
  256. }
  257. bool CanSelectCardCondition2(CardSource cardSource)
  258. {
  259. return cardSource != null &&
  260. cardSource.Owner == card.Owner &&
  261. cardSource.IsDigimon &&
  262. cardSource.EqualsCardName(cardName2);
  263. }
  264. AssemblyCondition assemblyCondition = new AssemblyCondition(
  265. elements:new List<AssemblyConditionElement>() { element1, element2 },
  266. reduceCost: 4);
  267. return assemblyCondition;
  268. }
  269. return null;
  270. }
  271. }
  272. #endregion
  273. #region Your Turn - ESS
  274. if (timing == EffectTiming.None)
  275. {
  276. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  277. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't be changed.", CanUseCondition, card);
  278. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  279. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  280. cardEffects.Add(canNotSwitchAttackTargetClass);
  281. bool CanUseCondition(Hashtable hashtable)
  282. {
  283. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  284. CardEffectCommons.IsOwnerTurn(card);
  285. }
  286. bool PermanentCondition(Permanent permanent)
  287. {
  288. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  289. }
  290. }
  291. #endregion
  292. return cardEffects;
  293. }
  294. }
  295. }