BT25_087.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Thomas H. Norstein
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_087 : 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.OnAddHand)
  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 effects add cards to your opponent's hand, 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.CanTriggerWhenAddHand(hashtable, player => player == card.Owner.Enemy, cardEffect => cardEffect != null);
  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 When you would digivolve
  73. if (timing == EffectTiming.BeforePayCost)
  74. {
  75. ActivateClass activateClass = new ActivateClass();
  76. activateClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition, card);
  77. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  78. activateClass.SetHashString("BT25_087_YT");
  79. cardEffects.Add(activateClass);
  80. string EffectDescription()
  81. {
  82. return "[Your Turn] [Once Per Turn] When any of your Digimon would digivolve into a [DATA SQUAD] trait Digimon card, by trashing the bottom face-down card from under any of your Tamers, reduce the cost by 1.";
  83. }
  84. bool CardCondition(CardSource cardSource)
  85. {
  86. return cardSource.IsDigimon
  87. && cardSource.EqualsTraits("DATA SQUAD");
  88. }
  89. bool CanUseCondition(Hashtable hashtable)
  90. {
  91. return CardEffectCommons.IsExistOnBattleArea(card)
  92. && CardEffectCommons.IsOwnerTurn(card)
  93. && CardEffectCommons.CanTriggerWhenPermanentWouldDigivolve(hashtable, PermanentCondition, CardCondition);
  94. }
  95. bool CanActivateCondition(Hashtable hashtable)
  96. {
  97. return CardEffectCommons.IsExistOnBattleArea(card)
  98. && card.Owner.GetBattleAreaPermanents().Count(TamerWithOneFaceDownSource) >= 1;
  99. }
  100. bool PermanentCondition(Permanent permanent)
  101. {
  102. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  103. }
  104. bool TamerWithOneFaceDownSource(Permanent permanent)
  105. {
  106. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaTamer(permanent, card)
  107. && permanent.DigivolutionCards.Any(CanSelectTrashSourceCardCondition);
  108. }
  109. bool CanSelectTrashSourceCardCondition(CardSource cardSource)
  110. {
  111. return cardSource.IsFlipped;
  112. }
  113. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  114. {
  115. bool trashed = false;
  116. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  117. selectPermanentEffect1.SetUp(
  118. selectPlayer: card.Owner,
  119. canTargetCondition: TamerWithOneFaceDownSource,
  120. canTargetCondition_ByPreSelecetedList: null,
  121. canEndSelectCondition: null,
  122. maxCount: 1,
  123. canNoSelect: true,
  124. canEndNotMax: true,
  125. selectPermanentCoroutine: null,
  126. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  127. mode: SelectPermanentEffect.Mode.Custom,
  128. cardEffect: activateClass);
  129. 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");
  130. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  131. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  132. {
  133. if (permanents.Count == 1)
  134. {
  135. trashed = true;
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashDigivolutionCardsFromTopOrBottom(targetPermanent: permanents[0], trashCount: 1, isFromTop: false, activateClass: activateClass, CanSelectTrashSourceCardCondition));
  137. }
  138. }
  139. if (trashed)
  140. {
  141. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  142. ChangeCostClass changeCostClass = new ChangeCostClass();
  143. changeCostClass.SetUpICardEffect("Digivolution Cost -1", CanUseCondition1, card);
  144. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  145. card.Owner.UntilCalculateFixedCostEffect.Add((_timing) => changeCostClass);
  146. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ShowReducedCost(_hashtable));
  147. bool CanUseCondition1(Hashtable hashtable)
  148. {
  149. return true;
  150. }
  151. int ChangeCost(CardSource cardSource, int Cost, SelectCardEffect.Root root, List<Permanent> targetPermanents)
  152. {
  153. if (CardSourceCondition(cardSource))
  154. {
  155. if (RootCondition(root))
  156. {
  157. if (PermanentsCondition(targetPermanents))
  158. {
  159. Cost -= 1;
  160. }
  161. }
  162. }
  163. return Cost;
  164. }
  165. bool PermanentsCondition(List<Permanent> targetPermanents)
  166. {
  167. return targetPermanents != null
  168. && targetPermanents.Count(PermanentCondition) >= 1;
  169. }
  170. bool PermanentCondition(Permanent targetPermanent)
  171. {
  172. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(targetPermanent, card);
  173. }
  174. bool CardSourceCondition(CardSource cardSource)
  175. {
  176. return cardSource.EqualsTraits("DATA SQUAD");
  177. }
  178. bool RootCondition(SelectCardEffect.Root root)
  179. {
  180. return true;
  181. }
  182. bool isUpDown()
  183. {
  184. return true;
  185. }
  186. }
  187. }
  188. }
  189. #endregion
  190. #region Security Effect
  191. if (timing == EffectTiming.SecuritySkill)
  192. {
  193. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  194. }
  195. #endregion
  196. return cardEffects;
  197. }
  198. }
  199. }