BT25_090.cs 13 KB

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