BT23_056.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // WereGarurumon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_056 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasCSTraits
  18. && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel4;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  21. permanentCondition: PermanentCondition,
  22. digivolutionCost: 3,
  23. ignoreDigivolutionRequirement: false,
  24. card: card,
  25. condition: null)
  26. );
  27. }
  28. #endregion
  29. #region Blocker
  30. if (timing == EffectTiming.None)
  31. {
  32. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  33. }
  34. #endregion
  35. #region OP/WD Shared
  36. bool IsCsTamer(Permanent permanent)
  37. {
  38. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  39. && permanent.IsTamer
  40. && permanent.TopCard.HasCSTraits;
  41. }
  42. bool SharedCanSelectPermamentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  45. }
  46. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  47. {
  48. Permanent selectedPermanent = null;
  49. #region Select Permanent
  50. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  51. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermamentCondition));
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: SharedCanSelectPermamentCondition,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: maxCount,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: SelectPermanentCoroutine,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.Custom,
  63. cardEffect: activateClass);
  64. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  65. {
  66. selectedPermanent = permanent;
  67. yield return null;
  68. }
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to gain '[Start of Your Main Phase] This Digimon attacks'.", "The opponent is selecting 1 digimon to gain '[Start of Your Main Phase] This Digimon attacks'.");
  70. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  71. #endregion
  72. if (selectedPermanent != null)
  73. {
  74. #region Setup Attack on Start of Main Phase
  75. ActivateClass activateClass1 = new ActivateClass();
  76. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  77. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  78. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  79. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  82. }
  83. string EffectDiscription1()
  84. {
  85. return "[Start of Your Main Phase] Attack with this Digimon.";
  86. }
  87. bool CanUseCondition1(Hashtable hashtable1)
  88. {
  89. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  90. {
  91. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  92. {
  93. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  94. {
  95. return true;
  96. }
  97. }
  98. }
  99. return false;
  100. }
  101. bool CanActivateCondition1(Hashtable hashtable1)
  102. {
  103. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  104. {
  105. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  106. {
  107. if (selectedPermanent.CanAttack(activateClass1))
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  116. {
  117. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  118. {
  119. if (selectedPermanent.CanAttack(activateClass1))
  120. {
  121. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  122. selectAttackEffect.SetUp(
  123. attacker: selectedPermanent,
  124. canAttackPlayerCondition: () => true,
  125. defenderCondition: (permanent) => true,
  126. cardEffect: activateClass1);
  127. selectAttackEffect.SetCanNotSelectNotAttack();
  128. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  129. }
  130. }
  131. }
  132. ICardEffect GetCardEffect(EffectTiming _timing)
  133. {
  134. if (_timing == EffectTiming.OnStartMainPhase)
  135. {
  136. return activateClass1;
  137. }
  138. return null;
  139. }
  140. #endregion
  141. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  142. }
  143. }
  144. #endregion
  145. #region On Play
  146. if (timing == EffectTiming.OnEnterFieldAnyone)
  147. {
  148. ActivateClass activateClass = new ActivateClass();
  149. activateClass.SetUpICardEffect("Give 1 digimon '[Start of your main phase] this digimon attacks' ", CanUseCondition, card);
  150. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  151. cardEffects.Add(activateClass);
  152. string EffectDiscription()
  153. {
  154. return "[On Play] If you have a Tamer with the [CS] trait, give 1 of your opponent's Digimon '[Start of Your Main Phase] This Digimon attacks.' until their turn ends.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  159. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  164. && CardEffectCommons.HasMatchConditionPermanent(IsCsTamer)
  165. && CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermamentCondition);
  166. }
  167. }
  168. #endregion
  169. #region When Digivolving
  170. if (timing == EffectTiming.OnEnterFieldAnyone)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect("Give 1 digimon '[Start of your main phase] this digimon attacks' ", CanUseCondition, card);
  174. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  175. cardEffects.Add(activateClass);
  176. string EffectDiscription()
  177. {
  178. return "[When Digivolving] If you have a Tamer with the [CS] trait, give 1 of your opponent's Digimon '[Start of Your Main Phase] This Digimon attacks.' until their turn ends.";
  179. }
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  183. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  188. && CardEffectCommons.HasMatchConditionPermanent(IsCsTamer)
  189. && CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermamentCondition);
  190. }
  191. }
  192. #endregion
  193. #region All Turns - ESS
  194. if (timing == EffectTiming.OnAttackTargetChanged)
  195. {
  196. ActivateClass activateClass = new ActivateClass();
  197. activateClass.SetUpICardEffect("<De-Digivolve 1>", CanUseCondition, card);
  198. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  199. activateClass.SetHashString("Bt23_056_AT");
  200. activateClass.SetIsInheritedEffect(true);
  201. cardEffects.Add(activateClass);
  202. string EffectDiscription()
  203. {
  204. return "[All Turns] [Once Per Turn] When attack targets change, <De-Digivolve 1> 1 of your opponent's Digimon.";
  205. }
  206. bool CanUseCondition(Hashtable hashtable)
  207. {
  208. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  209. && CardEffectCommons.CanTriggerOnPermanentAttackTargetSwitch(hashtable, permanent => true);
  210. }
  211. bool CanActivateCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  214. }
  215. IEnumerator ActivateCoroutine(Hashtable hashtable)
  216. {
  217. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermamentCondition))
  218. {
  219. Permanent selectedPermanent = null;
  220. #region Select Permanent
  221. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  222. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermamentCondition));
  223. selectPermanentEffect.SetUp(
  224. selectPlayer: card.Owner,
  225. canTargetCondition: SharedCanSelectPermamentCondition,
  226. canTargetCondition_ByPreSelecetedList: null,
  227. canEndSelectCondition: null,
  228. maxCount: maxCount,
  229. canNoSelect: false,
  230. canEndNotMax: false,
  231. selectPermanentCoroutine: SelectPermanentCoroutine,
  232. afterSelectPermanentCoroutine: null,
  233. mode: SelectPermanentEffect.Mode.Custom,
  234. cardEffect: activateClass);
  235. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  236. {
  237. selectedPermanent = permanent;
  238. yield return null;
  239. }
  240. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to <De-Digivolve>.", "The opponent is selecting 1 digimon to <De-Digivolve>.");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. #endregion
  243. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  244. permanent: selectedPermanent,
  245. DegenerationCount: 1,
  246. cardEffect: activateClass).Degeneration()
  247. );
  248. }
  249. }
  250. }
  251. #endregion
  252. return cardEffects;
  253. }
  254. }
  255. }