EX12_018.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Siriusmon / Planet Punch
  6. namespace DCGO.CardEffects.EX12
  7. {
  8. public class EX12_018 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digimon Effects
  14. #region Alt Digivolution
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent permanent)
  18. {
  19. return permanent.TopCard.HasVBTraits
  20. || permanent.TopCard.HasText("Gammamon");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 5));
  23. }
  24. #endregion
  25. #region Progress
  26. if (timing == EffectTiming.None)
  27. {
  28. cardEffects.Add(CardEffectFactory.ProgressSelfStaticEffect(false, card, null));
  29. }
  30. #endregion
  31. #region Piercing
  32. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  33. {
  34. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  35. }
  36. #endregion
  37. #region Security Attack +1
  38. if (timing == EffectTiming.None)
  39. {
  40. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: false, card: card, condition: null));
  41. }
  42. #endregion
  43. #region Shared WD / WA
  44. string SharedEffectName = "May place up to 2 [Gammamon] in text/[VB] trait digimon from hand or trash as top/bottom digivolution card, if placed -2000 DP for each digivolution card to 1 opponent digimon";
  45. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] You may place up to 2 Digimon cards with [Gammamon] in its text or the [VB] trait from your hand or trash as this Digimon's top or bottom digivolution cards. If this effect placed, to 1 of your opponent's Digimon, give -2000 DP until their turn ends for each of this Digimon's digivolution cards.";
  46. string SharedHashValue = "EX12_018_WDWA";
  47. CardEffectFactory.ActivateClassesForSharedEffects
  48. (ref cardEffects, timing, card,
  49. SharedEffectName,
  50. SharedActivateCoroutine,
  51. SharedEffectDescription,
  52. hashValue: SharedHashValue,
  53. maxCountPerTurn: 1,
  54. optional: false,
  55. isSkippable: true,
  56. whenDigivolving: true,
  57. whenAttacking: true);
  58. bool CanSelectCardCondition(CardSource cardSource)
  59. => cardSource.IsDigimon &&
  60. (cardSource.HasVBTraits || cardSource.HasText("Gammamon"));
  61. bool CanSelectPermamentCondition(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  62. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  63. {
  64. bool isUsed = false;
  65. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  66. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  67. if (canSelectHand || canSelectTrash)
  68. {
  69. List<CardSource> cardSources = new List<CardSource>();
  70. while (cardSources.Count < 2)
  71. {
  72. #region Setup Location Selection
  73. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  74. if (canSelectHand) selectionElements.Add(new(message: $"From Hand", value: 1, spriteIndex: 0));
  75. if (canSelectTrash) selectionElements.Add(new(message: $"From Trash", value: 2, spriteIndex: 0));
  76. selectionElements.Add(new(message: $"Don't place any", value: 3, spriteIndex: 1));
  77. string selectPlayerMessage = "Where will you select cards from to place under this Digimon as digivolution sources?";
  78. string notSelectPlayerMessage = "The opponent is choosing to up to 2 digimon cards inside this cards digivolution source.";
  79. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  80. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  81. #endregion
  82. if (GManager.instance.userSelectionManager.SelectedIntValue == 3)
  83. {
  84. break;
  85. }
  86. else
  87. {
  88. int maxCount = Math.Max(2, 2-cardSources.Count);
  89. IEnumerator SelectCardCoroutine(CardSource cardSource)
  90. {
  91. cardSources.Add(cardSource);
  92. yield return null;
  93. }
  94. if (GManager.instance.userSelectionManager.SelectedIntValue == 1)
  95. {
  96. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  97. selectHandEffect.SetUp(
  98. selectPlayer: card.Owner,
  99. canTargetCondition: CanSelectCardCondition,
  100. canTargetCondition_ByPreSelecetedList: null,
  101. canEndSelectCondition: null,
  102. maxCount: maxCount,
  103. canNoSelect: true,
  104. canEndNotMax: true,
  105. isShowOpponent: true,
  106. selectCardCoroutine: SelectCardCoroutine,
  107. afterSelectCardCoroutine: null,
  108. mode: SelectHandEffect.Mode.Custom,
  109. cardEffect: activateClass);
  110. selectHandEffect.SetUpCustomMessage("Select up to 2 digimon cards to add to source.", "The opponent is selecting 2 digimon cards to add to source.");
  111. selectHandEffect.SetUpCustomMessage_ShowCard("Selected cards");
  112. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  113. }
  114. else
  115. {
  116. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  117. selectCardEffect.SetUp(
  118. canTargetCondition: CanSelectCardCondition,
  119. canTargetCondition_ByPreSelecetedList: null,
  120. canEndSelectCondition: null,
  121. canNoSelect: () => true,
  122. selectCardCoroutine: SelectCardCoroutine,
  123. afterSelectCardCoroutine: null,
  124. message: "Select up to 2 digimon cards",
  125. maxCount: maxCount,
  126. canEndNotMax: true,
  127. isShowOpponent: true,
  128. mode: SelectCardEffect.Mode.Custom,
  129. root: SelectCardEffect.Root.Trash,
  130. customRootCardList: null,
  131. canLookReverseCard: true,
  132. selectPlayer: card.Owner,
  133. cardEffect: activateClass);
  134. selectCardEffect.SetUpCustomMessage("Select up to 2 digimon cards to add to source.", "The opponent is selecting 2 digimon cards to add to source.");
  135. selectCardEffect.SetUpCustomMessage_ShowCard("Selected cards");
  136. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  137. }
  138. }
  139. }
  140. if (cardSources.Any())
  141. {
  142. isUsed = true;
  143. #region Setup Location Selection
  144. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>();
  145. if (canSelectHand) selectionElements1.Add(new(message: $"Top of digivolution sources", value: true, spriteIndex: 0));
  146. if (canSelectTrash) selectionElements1.Add(new(message: $"Bottom of digivolution sources", value: false, spriteIndex: 0));
  147. string selectPlayerMessage1 = "Will you place up to 2 digimon cards inside this cards digivolution source?";
  148. string notSelectPlayerMessage1 = "The opponent is choosing to up to 2 digimon cards inside this cards digivolution source.";
  149. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  150. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  151. #endregion
  152. bool isTop = GManager.instance.userSelectionManager.SelectedBoolValue;
  153. if (isTop)
  154. {
  155. List<CardSource> fixedCards = new List<CardSource>();
  156. fixedCards = cardSources.Clone();
  157. fixedCards.Reverse();
  158. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsTop(
  159. addedDigivolutionCards: fixedCards,
  160. cardEffect: activateClass));
  161. }
  162. else yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  163. addedDigivolutionCards: cardSources,
  164. cardEffect: activateClass));
  165. if (card.PermanentOfThisCard().DigivolutionCards.Intersect(cardSources).Any() && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermamentCondition))
  166. {
  167. int dpMinus = 2000 * card.PermanentOfThisCard().DigivolutionCards.Count;
  168. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  169. selectPermanentEffect.SetUp(
  170. selectPlayer: card.Owner,
  171. canTargetCondition: CanSelectPermamentCondition,
  172. canTargetCondition_ByPreSelecetedList: null,
  173. canEndSelectCondition: null,
  174. maxCount: 1,
  175. canNoSelect: false,
  176. canEndNotMax: false,
  177. selectPermanentCoroutine: SelectPermanentCoroutine,
  178. afterSelectPermanentCoroutine: null,
  179. mode: SelectPermanentEffect.Mode.Custom,
  180. cardEffect: activateClass);
  181. selectPermanentEffect.SetUpCustomMessage($"Select 1 Digimon that will get DP -{dpMinus}.", $"The opponent is selecting 1 Digimon that will get DP -{dpMinus}.");
  182. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  183. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  184. {
  185. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: permanent, changeValue: -dpMinus, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  186. }
  187. }
  188. }
  189. }
  190. if (!isUsed) activateClass.RemoveUse();
  191. }
  192. #endregion
  193. #endregion
  194. #region Option Effects
  195. #region Ignore Colour Requirement
  196. if (timing == EffectTiming.None)
  197. {
  198. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  199. bool CardCondition(CardSource cardSource)
  200. {
  201. return cardSource.HasVBTraits;
  202. }
  203. }
  204. #endregion
  205. #region Main
  206. if (timing == EffectTiming.OptionSkill)
  207. {
  208. ActivateClass activateClass = new ActivateClass();
  209. activateClass.SetUpICardEffect("Delete 1 enemy digimon with highest DP, then 1 digimon may attack", CanUseCondition, card);
  210. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  211. cardEffects.Add(activateClass);
  212. string EffectDescription()
  213. => "[Main] Delete 1 of your opponent's highest DP Digimon. Then, 1 of your Digimon may attack.";
  214. bool CanUseCondition(Hashtable hashtable)
  215. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  216. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  217. => CardEffectCommons.IsMaxDP(permanent, card.Owner.Enemy, null);
  218. bool CanSelectOwnerPermamentCondition(Permanent permanent)
  219. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  220. && permanent.CanAttack(activateClass);
  221. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  222. {
  223. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  224. {
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectOpponentPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: 1,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: null,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Destroy,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete", "The opponent is selecting 1 Digimon to delete.");
  239. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  240. }
  241. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermamentCondition))
  242. {
  243. SelectPermanentEffect selectPermanentEffect =
  244. GManager.instance.GetComponent<SelectPermanentEffect>();
  245. selectPermanentEffect.SetUp(
  246. selectPlayer: card.Owner,
  247. canTargetCondition: CanSelectOwnerPermamentCondition,
  248. canTargetCondition_ByPreSelecetedList: null,
  249. canEndSelectCondition: null,
  250. maxCount: 1,
  251. canNoSelect: true,
  252. canEndNotMax: false,
  253. selectPermanentCoroutine: null,
  254. afterSelectPermanentCoroutine: null,
  255. mode: SelectPermanentEffect.Mode.Attack,
  256. cardEffect: activateClass);
  257. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  258. "The opponent is selecting 1 Digimon that will attack.");
  259. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  260. }
  261. }
  262. }
  263. #endregion
  264. #region Arts Digivolution
  265. if (timing == EffectTiming.None)
  266. {
  267. cardEffects.Add(CardEffectFactory.ArtsDigivolveEffect(card));
  268. }
  269. #endregion
  270. #endregion
  271. return cardEffects;
  272. }
  273. }
  274. }