AD1_009.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // BlitzGreymon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_009 : 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("Greymon")
  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, Piercing and Blocker
  32. if (timing == EffectTiming.OnAllyAttack)
  33. {
  34. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  37. {
  38. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  39. }
  40. if (timing == EffectTiming.None)
  41. {
  42. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  43. }
  44. #endregion
  45. #region Shared OP / WD
  46. string SharedEffectName = "<De-Digivolve 3> 1 opponent's Digimon. Until the end of your opponent's turn this Digimon and 1 with [Garurumon] in name cannot be affected by their Digimon's effects";
  47. string SharedEffectDescription(string tag)
  48. => $"[{tag}] <De-Digivolve 3> 1 of your opponent's Digimon. Then, until your opponent's turn ends, their Digimon's effects don't affect this Digimon and 1 of your Digimon with [Garurumon] in its name.";
  49. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  50. bool IsEnemyDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  51. bool IsOwnGarurumon(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  54. && permanent.TopCard.ContainsCardName("Garurumon");
  55. }
  56. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  57. {
  58. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, IsEnemyDigimon))
  59. {
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: IsEnemyDigimon,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: 1,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: null,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Degenerate,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetDegenerationCount(3);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. }
  77. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsOwnGarurumon))
  78. {
  79. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  80. selectPermanentEffect.SetUp(
  81. selectPlayer: card.Owner,
  82. canTargetCondition: IsOwnGarurumon,
  83. canTargetCondition_ByPreSelecetedList: null,
  84. canEndSelectCondition: null,
  85. maxCount: 1,
  86. canNoSelect: false,
  87. canEndNotMax: false,
  88. selectPermanentCoroutine: SelectPermanentCoroutine,
  89. afterSelectPermanentCoroutine: null,
  90. mode: SelectPermanentEffect.Mode.Custom,
  91. cardEffect: activateClass);
  92. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get immunity.", "The opponent is selecting 1 Digimon that will get immunity.");
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  95. {
  96. #region Give Digimon Effect Immunity
  97. permanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(permanent));
  98. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(permanent));
  99. #endregion
  100. }
  101. }
  102. #region Give Digimon Effect Immunity
  103. Permanent thisPermanent = card.PermanentOfThisCard();
  104. thisPermanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(thisPermanent));
  105. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(thisPermanent));
  106. #endregion
  107. }
  108. #endregion
  109. #region On Play
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  114. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("On Play"));
  115. cardEffects.Add(activateClass);
  116. bool CanUseCondition(Hashtable hashtable)
  117. {
  118. return CardEffectCommons.IsExistOnBattleArea(card)
  119. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  120. }
  121. }
  122. #endregion
  123. #region When Digivolving
  124. if (timing == EffectTiming.OnEnterFieldAnyone)
  125. {
  126. ActivateClass activateClass = new ActivateClass();
  127. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  128. activateClass.SetUpActivateClass(SharedCanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  129. cardEffects.Add(activateClass);
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleArea(card)
  133. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. }
  136. #endregion
  137. #region End of Your Turn
  138. if (timing == EffectTiming.OnEndTurn)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("DNA digivolve into [Omnimon Alter-S]. 1 Digimon may attack.", CanUseCondition, card);
  142. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  143. cardEffects.Add(activateClass);
  144. string EffectDescription() => "[End of Your Turn] 2 of your Digimon may DNA digivolve into [Omnimon Alter-S] in the hand. Then, 1 of your Digimon may attack.";
  145. bool CanSelectDNACardCondition(CardSource cardSource)
  146. {
  147. return cardSource.IsDigimon
  148. && cardSource.CanPlayJogress(true)
  149. && cardSource.EqualsCardName("Omnimon Alter-S");
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleArea(card)
  154. && CardEffectCommons.IsOwnerTurn(card);
  155. }
  156. bool CanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  157. bool IsYourDigimon(Permanent permanent)
  158. {
  159. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  160. && permanent.CanAttack(activateClass);
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. #region DNA digivolve
  165. yield return ContinuousController.instance.StartCoroutine(
  166. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  167. CanSelectDNACardCondition,
  168. payCost: true,
  169. isHand: true,
  170. activateClass
  171. ));
  172. #endregion
  173. #region May Attack
  174. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYourDigimon))
  175. {
  176. SelectPermanentEffect selectPermanentEffect =
  177. GManager.instance.GetComponent<SelectPermanentEffect>();
  178. selectPermanentEffect.SetUp(
  179. selectPlayer: card.Owner,
  180. canTargetCondition: IsYourDigimon,
  181. canTargetCondition_ByPreSelecetedList: null,
  182. canEndSelectCondition: null,
  183. maxCount: 1,
  184. canNoSelect: true,
  185. canEndNotMax: false,
  186. selectPermanentCoroutine: null,
  187. afterSelectPermanentCoroutine: null,
  188. mode: SelectPermanentEffect.Mode.Attack,
  189. cardEffect: activateClass);
  190. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  191. "The opponent is selecting 1 Digimon that will attack.");
  192. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  193. }
  194. #endregion
  195. }
  196. }
  197. #endregion
  198. #region Assembly
  199. if (timing == EffectTiming.None)
  200. {
  201. string cardName1 = "MetalGreymon: Alterous Mode";
  202. string cardName2 = "Greymon";
  203. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  204. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  205. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  206. addAssemblyConditionClass.SetNotShowUI(true);
  207. cardEffects.Add(addAssemblyConditionClass);
  208. bool CanUseCondition(Hashtable hashtable)
  209. {
  210. return true;
  211. }
  212. AssemblyCondition GetAssembly(CardSource cardSource)
  213. {
  214. if (cardSource == card)
  215. {
  216. AssemblyConditionElement element1 = new AssemblyConditionElement(CanSelectCardCondition1, selectMessage: $"[{cardName1}]", elementCount: 1);
  217. AssemblyConditionElement element2 = new AssemblyConditionElement(CanSelectCardCondition2, selectMessage: $"[{cardName2}]", elementCount: 1);
  218. bool CanSelectCardCondition1(CardSource cardSource)
  219. {
  220. return cardSource != null &&
  221. cardSource.Owner == card.Owner &&
  222. cardSource.IsDigimon &&
  223. cardSource.EqualsCardName(cardName1);
  224. }
  225. bool CanSelectCardCondition2(CardSource cardSource)
  226. {
  227. return cardSource != null &&
  228. cardSource.Owner == card.Owner &&
  229. cardSource.IsDigimon &&
  230. cardSource.EqualsCardName(cardName2);
  231. }
  232. AssemblyCondition assemblyCondition = new AssemblyCondition(
  233. elements:new List<AssemblyConditionElement>() { element1, element2 },
  234. reduceCost: 4);
  235. return assemblyCondition;
  236. }
  237. return null;
  238. }
  239. }
  240. #endregion
  241. #region ESS Sec +1
  242. if (timing == EffectTiming.None)
  243. {
  244. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: null));
  245. }
  246. #endregion
  247. return cardEffects;
  248. }
  249. }
  250. }