BT23_059.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //Justimon: Blitz Arm
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_059 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. //[Justimon: Accel Arm]/[Justimon: Critical Arm]: Cost 1
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Justimon: Accel Arm") ||
  19. targetPermanent.TopCard.EqualsCardName("Justimon: Critical Arm");
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false,
  23. card: card, condition: null));
  24. }
  25. // Lv.5 w/[CS] trait: Cost 3
  26. if (timing == EffectTiming.None)
  27. {
  28. bool PermanentCondition(Permanent targetPermanent)
  29. {
  30. return targetPermanent.TopCard.IsLevel5 &&
  31. targetPermanent.TopCard.HasCSTraits;
  32. }
  33. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  34. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  35. card: card, condition: null));
  36. }
  37. #endregion
  38. #region Blocker
  39. if (timing == EffectTiming.None)
  40. {
  41. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  42. isInheritedEffect: false,
  43. card: card,
  44. condition: null));
  45. }
  46. #endregion
  47. #region OP/WD Shared
  48. string SharedEffectDiscription(string tag)
  49. {
  50. return $"[{tag}] By trashing 1 Option card in the battle area, delete 1 of your opponent's Digimon with the lowest play cost.";
  51. }
  52. bool IsOptionCard(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent) &&
  55. permanent.IsOption;
  56. }
  57. bool SharedCanActivateCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  60. CardEffectCommons.HasMatchConditionPermanent(IsOptionCard);
  61. }
  62. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  63. {
  64. bool SelectOpponentsDigimon(Permanent permanent)
  65. {
  66. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  67. permanent.TopCard.HasPlayCost &&
  68. CardEffectCommons.IsMinCost(permanent, card.Owner.Enemy, true);
  69. }
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: IsOptionCard,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: false,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 Option to trash.",
  84. "The opponent is selecting 1 Option to trash.");
  85. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  86. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  89. targetPermanents: new List<Permanent>() { permanent },
  90. activateClass: activateClass,
  91. successProcess: permanents => SuccessProcess(),
  92. failureProcess: null));
  93. }
  94. IEnumerator SuccessProcess()
  95. {
  96. if (CardEffectCommons.HasMatchConditionPermanent(SelectOpponentsDigimon))
  97. {
  98. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  99. selectPermanentEffect.SetUp(
  100. selectPlayer: card.Owner,
  101. canTargetCondition: SelectOpponentsDigimon,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. maxCount: 1,
  105. canNoSelect: false,
  106. canEndNotMax: false,
  107. selectPermanentCoroutine: null,
  108. afterSelectPermanentCoroutine: null,
  109. mode: SelectPermanentEffect.Mode.Destroy,
  110. cardEffect: activateClass);
  111. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  112. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  113. }
  114. }
  115. }
  116. #endregion
  117. #region On Play
  118. if (timing == EffectTiming.OnEnterFieldAnyone)
  119. {
  120. ActivateClass activateClass = new ActivateClass();
  121. activateClass.SetUpICardEffect("By trashing 1 option card, delete 1 Digimon", CanUseCondition, card);
  122. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDiscription("On Play"));
  123. activateClass.SetHashString("OPWDWA_BT23-059");
  124. cardEffects.Add(activateClass);
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  128. CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  129. }
  130. }
  131. #endregion
  132. #region When Digivolving
  133. if (timing == EffectTiming.OnEnterFieldAnyone)
  134. {
  135. ActivateClass activateClass = new ActivateClass();
  136. activateClass.SetUpICardEffect("By trashing 1 option card, delete 1 Digimon", CanUseCondition, card);
  137. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDiscription("When Digivolving"));
  138. activateClass.SetHashString("OPWDWA_BT23-059");
  139. cardEffects.Add(activateClass);
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  143. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  144. }
  145. }
  146. #endregion
  147. #region When Attacking
  148. if (timing == EffectTiming.OnAllyAttack)
  149. {
  150. ActivateClass activateClass = new ActivateClass();
  151. activateClass.SetUpICardEffect("By trashing 1 option card, delete 1 Digimon", CanUseCondition, card);
  152. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, true, SharedEffectDiscription("When Attacking"));
  153. activateClass.SetHashString("OPWDWA_BT23-059");
  154. cardEffects.Add(activateClass);
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  158. CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  159. }
  160. }
  161. #endregion
  162. #region All Turns - OPT
  163. if (timing == EffectTiming.OnDestroyedAnyone)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("Unsuspend, unaffected by opponents Digimon effects", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  168. activateClass.SetHashString("BT23_059_AT");
  169. cardEffects.Add(activateClass);
  170. string EffectDiscription()
  171. {
  172. return "[All Turns] [Once Per Turn] When Option cards in the battle area are trashed, this Digimon unsuspends. Then, your opponent's Digimon's effects don't affect this Digimon for the turn.";
  173. }
  174. bool CanUseCondition(Hashtable hashtable)
  175. {
  176. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  177. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass);
  178. }
  179. bool CanActivateCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  182. }
  183. bool PermanentCondition(Permanent permanent)
  184. {
  185. return permanent.IsOption;
  186. }
  187. IEnumerator ActivateCoroutine(Hashtable hashtable)
  188. {
  189. Permanent selectedPermanent = card.PermanentOfThisCard();
  190. if (selectedPermanent != null)
  191. {
  192. yield return ContinuousController.instance.StartCoroutine(
  193. new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent }, activateClass).Unsuspend());
  194. #region Cant Be Effected Functions
  195. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().BuffSE);
  196. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  197. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  198. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's effect", CanUseCondition1, card);
  199. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  200. selectedPermanent.UntilEachTurnEndEffects.Add((_timing) => canNotAffectedClass);
  201. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  202. bool CanUseCondition1(Hashtable hashtable)
  203. {
  204. if (selectedPermanent.TopCard != null)
  205. {
  206. return true;
  207. }
  208. return false;
  209. }
  210. bool CardCondition(CardSource cardSource)
  211. {
  212. if (selectedPermanent.TopCard != null)
  213. {
  214. if (selectedPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(selectedPermanent))
  215. {
  216. if (cardSource == selectedPermanent.TopCard)
  217. {
  218. return true;
  219. }
  220. }
  221. }
  222. return false;
  223. }
  224. bool SkillCondition(ICardEffect cardEffect)
  225. {
  226. if (cardEffect != null)
  227. {
  228. if (cardEffect.EffectSourceCard != null)
  229. {
  230. if (cardEffect.EffectSourceCard.Owner == card.Owner.Enemy)
  231. {
  232. return cardEffect.EffectSourceCard.IsDigimon;
  233. }
  234. }
  235. }
  236. return false;
  237. }
  238. #endregion
  239. }
  240. }
  241. }
  242. #endregion
  243. return cardEffects;
  244. }
  245. }
  246. }