EX11_046.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Galacticmon
  5. namespace DCGO.CardEffects.EX11
  6. {
  7. public class EX11_046 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alt Digivolution Conditions
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent) =>targetPermanent.TopCard.EqualsCardName("Snatchmon");
  16. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 9, ignoreDigivolutionRequirement: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.None)
  19. {
  20. static bool PermanentCondition(Permanent targetPermanent) => targetPermanent.TopCard.EqualsCardName("Galacticmon");
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 5, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Shared OP / WD
  25. string SharedEffectName = "Choose 1 Highest Cost Opponent's Digimon, delete the rest. If 4+ Vemmon, gain Blocker and immunity.";
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. optional: false,
  32. onPlay: true,
  33. whenDigivolving: true);
  34. string SharedEffectDescription(string tag) => $"[{tag}] Choose 1 of your opponent's highest play cost Digimon and delete all of their other Digimon. Then, if this Digimon has 4 or more [Vemmon] in its digivolution cards, until your opponent's turn ends, it gains <Blocker> and isn't affected by their effects.";
  35. bool CanSelectHighestCostCondition(Permanent permanent) => CardEffectCommons.IsMaxCost(permanent, card.Owner.Enemy, true);
  36. bool CanDeletePermanentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  37. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  38. {
  39. if (CardEffectCommons.MatchConditionPermanentCount(CanSelectHighestCostCondition) == 1)
  40. {
  41. Permanent permanent = null;
  42. permanent = card.Owner.Enemy.GetBattleAreaPermanents().FirstOrDefault(CanSelectHighestCostCondition);
  43. yield return ContinuousController.instance.StartCoroutine(SelectPermanentCoroutine(permanent));
  44. }
  45. else if (CardEffectCommons.MatchConditionPermanentCount(CanSelectHighestCostCondition) > 1)
  46. {
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectHighestCostCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: 1,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Opponent's Digimon, you will delete all other digimon.", "Opponent is selecting 1 digimon and will delete all others.");
  61. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  62. }
  63. else if (CardEffectCommons.MatchConditionPermanentCount(CanSelectHighestCostCondition) == 0 && CardEffectCommons.HasMatchConditionPermanent(CanDeletePermanentCondition))
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(card.Owner.Enemy.GetBattleAreaDigimons(), CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  66. }
  67. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  68. {
  69. if (permanent != null)
  70. {
  71. List<Permanent> targetPermanents = card.Owner.Enemy.GetBattleAreaDigimons().Filter(perm => perm != permanent);
  72. yield return ContinuousController.instance.StartCoroutine(new DestroyPermanentsClass(targetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Destroy());
  73. }
  74. }
  75. if (card.PermanentOfThisCard() != null && card.PermanentOfThisCard().DigivolutionCards.Count(cardSource => cardSource.EqualsCardName("Vemmon")) >= 4)
  76. {
  77. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(targetPermanent: card.PermanentOfThisCard(), effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  78. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  79. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effect", CanUseCondition1, card);
  80. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  81. card.PermanentOfThisCard().UntilOpponentTurnEndEffects.Add((_timing) => canNotAffectedClass);
  82. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(card.PermanentOfThisCard()));
  83. bool CanUseCondition1(Hashtable hashtable)
  84. {
  85. return card.PermanentOfThisCard().TopCard != null;
  86. }
  87. bool CardCondition(CardSource cardSource)
  88. {
  89. return card.PermanentOfThisCard().TopCard != null
  90. && card.PermanentOfThisCard().TopCard.Owner.GetBattleAreaPermanents().Contains(card.PermanentOfThisCard())
  91. && cardSource == card.PermanentOfThisCard().TopCard;
  92. }
  93. bool SkillCondition(ICardEffect cardEffect)
  94. {
  95. return cardEffect != null
  96. && cardEffect.EffectSourceCard != null
  97. && cardEffect.EffectSourceCard.Owner == card.Owner.Enemy;
  98. }
  99. }
  100. }
  101. #endregion
  102. #region End Of Opponent's Turn
  103. if (timing == EffectTiming.OnEndTurn)
  104. {
  105. ActivateClass activateClass = new ActivateClass();
  106. activateClass.SetUpICardEffect("Digivolve into Galacticmon", CanUseCondition, card);
  107. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  108. cardEffects.Add(activateClass);
  109. string EffectDescription() => "[End of Opponent's Turn] This Digimon may digivolve into [Galacticmon] in the hand or trash, ignoring digivolution requirements and without paying the cost.";
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  113. && CardEffectCommons.IsOpponentTurn(card);
  114. }
  115. bool CanActivateCondition(Hashtable hashtable)
  116. {
  117. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  118. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  119. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition));
  120. }
  121. bool CanSelectCardCondition(CardSource cardSource) => cardSource.EqualsCardName("Galacticmon");
  122. IEnumerator ActivateCoroutine(Hashtable hashtable)
  123. {
  124. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  125. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  126. if (canSelectHand || canSelectTrash)
  127. {
  128. if (canSelectHand && canSelectTrash)
  129. {
  130. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  131. {
  132. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  133. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  134. };
  135. string selectPlayerMessage = "From which area do you digivolve a card?";
  136. string notSelectPlayerMessage = "The opponent is choosing from which area to digivolve a card.";
  137. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  138. }
  139. else
  140. {
  141. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  142. }
  143. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  144. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  145. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  146. targetPermanent: card.PermanentOfThisCard(),
  147. cardCondition: CanSelectCardCondition,
  148. payCost: false,
  149. reduceCostTuple: null,
  150. fixedCostTuple: null,
  151. ignoreDigivolutionRequirementFixedCost: -1,
  152. isHand: fromHand,
  153. activateClass: activateClass,
  154. successProcess: null,
  155. ignoreRequirements: CardEffectCommons.IgnoreRequirement.All));
  156. }
  157. }
  158. }
  159. #endregion
  160. #region Assembly
  161. if (timing == EffectTiming.None)
  162. {
  163. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  164. addAssemblyConditionClass.SetUpICardEffect($"Assembly", CanUseCondition, card);
  165. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  166. addAssemblyConditionClass.SetNotShowUI(true);
  167. cardEffects.Add(addAssemblyConditionClass);
  168. bool CanUseCondition(Hashtable hashtable) => true;
  169. AssemblyCondition GetAssembly(CardSource cardSource)
  170. {
  171. if (cardSource == card)
  172. {
  173. AssemblyConditionElement element = new AssemblyConditionElement(CanSelectCardCondition);
  174. bool CanSelectCardCondition(CardSource cardSource)
  175. {
  176. return cardSource != null
  177. && cardSource.Owner == card.Owner
  178. && cardSource.HasText("Vemmon");
  179. }
  180. AssemblyCondition assemblyCondition = new AssemblyCondition(
  181. element: element,
  182. CanTargetCondition_ByPreSelecetedList: null,
  183. selectMessage: "8 cards w/[Vemmon] in text",
  184. elementCount: 8,
  185. reduceCost: 6);
  186. return assemblyCondition;
  187. }
  188. return null;
  189. }
  190. }
  191. #endregion
  192. return cardEffects;
  193. }
  194. }
  195. }