BT25_088.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Kyo Sawashiro
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_088 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Start of turn set to 3
  13. if (timing == EffectTiming.OnStartTurn)
  14. {
  15. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  16. }
  17. #endregion
  18. #region All Turns
  19. if (timing == EffectTiming.OnLoseSecurity)
  20. {
  21. ActivateClass activateClass = new ActivateClass();
  22. activateClass.SetUpICardEffect("Suspend to may place top 2 from deck face down under this tamer", CanUseCondition, card);
  23. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  24. activateClass.SetIsSkippable(true);
  25. cardEffects.Add(activateClass);
  26. string EffectDescription()
  27. {
  28. return "[All Turns] When your security stack is removed from, by suspending this Tamer, you may place the top 2 cards of your deck face down under this Tamer.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card)
  33. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, (player) => player == card.Owner);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card)
  38. && CardEffectCommons.CanActivateSuspendCostEffect(card);
  39. }
  40. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  41. {
  42. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>
  43. {
  44. new(message: $"Suspend and place 2 cards from deck under this card", value: 1, spriteIndex: 0),
  45. new(message: $"Only suspend without placing cards", value: 2, spriteIndex: 0),
  46. new(message: $"No", value: 3, spriteIndex: 1)
  47. };
  48. string selectPlayerMessage = "Will you suspend this tamer to place the top 2 cards from your deck under this Tamer face down?";
  49. string notSelectPlayerMessage = "The opponent is choosing whether to place the top 2 cards from their deck under their Tamer face down.";
  50. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  51. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  52. int answer = GManager.instance.userSelectionManager.SelectedIntValue;
  53. if (answer != 3)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SuspendPeremanentAndProcessAccordingToResult(
  56. new List<Permanent>() { card.PermanentOfThisCard() },
  57. activateClass,
  58. SuccessProcess,
  59. null));
  60. }
  61. IEnumerator SuccessProcess(List<Permanent> suspendedPermaments)
  62. {
  63. if (answer == 1)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  66. new List<CardSource> { card.Owner.LibraryCards[0], card.Owner.LibraryCards[1] }, activateClass, isFacedown: true));
  67. }
  68. }
  69. }
  70. }
  71. #endregion
  72. #region Your Turn - Cost Reduction
  73. string CostReductionEffectName = "Trash 1 Face Down under a tamer to reduce cost by 1";
  74. bool TamerWithOneFaceDownSource(Permanent permanent)
  75. {
  76. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  77. && permanent.DigivolutionCards.Any(CanTrashCard);
  78. }
  79. bool CanTrashCard(CardSource cardSource) => cardSource.IsFaceDown;
  80. bool CardCondition(CardSource cardSource)
  81. {
  82. return cardSource.HasPlayCost
  83. && cardSource.HasGlowingDawnTraits
  84. && cardSource.Owner == card.Owner;
  85. }
  86. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  87. {
  88. if (CardCondition(cardSource))
  89. {
  90. if (RootCondition(root))
  91. {
  92. if (PermanentsCondition(targetPermanents))
  93. {
  94. Cost -= 1;
  95. }
  96. }
  97. }
  98. return Cost;
  99. }
  100. bool PermanentsCondition(List<Permanent> targetPermanents)
  101. {
  102. if (targetPermanents == null)
  103. {
  104. return true;
  105. }
  106. else
  107. {
  108. if (targetPermanents.Count((targetPermanent) => targetPermanent != null) == 0)
  109. {
  110. return true;
  111. }
  112. }
  113. return false;
  114. }
  115. bool RootCondition(SelectCardEffect.Root root)
  116. {
  117. return true;
  118. }
  119. #region Before Pay Cost - Condition Effect
  120. if (timing == EffectTiming.BeforePayCost)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect(CostReductionEffectName, CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  125. activateClass.SetHashString("PlayCost-1_BT25_088");
  126. cardEffects.Add(activateClass);
  127. string EffectDescription()
  128. => "[Your Turn] [Once Per Turn] When any of your [Glowing Dawn] trait cards would be played, by trashing the bottom face-down card from under any of your Tamers, reduce the cost by 1.";
  129. bool CanNoSelect(Hashtable hashtable)
  130. {
  131. CardSource cardSource = CardEffectCommons.GetCardFromHashtable(hashtable);
  132. SelectCardEffect.Root root = SelectCardEffect.Root.None;
  133. if (CardEffectCommons.IsExistOnHand(cardSource))
  134. root = SelectCardEffect.Root.Hand;
  135. else if (CardEffectCommons.IsExistInAnyTrash(cardSource))
  136. root = SelectCardEffect.Root.Trash;
  137. else if (CardEffectCommons.IsExistDigivolutionCards(cardSource))
  138. root = SelectCardEffect.Root.DigivolutionCards;
  139. else if (CardEffectCommons.IsExistLinked(cardSource))
  140. root = SelectCardEffect.Root.LinkedCards;
  141. return cardSource != null
  142. && cardSource.PayingCost(root, null, checkAvailability: false) <= cardSource.Owner.MaxMemoryCost;
  143. }
  144. bool CanUseCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleArea(card)
  147. && CardEffectCommons.IsOwnerTurn(card)
  148. && CardEffectCommons.CanTriggerWhenPermanentWouldPlay(hashtable, CardCondition);
  149. }
  150. bool CanActivateCondition(Hashtable hashtable)
  151. {
  152. return CardEffectCommons.IsExistOnBattleArea(card)
  153. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource);
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable hashtable)
  156. {
  157. bool trash = false;
  158. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect1.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: TamerWithOneFaceDownSource,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: 1,
  165. canNoSelect: CanNoSelect(hashtable),
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: null,
  168. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect1.SetUpCustomMessage("Select 1 Tamer to trash 1 bottom face-down card from", "The opponent is selecting 1 Tamer to trash 1 bottom face-down card from");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  173. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanTrashCard));
  176. trash = true;
  177. }
  178. if (trash)
  179. {
  180. if (card.Owner.CanReduceCost(null, card))
  181. {
  182. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  183. }
  184. ChangeCostClass changeCostClass = new ChangeCostClass();
  185. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition1, card);
  186. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  187. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  188. bool CanUseCondition1(Hashtable _hashtable)
  189. {
  190. return true;
  191. }
  192. bool isUpDown()
  193. {
  194. return true;
  195. }
  196. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(hashtable));
  197. }
  198. else activateClass.RemoveUse();
  199. }
  200. }
  201. #endregion
  202. #region Reduce Play Cost - Not Shown
  203. if (timing == EffectTiming.None)
  204. {
  205. ChangeCostClass changeCostClass = new ChangeCostClass();
  206. changeCostClass.SetUpICardEffect("Play Cost -1", CanUseCondition, card);
  207. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => true, isChangePayingCost: () => true);
  208. changeCostClass.SetNotShowUI(true);
  209. cardEffects.Add(changeCostClass);
  210. bool CanUseCondition(Hashtable hashtable)
  211. {
  212. if (CardEffectCommons.IsExistOnBattleArea(card)
  213. && CardEffectCommons.IsOwnerTurn(card)
  214. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, TamerWithOneFaceDownSource))
  215. {
  216. ICardEffect activateClass = card.EffectList(EffectTiming.BeforePayCost).Find(cardEffect => cardEffect.EffectName == CostReductionEffectName);
  217. return activateClass != null
  218. && !card.cEntity_EffectController.isOverMaxCountPerTurn(activateClass, activateClass.MaxCountPerTurn);
  219. }
  220. return false;
  221. }
  222. bool isUpDown()
  223. {
  224. return true;
  225. }
  226. }
  227. #endregion
  228. #endregion
  229. #region Security Effect
  230. if (timing == EffectTiming.SecuritySkill)
  231. {
  232. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  233. }
  234. #endregion
  235. return cardEffects;
  236. }
  237. }
  238. }