BT25_043.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Habakirimon/Habakiri
  5. namespace DCGO.CardEffects.BT25
  6. {
  7. public class BT25_043 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digimon Effects
  13. #region Alt Digivolution
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent permanent)
  17. {
  18. return permanent.TopCard.HasGlowingDawnTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 5));
  21. }
  22. #endregion
  23. #region Shared WD/WA
  24. string SharedHashString = "BT25_043_WD_WA";
  25. string SharedEffectName = "<Recovery +1>, by trashing top sec of player with most sec cards, unsuspend";
  26. CardEffectFactory.ActivateClassesForSharedEffects
  27. (ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. optional: false,
  32. maxCountPerTurn: 1,
  33. hashValue: SharedHashString,
  34. whenDigivolving: true,
  35. whenAttacking: true);
  36. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] <Recovery +1>. Then, by trashing the top security card of 1 player with the most security cards, this Digimon unsuspends.";
  37. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  38. {
  39. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  40. bool validOwnerSecurity = card.Owner.SecurityCards.Count > 0 && card.Owner.SecurityCards.Count >= card.Owner.Enemy.SecurityCards.Count;
  41. bool validEnemySecurity = card.Owner.Enemy.SecurityCards.Count > 0 && card.Owner.Enemy.SecurityCards.Count >= card.Owner.SecurityCards.Count;
  42. if (validOwnerSecurity || validEnemySecurity)
  43. {
  44. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  45. if (validOwnerSecurity)
  46. {
  47. selectionElements.Add(new(message: $"Trash your own top security card", value: 1, spriteIndex: 0));
  48. }
  49. if (validEnemySecurity)
  50. {
  51. selectionElements.Add(new(message: $"Trash your opponent's top security card", value: 2, spriteIndex: 0));
  52. }
  53. selectionElements.Add(new(message: $"Don't trash security", value: 3, spriteIndex: 1));
  54. string selectPlayerMessage = "Will you trash 1 player's security to unsuspend?";
  55. string notSelectPlayerMessage = "The opponent is choosing if they will trash a security.";
  56. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  57. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  58. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  59. bool ownSecurity = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  60. if (doTrash)
  61. {
  62. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  63. player: ownSecurity ? card.Owner : card.Owner.Enemy,
  64. trashAmount: 1,
  65. activateClass: activateClass,
  66. fromTop: true,
  67. successProcess: SuccessProcess,
  68. failureProcess: null
  69. ));
  70. IEnumerator SuccessProcess(List<CardSource> cardSources)
  71. {
  72. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  73. }
  74. }
  75. }
  76. }
  77. #endregion
  78. #region All Turns
  79. if (timing == EffectTiming.WhenRemoveField)
  80. {
  81. ActivateClass activateClass = new ActivateClass();
  82. activateClass.SetUpICardEffect("Trash your top sec to prevent them from leaving", CanUseCondition, card);
  83. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  84. activateClass.SetHashString("BT25_043_AT");
  85. cardEffects.Add(activateClass);
  86. string EffectDescription()
  87. {
  88. return
  89. "[All Turns][Once Per Turn] When any of your [Glowing Dawn] trait Digimon would leave the battle area, by trashing your top security card, they don't leave.";
  90. }
  91. bool PermanentCondition(Permanent permanent)
  92. {
  93. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  94. && permanent.TopCard.HasGlowingDawnTraits;
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  99. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  100. }
  101. bool CanActivateCondition(Hashtable hashtable)
  102. {
  103. return CardEffectCommons.IsExistOnBattleArea(card)
  104. && card.Owner.SecurityCards.Count >= 1;
  105. }
  106. IEnumerator ActivateCoroutine(Hashtable hashtable)
  107. {
  108. List<Permanent> removedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable);
  109. removedPermanents = removedPermanents.Filter(PermanentCondition);
  110. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  111. player: card.Owner,
  112. destroySecurityCount: 1,
  113. cardEffect: activateClass,
  114. fromTop: true).DestroySecurity());
  115. foreach (Permanent permanent in removedPermanents)
  116. {
  117. permanent.willBeRemoveField = false;
  118. permanent.HideDeleteEffect();
  119. permanent.HideHandBounceEffect();
  120. permanent.HideDeckBounceEffect();
  121. permanent.HideWillRemoveFieldEffect();
  122. }
  123. }
  124. }
  125. #endregion
  126. #endregion
  127. #region Option Effects
  128. #region Ignore Colour Requirement
  129. if (timing == EffectTiming.None)
  130. {
  131. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  132. bool CardCondition(CardSource cardSource)
  133. {
  134. return cardSource.HasGlowingDawnTraits;
  135. }
  136. }
  137. #endregion
  138. #region Main
  139. if (timing == EffectTiming.OptionSkill)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("1 enemy Digimon gets -8K DP for turn, then by trashing your top sec, all enemy digimon get -5K DP for turn", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  144. cardEffects.Add(activateClass);
  145. string EffectDescription()
  146. => "[Main] 1 of your opponent's Digimon gets -8000 DP for the turn. Then, by trashing your top security card, all of your opponent's Digimon get -5000 DP for the turn.";
  147. bool CanUseCondition(Hashtable hashtable)
  148. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  149. bool CanSelectPermanentCondition(Permanent permanent)
  150. {
  151. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  152. }
  153. IEnumerator ActivateCoroutine(Hashtable hashtable)
  154. {
  155. #region DP minus single target
  156. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  157. {
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: 1,
  165. canNoSelect: false,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to -8K DP", "The opponent is selecting 1 Digimon to -8K DP");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. if (permanent != null) yield return ContinuousController.instance.StartCoroutine(
  176. CardEffectCommons.ChangeDigimonDP(permanent, -8000, EffectDuration.UntilEachTurnEnd, activateClass));
  177. }
  178. }
  179. #endregion
  180. #region DP minus enemy board
  181. if (card.Owner.SecurityCards.Count >= 1)
  182. {
  183. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  184. {
  185. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  186. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  187. };
  188. string selectPlayerMessage = "Will you trash your top security card to give all enemy Digimon -5K DP for turn?";
  189. string notSelectPlayerMessage = "The opponent is choosing whether or not to trash their top security card to give all your Digimon -5K DP for turn.";
  190. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  191. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  192. bool trash = GManager.instance.userSelectionManager.SelectedBoolValue;
  193. if (trash)
  194. {
  195. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  196. player: card.Owner,
  197. destroySecurityCount: 1,
  198. cardEffect: activateClass,
  199. fromTop: true).DestroySecurity());
  200. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  201. permanentCondition: CanSelectPermanentCondition,
  202. changeValue: -5000,
  203. effectDuration: EffectDuration.UntilEachTurnEnd,
  204. activateClass: activateClass));
  205. }
  206. }
  207. #endregion
  208. }
  209. }
  210. #endregion
  211. #region Arts Digivolution
  212. if (timing == EffectTiming.None)
  213. {
  214. cardEffects.Add(CardEffectFactory.ArtsDigivolveEffect(card));
  215. }
  216. #endregion
  217. #endregion
  218. return cardEffects;
  219. }
  220. }
  221. }