AD1_017.cs 12 KB

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