AD1_017.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. // Dynasmon
  5. namespace DCGO.CardEffects.AD1
  6. {
  7. public class AD1_017 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Reduce Play Cost
  13. if (timing == EffectTiming.None)
  14. {
  15. ChangeCostClass changeCostClass = new ChangeCostClass();
  16. changeCostClass.SetUpICardEffect("Play Cost -5", CanUseCondition, card);
  17. changeCostClass.SetUpChangeCostClass(changeCostFunc: ChangeCost, cardSourceCondition: CardSourceCondition, rootCondition: RootCondition, isUpDown: isUpDown, isCheckAvailability: () => false, isChangePayingCost: () => true);
  18. changeCostClass.SetNotShowUI(true);
  19. cardEffects.Add(changeCostClass);
  20. bool CanUseCondition(Hashtable hashtable)
  21. {
  22. return CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, WouldPlayCondition) >= 4;
  23. }
  24. bool WouldPlayCondition(CardSource cardSource)
  25. {
  26. return cardSource.HasText("Lucemon")
  27. || cardSource.HasText("Witchelny");
  28. }
  29. int ChangeCost(CardSource cardSource, int cost, SelectCardEffect.Root root,
  30. List<Permanent> targetPermanents)
  31. {
  32. if (CardSourceCondition(cardSource) &&
  33. RootCondition(root) &&
  34. PermanentsCondition(targetPermanents))
  35. {
  36. cost -= 5;
  37. }
  38. return cost;
  39. }
  40. bool PermanentsCondition(List<Permanent> targetPermanents)
  41. {
  42. return targetPermanents == null || targetPermanents.Count(targetPermanent => targetPermanent != null) == 0;
  43. }
  44. bool CardSourceCondition(CardSource cardSource)
  45. {
  46. return cardSource == card;
  47. }
  48. bool RootCondition(SelectCardEffect.Root root)
  49. {
  50. return true;
  51. }
  52. bool isUpDown()
  53. {
  54. return true;
  55. }
  56. }
  57. #endregion
  58. #region Shared OP/WD
  59. string SharedEffectName() => "Trash sec to -6K DP enemy board for turn";
  60. string SharedEffectDescription(string tag) => $"[{tag}] By trashing your top or bottom security card, all of your opponent's Digimon get -6000 DP for the turn.";
  61. bool SharedCanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  64. && card.Owner.SecurityCards.Count >= 1;
  65. }
  66. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  67. {
  68. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  69. selectionElements.Add(new(message: $"From top", value: 1, spriteIndex: 0));
  70. selectionElements.Add(new(message: $"From bottom", value: 2, spriteIndex: 0));
  71. selectionElements.Add(new(message: $"Do not trash", value: 3, spriteIndex: 1));
  72. string selectPlayerMessage = "From which area do you select a card?";
  73. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  74. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  75. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  76. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  77. bool fromTop = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  78. if (doTrash)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  81. player: card.Owner,
  82. destroySecurityCount: 1,
  83. cardEffect: activateClass,
  84. fromTop: fromTop).DestroySecurity());
  85. bool PermanentCondition(Permanent permanent)
  86. {
  87. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  88. }
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDPPlayerEffect(
  90. permanentCondition: PermanentCondition,
  91. changeValue: -6000,
  92. effectDuration: EffectDuration.UntilEachTurnEnd,
  93. activateClass: activateClass));
  94. }
  95. }
  96. #endregion
  97. #region On Play
  98. if (timing == EffectTiming.OnEnterFieldAnyone)
  99. {
  100. ActivateClass activateClass = new ActivateClass();
  101. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  102. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  103. cardEffects.Add(activateClass);
  104. bool CanUseCondition(Hashtable hashtable)
  105. {
  106. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  107. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  108. }
  109. }
  110. #endregion
  111. #region When Digivolving
  112. if (timing == EffectTiming.OnEnterFieldAnyone)
  113. {
  114. ActivateClass activateClass = new ActivateClass();
  115. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  116. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  117. cardEffects.Add(activateClass);
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  121. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. }
  124. #endregion
  125. #region All Turns
  126. if (timing == EffectTiming.OnLoseSecurity)
  127. {
  128. ActivateClass activateClass = new ActivateClass();
  129. activateClass.SetUpICardEffect("May delete 1 enemy's lowest DP", CanUseCondition, card);
  130. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  131. activateClass.SetHashString("AD1_017_AT");
  132. cardEffects.Add(activateClass);
  133. string EffectDiscription()
  134. {
  135. return "[All Turns] [Once Per Turn] When your security stack is removed from, you may delete 1 of your opponent's lowest DP Digimon.";
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  140. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  141. }
  142. bool CanActivateCondition(Hashtable hashtable)
  143. {
  144. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  145. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  146. }
  147. bool CanSelectPermanentCondition(Permanent permanent)
  148. {
  149. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  150. && CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  153. {
  154. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  155. selectPermanentEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: CanSelectPermanentCondition,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. maxCount: 1,
  161. canNoSelect: false,
  162. canEndNotMax: false,
  163. selectPermanentCoroutine: null,
  164. afterSelectPermanentCoroutine: null,
  165. mode: SelectPermanentEffect.Mode.Destroy,
  166. cardEffect: activateClass);
  167. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  168. }
  169. }
  170. #endregion
  171. #region Security
  172. if (timing == EffectTiming.SecuritySkill)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Give 1 enemy Digimon <Sec A. -1>, -3K DP 1 enemy Digimon until end of your turn", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  177. activateClass.SetIsSecurityEffect(true);
  178. activateClass.SetIsDigimonEffect(true);
  179. cardEffects.Add(activateClass);
  180. string EffectDescription()
  181. {
  182. return "[Security] Give 1 of your opponent's Digimon <Security A. -1> for the turn. Then, 1 of their Digimon gets -3000 DP until your turn ends.";
  183. }
  184. bool CanUseCondition(Hashtable hashtable)
  185. {
  186. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  187. }
  188. bool CanActivateCondition(Hashtable hashtable)
  189. {
  190. return card.Owner.ExecutingCards.Contains(card);
  191. }
  192. bool CanSelectPermanentCondition(Permanent permanent)
  193. {
  194. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  195. }
  196. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  197. {
  198. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  199. selectPermanentEffect.SetUp(
  200. selectPlayer: card.Owner,
  201. canTargetCondition: CanSelectPermanentCondition,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canEndSelectCondition: null,
  204. maxCount: 1,
  205. canNoSelect: false,
  206. canEndNotMax: false,
  207. selectPermanentCoroutine: SelectPermanentCoroutine,
  208. afterSelectPermanentCoroutine: null,
  209. mode: SelectPermanentEffect.Mode.Custom,
  210. cardEffect: activateClass);
  211. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get <Security A. -1>.", "The opponent is selecting 1 Digimon that will get <Security A. -1>.");
  212. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  213. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  214. {
  215. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  216. targetPermanent: permanent,
  217. changeValue: -1,
  218. effectDuration: EffectDuration.UntilEachTurnEnd,
  219. activateClass: activateClass));
  220. }
  221. SelectPermanentEffect selectPermanentEffect2 = GManager.instance.GetComponent<SelectPermanentEffect>();
  222. selectPermanentEffect2.SetUp(
  223. selectPlayer: card.Owner,
  224. canTargetCondition: CanSelectPermanentCondition,
  225. canTargetCondition_ByPreSelecetedList: null,
  226. canEndSelectCondition: null,
  227. maxCount: 1,
  228. canNoSelect: false,
  229. canEndNotMax: false,
  230. selectPermanentCoroutine: SelectPermanentCoroutine2,
  231. afterSelectPermanentCoroutine: null,
  232. mode: SelectPermanentEffect.Mode.Custom,
  233. cardEffect: activateClass);
  234. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get -3000 DP.", "The opponent is selecting 1 Digimon that will get -3000 DP.");
  235. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  236. IEnumerator SelectPermanentCoroutine2(Permanent permanent)
  237. {
  238. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  239. targetPermanent: permanent,
  240. changeValue: -3000,
  241. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  242. activateClass: activateClass));
  243. }
  244. }
  245. }
  246. #endregion
  247. return cardEffects;
  248. }
  249. }
  250. }