BT23_055.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. //Cyberdramon
  4. namespace DCGO.CardEffects.BT23
  5. {
  6. public class BT23_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.IsLevel4 &&
  17. targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region OP/WD Shared
  25. string SharedEffectDiscription(string tag)
  26. {
  27. return $"[{tag}] Delete 1 of your opponent's Digimon with a play cost of 5 or less.";
  28. }
  29. bool SharedCanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  32. }
  33. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  34. {
  35. bool SelectOpponentsDigimon(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  38. permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 5;
  39. }
  40. if (CardEffectCommons.HasMatchConditionPermanent(SelectOpponentsDigimon))
  41. {
  42. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  43. selectPermanentEffect.SetUp(
  44. selectPlayer: card.Owner,
  45. canTargetCondition: SelectOpponentsDigimon,
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. maxCount: 1,
  49. canNoSelect: false,
  50. canEndNotMax: false,
  51. selectPermanentCoroutine: null,
  52. afterSelectPermanentCoroutine: null,
  53. mode: SelectPermanentEffect.Mode.Destroy,
  54. cardEffect: activateClass);
  55. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  56. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  57. }
  58. }
  59. #endregion
  60. #region On Play
  61. if (timing == EffectTiming.OnEnterFieldAnyone)
  62. {
  63. ActivateClass activateClass = new ActivateClass();
  64. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  65. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDiscription("On Play"));
  66. cardEffects.Add(activateClass);
  67. bool CanUseCondition(Hashtable hashtable)
  68. {
  69. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  70. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  71. }
  72. }
  73. #endregion
  74. #region When Digivolving
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Delete 1 Digimon", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDiscription("When Digivolving"));
  80. cardEffects.Add(activateClass);
  81. bool CanUseCondition(Hashtable hashtable)
  82. {
  83. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  84. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  85. }
  86. }
  87. #endregion
  88. #region All Turns - OPT
  89. if (timing == EffectTiming.WhenRemoveField)
  90. {
  91. ActivateClass activateClass = new ActivateClass();
  92. activateClass.SetUpICardEffect("By trashing 1 of your Option cards, protect this digimon", CanUseCondition, card);
  93. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  94. activateClass.SetHashString("AT_BT23_055");
  95. cardEffects.Add(activateClass);
  96. string EffectDiscription()
  97. {
  98. return "[All Turns] [Once Per Turn] When this Digimon would leave the battle area, by trashing 1 of your Option cards in the battle area, it doesn't leave.";
  99. }
  100. bool IsOptionCard(Permanent permanent)
  101. {
  102. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  103. permanent.IsOption;
  104. }
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  108. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  109. }
  110. bool CanActivateCondition(Hashtable hashtable)
  111. {
  112. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  113. CardEffectCommons.HasMatchConditionPermanent(IsOptionCard);
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. Permanent selectedPermanent = card.PermanentOfThisCard();
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: IsOptionCard,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: 1,
  125. canNoSelect: false,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: SelectPermanentCoroutine,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. selectPermanentEffect.SetUpCustomMessage("Select 1 Option to trash.",
  132. "The opponent is selecting 1 Option to trash.");
  133. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  134. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  135. {
  136. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  137. targetPermanents: new List<Permanent>() { permanent },
  138. activateClass: activateClass,
  139. successProcess: permanents => SuccessProcess(),
  140. failureProcess: null));
  141. }
  142. IEnumerator SuccessProcess()
  143. {
  144. selectedPermanent.willBeRemoveField = false;
  145. selectedPermanent.HideDeleteEffect();
  146. selectedPermanent.HideHandBounceEffect();
  147. selectedPermanent.HideDeckBounceEffect();
  148. selectedPermanent.HideWillRemoveFieldEffect();
  149. yield return null;
  150. }
  151. }
  152. }
  153. #endregion
  154. #region All Turns - OPT - ESS
  155. if (timing == EffectTiming.WhenRemoveField)
  156. {
  157. ActivateClass activateClass = new ActivateClass();
  158. activateClass.SetUpICardEffect("By trashing 1 of your Option cards, protect this digimon", CanUseCondition, card);
  159. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  160. activateClass.SetIsInheritedEffect(true);
  161. activateClass.SetHashString("ATESS_BT23_055");
  162. cardEffects.Add(activateClass);
  163. string EffectDiscription()
  164. {
  165. return "[All Turns] [Once Per Turn] When this Digimon with [Cyberdramon] or [Justimon] in its name or the [CS] trait would leave the battle area, by trashing 1 of your Option cards in the battle area, it doesn't leave.";
  166. }
  167. bool IsOptionCard(Permanent permanent)
  168. {
  169. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card) &&
  170. permanent.IsOption;
  171. }
  172. bool RemovedPermanent(Permanent permanent)
  173. {
  174. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  175. permanent == card.PermanentOfThisCard() &&
  176. (permanent.TopCard.ContainsCardName("Cyberdramon") || permanent.TopCard.ContainsCardName("Justimon") || permanent.TopCard.HasCSTraits);
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  181. CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, RemovedPermanent);
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  186. CardEffectCommons.HasMatchConditionPermanent(IsOptionCard);
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable hashtable)
  189. {
  190. Permanent selectedPermanent = null;
  191. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  192. selectPermanentEffect.SetUp(
  193. selectPlayer: card.Owner,
  194. canTargetCondition: IsOptionCard,
  195. canTargetCondition_ByPreSelecetedList: null,
  196. canEndSelectCondition: null,
  197. maxCount: 1,
  198. canNoSelect: false,
  199. canEndNotMax: false,
  200. selectPermanentCoroutine: SelectPermanentCoroutine,
  201. afterSelectPermanentCoroutine: null,
  202. mode: SelectPermanentEffect.Mode.Custom,
  203. cardEffect: activateClass);
  204. selectPermanentEffect.SetUpCustomMessage("Select 1 Option to trash.",
  205. "The opponent is selecting 1 Option to trash.");
  206. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  207. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  208. {
  209. selectedPermanent = permanent;
  210. yield return null;
  211. }
  212. if(selectedPermanent != null)
  213. {
  214. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  215. targetPermanents: new List<Permanent>() { selectedPermanent },
  216. activateClass: activateClass,
  217. successProcess: permanents => SuccessProcess(),
  218. failureProcess: null));
  219. }
  220. IEnumerator SuccessProcess()
  221. {
  222. Permanent cardPermanent = card.PermanentOfThisCard();
  223. cardPermanent.willBeRemoveField = false;
  224. cardPermanent.HideDeleteEffect();
  225. cardPermanent.HideHandBounceEffect();
  226. cardPermanent.HideDeckBounceEffect();
  227. cardPermanent.HideWillRemoveFieldEffect();
  228. yield return null;
  229. }
  230. }
  231. }
  232. #endregion
  233. return cardEffects;
  234. }
  235. }
  236. }