BT23_102.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Mastemon
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_102 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Alt Digivolve Cost
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.IsLevel5
  20. && targetPermanent.TopCard.HasCSTraits;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. permanentCondition: PermanentCondition,
  24. digivolutionCost: 5,
  25. ignoreDigivolutionRequirement: false,
  26. card: card, condition: null)
  27. );
  28. }
  29. #endregion
  30. #region DNA Digivolution
  31. if (timing == EffectTiming.None)
  32. {
  33. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  34. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  35. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  36. addJogressConditionClass.SetNotShowUI(true);
  37. cardEffects.Add(addJogressConditionClass);
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return true;
  41. }
  42. JogressCondition GetJogress(CardSource cardSource)
  43. {
  44. if (cardSource == card)
  45. {
  46. bool PermanentCondition1(Permanent permanent)
  47. {
  48. if (permanent != null)
  49. {
  50. if (permanent.TopCard != null)
  51. {
  52. if (permanent.TopCard.Owner == card.Owner)
  53. {
  54. if (permanent.IsDigimon)
  55. {
  56. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  57. {
  58. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  59. {
  60. if (permanent.Levels_ForJogress(card).Contains(5))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. bool PermanentCondition2(Permanent permanent)
  73. {
  74. if (permanent != null)
  75. {
  76. if (permanent.TopCard != null)
  77. {
  78. if (permanent.TopCard.Owner == card.Owner)
  79. {
  80. if (permanent.IsDigimon)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.TopCard.CardColors.Contains(CardColor.Purple))
  85. {
  86. if (permanent.Levels_ForJogress(card).Contains(5))
  87. {
  88. return true;
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. JogressConditionElement[] elements =
  99. {
  100. new(PermanentCondition1, "a level Yellow Digimon"),
  101. new(PermanentCondition2, "a level Purple Digimon")
  102. };
  103. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  104. return jogressCondition;
  105. }
  106. return null;
  107. }
  108. }
  109. #endregion
  110. #region Barrier
  111. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  112. {
  113. cardEffects.Add(CardEffectFactory.BarrierSelfEffect(isInheritedEffect: false, card: card, condition: null));
  114. }
  115. #endregion
  116. #region Partition
  117. List<PartitionCondition> partitionConditions = new List<PartitionCondition>
  118. {
  119. new PartitionCondition("Angewomon"),
  120. new PartitionCondition("LadyDevimon")
  121. };
  122. if (timing == EffectTiming.WhenRemoveField)
  123. {
  124. cardEffects.Add(CardEffectFactory.PartitionSelfEffect(
  125. isInheritedEffect: false,
  126. card: card,
  127. condition: null,
  128. cardSourceConditions: partitionConditions));
  129. }
  130. #endregion
  131. #endregion
  132. #region When Digivolving
  133. if (timing == EffectTiming.OnEnterFieldAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("Play 1 level 5 or lower yellow/purple card from hand or trash. then if digimon has 2+ same level cards in stack, trash both security till 3", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  138. cardEffects.Add(activateClass);
  139. string EffectDiscription()
  140. {
  141. return "[When Digivolving] You may play 1 level 5 or lower yellow or purple card from your hand or trash without paying the cost. Then, if this Digimon's stack has 2 or more same-level cards, trash the top cards of both players' security stacks so that they have 3 cards left.";
  142. }
  143. bool CanUseCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  146. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  147. }
  148. bool CanActivateCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  151. }
  152. bool CanSelectCard(CardSource cardSource)
  153. {
  154. return cardSource.IsDigimon
  155. && cardSource.HasLevel && cardSource.Level <= 5
  156. && (cardSource.HasCardColor(CardColor.Yellow) || cardSource.HasCardColor(CardColor.Purple))
  157. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  158. }
  159. IEnumerator ActivateCoroutine(Hashtable hashtable)
  160. {
  161. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCard);
  162. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCard);
  163. if (canSelectHand || canSelectTrash)
  164. {
  165. #region Setup user Selection
  166. if (canSelectHand && canSelectTrash)
  167. {
  168. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  169. {
  170. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  171. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  172. };
  173. string selectPlayerMessage = "From which area do you select a card?";
  174. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  175. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  176. }
  177. else
  178. {
  179. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  180. }
  181. #endregion
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  183. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  184. CardSource selectedCard = null;
  185. IEnumerator SelectCardCoroutine(CardSource cardSource)
  186. {
  187. selectedCard = cardSource;
  188. yield return null;
  189. }
  190. if (fromHand)
  191. {
  192. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  193. selectHandEffect.SetUp(
  194. selectPlayer: card.Owner,
  195. canTargetCondition: CanSelectCard,
  196. canTargetCondition_ByPreSelecetedList: null,
  197. canEndSelectCondition: null,
  198. maxCount: 1,
  199. canNoSelect: true,
  200. canEndNotMax: false,
  201. isShowOpponent: true,
  202. selectCardCoroutine: SelectCardCoroutine,
  203. afterSelectCardCoroutine: null,
  204. mode: SelectHandEffect.Mode.Custom,
  205. cardEffect: activateClass);
  206. selectHandEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play.");
  207. selectHandEffect.SetUpCustomMessage_ShowCard("Selected card");
  208. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  209. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  210. new List<CardSource>() { selectedCard },
  211. activateClass: activateClass,
  212. payCost: false,
  213. isTapped: false,
  214. root: SelectCardEffect.Root.Hand,
  215. activateETB: transform)
  216. );
  217. }
  218. else
  219. {
  220. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  221. selectCardEffect.SetUp(
  222. canTargetCondition: CanSelectCard,
  223. canTargetCondition_ByPreSelecetedList: null,
  224. canEndSelectCondition: null,
  225. canNoSelect: () => true,
  226. selectCardCoroutine: SelectCardCoroutine,
  227. afterSelectCardCoroutine: null,
  228. message: "Select 1 card to play.",
  229. maxCount: 1,
  230. canEndNotMax: false,
  231. isShowOpponent: true,
  232. mode: SelectCardEffect.Mode.Custom,
  233. root: SelectCardEffect.Root.Trash,
  234. customRootCardList: null,
  235. canLookReverseCard: true,
  236. selectPlayer: card.Owner,
  237. cardEffect: activateClass);
  238. selectCardEffect.SetUpCustomMessage("Select 1 card to play", "The opponent is selecting 1 card to play.");
  239. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  240. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  241. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  242. new List<CardSource>() { selectedCard },
  243. activateClass: activateClass,
  244. payCost: false,
  245. isTapped: false,
  246. root: SelectCardEffect.Root.Trash,
  247. activateETB: transform)
  248. );
  249. }
  250. }
  251. if (card.PermanentOfThisCard().StackCards.Filter(x => !x.IsFlipped).GroupBy(x => x.Level).Any(g => g.Count() >= 2))
  252. {
  253. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  254. {
  255. if (player.SecurityCards.Count <= 3) continue;
  256. var trashAmount = player.SecurityCards.Count - 3;
  257. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  258. player: player,
  259. destroySecurityCount: trashAmount,
  260. cardEffect: activateClass,
  261. fromTop: true).DestroySecurity()
  262. );
  263. }
  264. }
  265. }
  266. }
  267. #endregion
  268. #region All Turns - OPT
  269. if (timing == EffectTiming.OnLoseSecurity)
  270. {
  271. ActivateClass activateClass = new ActivateClass();
  272. activateClass.SetUpICardEffect("Place 1 digimon as bottom security", CanUseCondition, card);
  273. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  274. activateClass.SetHashString("BT23_102_AT");
  275. cardEffects.Add(activateClass);
  276. string EffectDiscription()
  277. {
  278. return "[All Turns] [Once Per Turn] When security stacks are removed from, you may place 1 Digimon as the bottom security card.";
  279. }
  280. bool CanUseCondition(Hashtable hashtable)
  281. {
  282. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  283. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, null);
  284. }
  285. bool CanActivateCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  288. }
  289. bool CanSelectPermanentCondition(Permanent permanent)
  290. {
  291. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  292. && permanent.IsDigimon;
  293. }
  294. IEnumerator ActivateCoroutine(Hashtable hashtable)
  295. {
  296. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  297. {
  298. Permanent selectedPermament = null;
  299. #region Select Opponent Permanent
  300. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  301. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  302. selectPermanentEffect.SetUp(
  303. selectPlayer: card.Owner,
  304. canTargetCondition: CanSelectPermanentCondition,
  305. canTargetCondition_ByPreSelecetedList: null,
  306. canEndSelectCondition: null,
  307. maxCount: maxCount,
  308. canNoSelect: false,
  309. canEndNotMax: false,
  310. selectPermanentCoroutine: SelectPermanentCoroutine,
  311. afterSelectPermanentCoroutine: null,
  312. mode: SelectPermanentEffect.Mode.Custom,
  313. cardEffect: activateClass);
  314. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  315. {
  316. selectedPermament = permanent;
  317. yield return null;
  318. }
  319. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to send to bottom of security.", "Your opponent is selecting 1 digimon to send to bottom of security.");
  320. #endregion
  321. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  322. if (selectedPermament != null)
  323. {
  324. if (!selectedPermament.TopCard.CanNotBeAffected(activateClass))
  325. {
  326. #region hashtable
  327. Hashtable _hashtable = new Hashtable()
  328. {
  329. {"CardEffect", activateClass}
  330. };
  331. #endregion
  332. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  333. permanent: selectedPermament,
  334. hashtable: _hashtable,
  335. toTop: false).PutSecurity()
  336. );
  337. }
  338. }
  339. }
  340. }
  341. }
  342. #endregion
  343. return cardEffects;
  344. }
  345. }
  346. }