ST22_10.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. //Amethyst Mandala
  5. namespace DCGO.CardEffects.ST22
  6. {
  7. public class ST22_10 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region WTFS/Security Shared
  13. bool SharedIsOpponentDigimon(Permanent permanent) => CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  14. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  15. {
  16. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon))
  17. {
  18. Permanent selectedPermament = null;
  19. #region Select Permanent
  20. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOpponentsPermanentCount(card, SharedIsOpponentDigimon));
  21. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  22. selectPermanentEffect.SetUp(
  23. selectPlayer: card.Owner,
  24. canTargetCondition: SharedIsOpponentDigimon,
  25. canTargetCondition_ByPreSelecetedList: null,
  26. canEndSelectCondition: null,
  27. maxCount: maxCount,
  28. canNoSelect: false,
  29. canEndNotMax: false,
  30. selectPermanentCoroutine: SelectPermanentCoroutine,
  31. afterSelectPermanentCoroutine: null,
  32. mode: SelectPermanentEffect.Mode.Custom,
  33. cardEffect: activateClass);
  34. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  35. {
  36. selectedPermament = permanent;
  37. yield return null;
  38. }
  39. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to -9K DP", "The opponent is selecting 1 digimon to -9K DP");
  40. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  41. #endregion
  42. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(
  43. CardEffectCommons.ChangeDigimonDP(selectedPermament, -9000, EffectDuration.UntilEachTurnEnd, activateClass));
  44. }
  45. }
  46. #endregion
  47. #region When trashed from security
  48. if (timing == EffectTiming.OnDiscardSecurity)
  49. {
  50. ActivateClass activateClass = new ActivateClass();
  51. activateClass.SetUpICardEffect("-9K DP to 1 opponent digimon", CanUseCondition, card);
  52. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  53. cardEffects.Add(activateClass);
  54. string EffectDiscription()
  55. {
  56. return "When effects trash this card from the security stack, 1 of your opponent's Digimon gets -9000 DP for the turn.";
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card);
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return CardEffectCommons.IsExistOnTrash(card)
  65. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon);
  66. }
  67. }
  68. #endregion
  69. #region Security
  70. if (timing == EffectTiming.SecuritySkill)
  71. {
  72. ActivateClass activateClass = new ActivateClass();
  73. activateClass.SetUpICardEffect("-9K DP to 1 opponent digimon", CanUseCondition, card);
  74. activateClass.SetUpActivateClass(null, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDiscription());
  75. activateClass.SetIsSecurityEffect(true);
  76. cardEffects.Add(activateClass);
  77. string EffectDiscription()
  78. => "[Security] 1 of your opponent's Digimon gets -9000 DP for the turn.";
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card)
  82. && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedIsOpponentDigimon);
  83. }
  84. }
  85. #endregion
  86. #region Security - All Turns
  87. if (timing == EffectTiming.WhenRemoveField)
  88. {
  89. List<Permanent> removedPermanents = new List<Permanent>();
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("By trashing this card, 1 digimon doesn't leave", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  93. activateClass.SetIsSecurityEffect(true);
  94. cardEffects.Add(activateClass);
  95. string EffectDiscription()
  96. => "[Security] [All Turns] When any of your Digimon with [Renamon], [Kyubimon], [Taomon] or [Sakuyamon] in their names would leave the battle area other than by battle, by trashing this card, 1 of those Digimon doesn't leave.";
  97. bool CanUseCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.IsExistInSecurity(card, false)
  100. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, CanSelectPermamentCondition)
  101. && !CardEffectCommons.IsByBattle(hashtable);
  102. }
  103. bool CanActivateCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.IsExistInSecurity(card, false);
  106. }
  107. bool CanSelectPermamentCondition(Permanent permanent)
  108. {
  109. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  110. && (permanent.TopCard.ContainsCardName("Renamon") ||
  111. permanent.TopCard.ContainsCardName("Kyubimon") ||
  112. permanent.TopCard.ContainsCardName("Taomon") ||
  113. permanent.TopCard.ContainsCardName("Sakuyamon"));
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. #region Trash Card from security
  118. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(card.Owner, card, activateClass).DestroySecurity());
  119. #endregion
  120. #region Prevent 1 Digimon Removal
  121. Permanent selectedPermanent = null;
  122. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  123. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  124. selectPermanentEffect.SetUp(
  125. selectPlayer: card.Owner,
  126. canTargetCondition: CanSelectPermamentCondition,
  127. canTargetCondition_ByPreSelecetedList: null,
  128. canEndSelectCondition: null,
  129. maxCount: maxCount,
  130. canNoSelect: false,
  131. canEndNotMax: false,
  132. selectPermanentCoroutine: SelectPermanentCoroutine,
  133. afterSelectPermanentCoroutine: null,
  134. mode: SelectPermanentEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  137. {
  138. selectedPermanent = permanent;
  139. yield return null;
  140. }
  141. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to prevent removal.", "The opponent is selecting 1 Digimon to prevent removal.");
  142. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  143. if (selectedPermanent != null)
  144. {
  145. selectedPermanent.HideDeleteEffect();
  146. selectedPermanent.HideHandBounceEffect();
  147. selectedPermanent.HideDeckBounceEffect();
  148. selectedPermanent.HideWillRemoveFieldEffect();
  149. selectedPermanent.DestroyingEffect = null;
  150. selectedPermanent.HandBounceEffect = null;
  151. selectedPermanent.LibraryBounceEffect = null;
  152. selectedPermanent.willBeRemoveField = false;
  153. }
  154. #endregion
  155. }
  156. }
  157. #endregion
  158. #region Main
  159. if (timing == EffectTiming.OptionSkill)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("Draw 1. Then, place this card face up as the bottom security card.", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  164. cardEffects.Add(activateClass);
  165. string EffectDiscription()
  166. => "[Main] <Draw 1>. Then, place this card face up as the bottom security card.";
  167. bool CanUseCondition(Hashtable hashtable)
  168. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  169. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  170. {
  171. #region Draw 1
  172. if (card.Owner.LibraryCards.Count >= 1)
  173. {
  174. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  175. }
  176. #endregion
  177. #region Place in security
  178. if (card.Owner.CanAddSecurity(activateClass))
  179. {
  180. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  181. card, toTop: false, faceUp: true));
  182. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  183. .CreateRecoveryEffect(card.Owner));
  184. yield return ContinuousController.instance.StartCoroutine(new IAddSecurity(card).AddSecurity());
  185. }
  186. #endregion
  187. }
  188. }
  189. #endregion
  190. return cardEffects;
  191. }
  192. }
  193. }