BT25_088.cs 13 KB

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