BT25_038.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Shakkoumon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_038 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alternate Digivolution Requirement
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, true, card, null, level: 4));
  21. }
  22. #endregion
  23. #region DNA Digivolution - Yellow Lv.4 + Black/Blue Lv.4: Cost 0
  24. if (timing == EffectTiming.None)
  25. {
  26. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  27. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  28. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  29. addJogressConditionClass.SetNotShowUI(true);
  30. cardEffects.Add(addJogressConditionClass);
  31. bool CanUseCondition(Hashtable hashtable)
  32. {
  33. return true;
  34. }
  35. JogressCondition GetJogress(CardSource cardSource)
  36. {
  37. if (cardSource == card)
  38. {
  39. bool PermanentCondition1(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  42. {
  43. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  44. {
  45. if (permanent.Levels_ForJogress(card).Contains(4))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool PermanentCondition2(Permanent permanent)
  54. {
  55. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  56. {
  57. if (permanent.TopCard.CardColors.Contains(CardColor.Black) || permanent.TopCard.CardColors.Contains(CardColor.Blue))
  58. {
  59. if (permanent.Levels_ForJogress(card).Contains(4))
  60. {
  61. return true;
  62. }
  63. }
  64. }
  65. return false;
  66. }
  67. JogressConditionElement[] elements = new JogressConditionElement[]
  68. {
  69. new JogressConditionElement(PermanentCondition1, "a level 4 Yellow Digimon"),
  70. new JogressConditionElement(PermanentCondition2, "a level 4 Black or Blue Digimon"),
  71. };
  72. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  73. return jogressCondition;
  74. }
  75. return null;
  76. }
  77. }
  78. #endregion
  79. #region Shared OP/WD
  80. string SharedEffectName = "May place 1 traited Digimon card from hand/sources as top or bot sec, then if DNA, trash both player's top sec";
  81. CardEffectFactory.ActivateClassesForSharedEffects
  82. (ref cardEffects, timing, card,
  83. SharedEffectName,
  84. SharedActivateCoroutine,
  85. SharedEffectDescription,
  86. optional: false,
  87. isSkippableFunction: IsSkippable,
  88. onPlay: true,
  89. whenDigivolving: true);
  90. string SharedEffectDescription(string tag)
  91. => $"[{tag}] You may place 1 [Angel], [Archangel], [Three Great Angels] or [Iliad] trait Digimon card from your hand or your Digimon's digivolution cards as the top or bottom security card. Then, if DNA digivolving, trash both players' top security cards.";
  92. bool IsSkippable(Hashtable hashtable)
  93. {
  94. return !CardEffectCommons.IsJogress(hashtable);
  95. }
  96. bool CanSelectCardCondition(CardSource cardSource)
  97. {
  98. return cardSource.IsDigimon
  99. && (cardSource.EqualsTraits("Angel")
  100. || cardSource.EqualsTraits("Archangel")
  101. || cardSource.EqualsTraits("Three Great Angels")
  102. || cardSource.EqualsTraits("Iliad"));
  103. }
  104. bool CanSelectPlacePermanentCondition(Permanent permanent)
  105. {
  106. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  107. && permanent.DigivolutionCards.Exists(CanSelectCardCondition);
  108. }
  109. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  110. {
  111. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  112. }
  113. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  114. {
  115. if (card.Owner.CanAddSecurity(activateClass))
  116. {
  117. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  118. bool canSelectSource = CardEffectCommons.HasMatchConditionPermanent(CanSelectPlacePermanentCondition);
  119. if (canSelectHand || canSelectSource)
  120. {
  121. if (canSelectHand && canSelectSource)
  122. {
  123. List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
  124. {
  125. new (message: $"From hand", value : 1, spriteIndex: 0),
  126. new (message: $"From sources", value : 2, spriteIndex: 0),
  127. new (message: $"Don't place", value: 3, spriteIndex: 1)
  128. };
  129. string selectPlayerMessage1 = "From which area will you place a card?";
  130. string notSelectPlayerMessage1 = "The opponent is choosing from which area to place a card.";
  131. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  132. }
  133. else
  134. {
  135. GManager.instance.userSelectionManager.SetInt(canSelectHand ? 1 : 2);
  136. }
  137. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  138. bool fromHand = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  139. bool dontPlace = GManager.instance.userSelectionManager.SelectedIntValue == 3;
  140. if (!dontPlace)
  141. {
  142. CardSource selectedCard = null;
  143. if (fromHand)
  144. {
  145. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  146. selectHandEffect.SetUp(
  147. selectPlayer: card.Owner,
  148. canTargetCondition: CanSelectCardCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. maxCount: 1,
  152. canNoSelect: true,
  153. canEndNotMax: false,
  154. isShowOpponent: true,
  155. selectCardCoroutine: SelectCardCoroutine,
  156. afterSelectCardCoroutine: null,
  157. mode: SelectHandEffect.Mode.Custom,
  158. cardEffect: activateClass);
  159. selectHandEffect.SetUpCustomMessage("Select 1 card to place in security.", "The opponent is selecting 1 card to place in security.");
  160. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  161. yield return StartCoroutine(selectHandEffect.Activate());
  162. }
  163. else
  164. {
  165. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  166. selectPermanentEffect.SetUp(
  167. selectPlayer: card.Owner,
  168. canTargetCondition: CanSelectPlacePermanentCondition,
  169. canTargetCondition_ByPreSelecetedList: null,
  170. canEndSelectCondition: null,
  171. maxCount: 1,
  172. canNoSelect: true,
  173. canEndNotMax: false,
  174. selectPermanentCoroutine: null,
  175. afterSelectPermanentCoroutine: afterSelectPermanentCoroutine,
  176. mode: SelectPermanentEffect.Mode.Custom,
  177. cardEffect: activateClass);
  178. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to select a card from to place in security.", "The opponent is selecting 1 Digimon to select a card from to place in security.");
  179. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  180. IEnumerator afterSelectPermanentCoroutine(List<Permanent> selectedPermanent)
  181. {
  182. if (selectedPermanent != null)
  183. {
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: CanSelectCardCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => true,
  190. selectCardCoroutine: SelectCardCoroutine,
  191. afterSelectCardCoroutine: null,
  192. message: "Select 1 [Angel], [Archangel], [Three Great Angels] or [Iliad] trait Digimon card to place in security.",
  193. maxCount: 1,
  194. canEndNotMax: false,
  195. isShowOpponent: true,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.DigivolutionCards,
  198. customRootCardList: selectedPermanent[0].DigivolutionCards,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. yield return StartCoroutine(selectCardEffect.Activate());
  203. }
  204. }
  205. }
  206. IEnumerator SelectCardCoroutine(CardSource cardSource)
  207. {
  208. selectedCard = cardSource;
  209. yield return null;
  210. }
  211. if (selectedCard != null)
  212. {
  213. List<SelectionElement<int>> selectionElements1 = new List<SelectionElement<int>>()
  214. {
  215. new (message: $"to Top", value : 1, spriteIndex: 0),
  216. new (message: $"to Bottom", value : 2, spriteIndex: 0),
  217. new (message: $"do not place", value : 3, spriteIndex: 1),
  218. };
  219. string selectPlayerMessage1 = "Where will you place card?";
  220. string notSelectPlayerMessage1 = "The opponent is choosing where to place card.";
  221. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  222. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  223. bool toTop = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  224. bool dontPlace1 = GManager.instance.userSelectionManager.SelectedIntValue == 3;
  225. if (!dontPlace1)
  226. {
  227. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().RemoveDigivolveRootEffect(selectedCard, selectedCard.PermanentOfThisCard()));
  228. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard, toTop: toTop));
  229. }
  230. }
  231. }
  232. }
  233. }
  234. if (CardEffectCommons.IsJogress(hashtable))
  235. {
  236. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  237. player: card.Owner,
  238. destroySecurityCount: 1,
  239. cardEffect: activateClass,
  240. fromTop: true).DestroySecurity());
  241. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  242. player: card.Owner.Enemy,
  243. destroySecurityCount: 1,
  244. cardEffect: activateClass,
  245. fromTop: true).DestroySecurity());
  246. }
  247. }
  248. #endregion
  249. #region All Turns
  250. if (timing == EffectTiming.OnAddSecurity)
  251. {
  252. ActivateClass activateClass = new ActivateClass();
  253. activateClass.SetUpICardEffect("<Dedigivolve 1> 1 enemy digimon>", CanUseCondition, card);
  254. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  255. activateClass.SetHashString("BT25_038_AT");
  256. cardEffects.Add(activateClass);
  257. string EffectDescription()
  258. {
  259. return "[All Turns] [Once Per Turn] When your security stack is added to, <De-Digivolve 1> 1 of your opponent's Digimon.";
  260. }
  261. bool CanUseCondition(Hashtable hashtable)
  262. {
  263. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  264. && CardEffectCommons.CanTriggerWhenAddSecurity(hashtable, player => player == card.Owner);
  265. }
  266. bool CanActivateCondition(Hashtable hashtable)
  267. {
  268. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  269. }
  270. IEnumerator ActivateCoroutine(Hashtable hashtable)
  271. {
  272. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentPermanentCondition))
  273. {
  274. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  275. selectPermanentEffect.SetUp(
  276. selectPlayer: card.Owner,
  277. canTargetCondition: CanSelectOpponentPermanentCondition,
  278. canTargetCondition_ByPreSelecetedList: null,
  279. canEndSelectCondition: null,
  280. maxCount: 1,
  281. canNoSelect: false,
  282. canEndNotMax: false,
  283. selectPermanentCoroutine: null,
  284. afterSelectPermanentCoroutine: null,
  285. mode: SelectPermanentEffect.Mode.Degenerate,
  286. cardEffect: activateClass);
  287. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to <De-Digivolve 1>", "The opponent is selecting 1 Digimon to <De-Digivolve 1>");
  288. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  289. }
  290. }
  291. }
  292. #endregion
  293. #region Inherited
  294. if (timing == EffectTiming.OnLoseSecurity)
  295. {
  296. ActivateClass activateClass = new ActivateClass();
  297. activateClass.SetUpICardEffect("1 of your opponent's Digimon gets -4000 DP", CanUseCondition, card);
  298. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  299. activateClass.SetHashString("BT25_040_WST_AT");
  300. activateClass.SetIsInheritedEffect(true);
  301. cardEffects.Add(activateClass);
  302. string EffectDescription() => "[All Turns] (Once Per Turn) When security stacks are removed from, 1 of your opponent's Digimon gets -4000 DP for the turn.";
  303. bool CanUseCondition(Hashtable hashtable)
  304. {
  305. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  306. CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  307. }
  308. bool CanActivateCondition(Hashtable hashtable)
  309. {
  310. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  311. }
  312. IEnumerator ActivateCoroutine(Hashtable hashtable)
  313. {
  314. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  315. {
  316. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  317. selectPermanentEffect.SetUp(
  318. selectPlayer: card.Owner,
  319. canTargetCondition: CanSelectOpponentPermanentCondition,
  320. canTargetCondition_ByPreSelecetedList: null,
  321. canEndSelectCondition: null,
  322. maxCount: 1,
  323. canNoSelect: false,
  324. canEndNotMax: false,
  325. selectPermanentCoroutine: SelectPermanentCoroutine,
  326. afterSelectPermanentCoroutine: null,
  327. mode: SelectPermanentEffect.Mode.Custom,
  328. cardEffect: activateClass);
  329. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  330. "The opponent is selecting 1 Digimon that will get DP -4000.");
  331. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  332. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  333. {
  334. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  335. targetPermanent: permanent,
  336. changeValue: -4000,
  337. effectDuration: EffectDuration.UntilEachTurnEnd,
  338. activateClass: activateClass));
  339. }
  340. }
  341. }
  342. }
  343. #endregion
  344. return cardEffects;
  345. }
  346. }
  347. }