BT25_090.cs 13 KB

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