BT21_057.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. //Greymon
  7. public class BT21_057 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolve Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 3 && (targetPermanent.TopCard.ContainsCardName("Agumon") || targetPermanent.TopCard.EqualsTraits("ADVENTURE"));
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Forces 1 opponent Digimon attack Start of Main Phase", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[On Play] If you have [Tai Kamiya] or a Tamer with the [ADVENTURE] trait, give 1 of your opponent's Digimon \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  32. }
  33. bool PermanentCondition(Permanent permanent)
  34. {
  35. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  36. {
  37. if (permanent.TopCard.EqualsCardName("Tai Kamiya"))
  38. {
  39. return true;
  40. }
  41. if (permanent.IsTamer & permanent.TopCard.EqualsTraits("ADVENTURE"))
  42. {
  43. return true;
  44. }
  45. }
  46. return false;
  47. }
  48. bool CanSelectPermanentCondition(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  61. {
  62. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  71. {
  72. Permanent selectedPermanent = null;
  73. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  74. {
  75. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  76. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  77. selectPermanentEffect.SetUp(
  78. selectPlayer: card.Owner,
  79. canTargetCondition: CanSelectPermanentCondition,
  80. canTargetCondition_ByPreSelecetedList: null,
  81. canEndSelectCondition: null,
  82. maxCount: maxCount,
  83. canNoSelect: false,
  84. canEndNotMax: false,
  85. selectPermanentCoroutine: SelectPermanentCoroutine,
  86. afterSelectPermanentCoroutine: null,
  87. mode: SelectPermanentEffect.Mode.Custom,
  88. cardEffect: activateClass);
  89. selectPermanentEffect.SetUpCustomMessage(
  90. $"Select 1 Digimon that will get effects.",
  91. $"The opponent is selecting 1 Digimon that will get effects.");
  92. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  93. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  94. {
  95. selectedPermanent = permanent;
  96. yield return null;
  97. }
  98. if (selectedPermanent != null)
  99. {
  100. ActivateClass activateClass1 = new ActivateClass();
  101. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  102. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  103. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  104. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  105. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  106. {
  107. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  108. }
  109. string EffectDiscription1()
  110. {
  111. return "[Start of Your Main Phase] Attack with this Digimon.";
  112. }
  113. bool CanUseCondition1(Hashtable hashtable1)
  114. {
  115. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  116. {
  117. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  118. {
  119. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  120. {
  121. return true;
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanActivateCondition1(Hashtable hashtable1)
  128. {
  129. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  130. {
  131. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  132. {
  133. if (selectedPermanent.CanAttack(activateClass1))
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. return false;
  140. }
  141. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  142. {
  143. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  144. {
  145. if (selectedPermanent.CanAttack(activateClass1))
  146. {
  147. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  148. selectAttackEffect.SetUp(
  149. attacker: selectedPermanent,
  150. canAttackPlayerCondition: () => true,
  151. defenderCondition: (permanent) => true,
  152. cardEffect: activateClass1);
  153. selectAttackEffect.SetCanNotSelectNotAttack();
  154. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  155. }
  156. }
  157. }
  158. ICardEffect GetCardEffect(EffectTiming _timing)
  159. {
  160. if (_timing == EffectTiming.OnStartMainPhase)
  161. {
  162. return activateClass1;
  163. }
  164. return null;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. #endregion
  171. #region When Digivolving
  172. if (timing == EffectTiming.OnEnterFieldAnyone)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Forces 1 opponent Digimon attack Start of Main Phase", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  177. cardEffects.Add(activateClass);
  178. string EffectDiscription()
  179. {
  180. return "[When Digivolving] If you have [Tai Kamiya] or a Tamer with the [ADVENTURE] trait, give 1 of your opponent's Digimon \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  181. }
  182. bool PermanentCondition(Permanent permanent)
  183. {
  184. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  185. {
  186. if (permanent.TopCard.EqualsCardName("Tai Kamiya"))
  187. {
  188. return true;
  189. }
  190. if (permanent.IsTamer & permanent.TopCard.EqualsTraits("ADVENTURE"))
  191. {
  192. return true;
  193. }
  194. }
  195. return false;
  196. }
  197. bool CanSelectPermanentCondition(Permanent permanent)
  198. {
  199. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleArea(card))
  208. {
  209. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  210. {
  211. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  212. {
  213. return true;
  214. }
  215. }
  216. }
  217. return false;
  218. }
  219. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  220. {
  221. Permanent selectedPermanent = null;
  222. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  223. {
  224. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  225. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  226. selectPermanentEffect.SetUp(
  227. selectPlayer: card.Owner,
  228. canTargetCondition: CanSelectPermanentCondition,
  229. canTargetCondition_ByPreSelecetedList: null,
  230. canEndSelectCondition: null,
  231. maxCount: maxCount,
  232. canNoSelect: false,
  233. canEndNotMax: false,
  234. selectPermanentCoroutine: SelectPermanentCoroutine,
  235. afterSelectPermanentCoroutine: null,
  236. mode: SelectPermanentEffect.Mode.Custom,
  237. cardEffect: activateClass);
  238. selectPermanentEffect.SetUpCustomMessage(
  239. $"Select 1 Digimon that will get effects.",
  240. $"The opponent is selecting 1 Digimon that will get effects.");
  241. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  242. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  243. {
  244. selectedPermanent = permanent;
  245. yield return null;
  246. }
  247. if (selectedPermanent != null)
  248. {
  249. ActivateClass activateClass1 = new ActivateClass();
  250. activateClass1.SetUpICardEffect("Attack with this Digimon", CanUseCondition1, selectedPermanent.TopCard);
  251. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDiscription1());
  252. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  253. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  254. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  257. }
  258. string EffectDiscription1()
  259. {
  260. return "[Start of Your Main Phase] Attack with this Digimon.";
  261. }
  262. bool CanUseCondition1(Hashtable hashtable1)
  263. {
  264. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  265. {
  266. if (selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent))
  267. {
  268. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner)
  269. {
  270. return true;
  271. }
  272. }
  273. }
  274. return false;
  275. }
  276. bool CanActivateCondition1(Hashtable hashtable1)
  277. {
  278. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  279. {
  280. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  281. {
  282. if (selectedPermanent.CanAttack(activateClass1))
  283. {
  284. return true;
  285. }
  286. }
  287. }
  288. return false;
  289. }
  290. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  291. {
  292. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent))
  293. {
  294. if (selectedPermanent.CanAttack(activateClass1))
  295. {
  296. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  297. selectAttackEffect.SetUp(
  298. attacker: selectedPermanent,
  299. canAttackPlayerCondition: () => true,
  300. defenderCondition: (permanent) => true,
  301. cardEffect: activateClass1);
  302. selectAttackEffect.SetCanNotSelectNotAttack();
  303. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  304. }
  305. }
  306. }
  307. ICardEffect GetCardEffect(EffectTiming _timing)
  308. {
  309. if (_timing == EffectTiming.OnStartMainPhase)
  310. {
  311. return activateClass1;
  312. }
  313. return null;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. #endregion
  320. #region Reboot Inherit
  321. if (timing == EffectTiming.None)
  322. {
  323. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: true, card: card, condition: null));
  324. }
  325. #endregion
  326. return cardEffects;
  327. }
  328. }
  329. }