BT20_036.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT20
  6. {
  7. public class BT20_036 : 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 Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.IsLevel5 && targetPermanent.TopCard.EqualsTraits("ACCEL");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Reduce Play Cost
  23. if (timing == EffectTiming.None)
  24. {
  25. bool Condition()
  26. {
  27. return CardEffectCommons.HasMatchConditionPermanent(HasAccelTraitInPlay);
  28. }
  29. bool HasAccelTraitInPlay(Permanent permanent)
  30. {
  31. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  32. && permanent.TopCard.EqualsTraits("ACCEL");
  33. }
  34. cardEffects.Add(CardEffectFactory.MandatorySelfPlayCostReduction(5, card, Condition));
  35. }
  36. #endregion
  37. #region On Play
  38. if (timing == EffectTiming.OnEnterFieldAnyone)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 of your opponent's Digimon, then 1 gets -5000 DP", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  43. cardEffects.Add(activateClass);
  44. string EffectDescription()
  45. {
  46. return "[On Play] <De-Digivolve 2> 1 of your opponent's Digimon. Then, 1 of their Digimon gets -5000 DP until the end of their turn.";
  47. }
  48. bool IsOpponentsDigimon(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. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  59. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  64. selectPermanentEffect.SetUp(
  65. selectPlayer: card.Owner,
  66. canTargetCondition: IsOpponentsDigimon,
  67. canTargetCondition_ByPreSelecetedList: null,
  68. canEndSelectCondition: null,
  69. maxCount: 1,
  70. canNoSelect: false,
  71. canEndNotMax: false,
  72. selectPermanentCoroutine: SelectedDedigivolvePermanent,
  73. afterSelectPermanentCoroutine: null,
  74. mode: SelectPermanentEffect.Mode.Custom,
  75. cardEffect: activateClass);
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will <De-Digivolve 2>.", "The opponent is selecting 1 Digimon that will <De-Digivolve 2>.");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. IEnumerator SelectedDedigivolvePermanent(Permanent target)
  79. {
  80. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 2, activateClass).Degeneration());
  81. }
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: IsOpponentsDigimon,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: SelectedPermanent,
  91. afterSelectPermanentCoroutine: null,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effect and DP -5000.", "The opponent is selecting 1 Digimon that will gain effect and DP -5000.");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. IEnumerator SelectedPermanent(Permanent target)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: target, changeValue: -5000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  99. }
  100. }
  101. }
  102. #endregion
  103. #region When Digivolving
  104. if (timing == EffectTiming.OnEnterFieldAnyone)
  105. {
  106. ActivateClass activateClass = new ActivateClass();
  107. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 of your opponent's Digimon, then 1 gets -5000 DP", CanUseCondition, card);
  108. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  109. cardEffects.Add(activateClass);
  110. string EffectDescription()
  111. {
  112. return "[When Digivolving] <De-Digivolve 2> 1 of your opponent's Digimon. Then, 1 of their Digimon gets -5000 DP until the end of their turn.";
  113. }
  114. bool IsOpponentsDigimon(Permanent permanent)
  115. {
  116. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  121. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  126. CardEffectCommons.HasMatchConditionPermanent(IsOpponentsDigimon);
  127. }
  128. IEnumerator ActivateCoroutine(Hashtable hashtable)
  129. {
  130. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  131. selectPermanentEffect.SetUp(
  132. selectPlayer: card.Owner,
  133. canTargetCondition: IsOpponentsDigimon,
  134. canTargetCondition_ByPreSelecetedList: null,
  135. canEndSelectCondition: null,
  136. maxCount: 1,
  137. canNoSelect: false,
  138. canEndNotMax: false,
  139. selectPermanentCoroutine: SelectedDedigivolvePermanent,
  140. afterSelectPermanentCoroutine: null,
  141. mode: SelectPermanentEffect.Mode.Custom,
  142. cardEffect: activateClass);
  143. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will <De-Digivolve 2>.", "The opponent is selecting 1 Digimon that will <De-Digivolve 2>.");
  144. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  145. IEnumerator SelectedDedigivolvePermanent(Permanent target)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 2, activateClass).Degeneration());
  148. }
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: IsOpponentsDigimon,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: 1,
  155. canNoSelect: false,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: SelectedPermanent,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Custom,
  160. cardEffect: activateClass);
  161. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain effect and DP -5000.", "The opponent is selecting 1 Digimon that will gain effect and DP -5000.");
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. IEnumerator SelectedPermanent(Permanent target)
  164. {
  165. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: target, changeValue: -5000, effectDuration: EffectDuration.UntilOpponentTurnEnd, activateClass: activateClass));
  166. }
  167. }
  168. }
  169. #endregion
  170. #region End of Turn
  171. if (timing == EffectTiming.OnEndTurn)
  172. {
  173. ActivateClass activateClass = new ActivateClass();
  174. activateClass.SetUpICardEffect("DNA digivolve this Digimon", CanUseCondition, card);
  175. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  176. cardEffects.Add(activateClass);
  177. string EffectDescription()
  178. {
  179. return "[End of Your Turn] This Digimon and any of your other Digimon may DNA digivolve into a Digimon card with [Chaosmon] in its name in the hand. Then, the DNA digivolved Digimon may attack.";
  180. }
  181. bool CanSelectCardCondition(CardSource cardSource)
  182. {
  183. if (cardSource != null)
  184. {
  185. if (cardSource.IsDigimon)
  186. {
  187. if (cardSource.ContainsCardName("Chaosmon"))
  188. {
  189. if (cardSource.CanPlayJogress(true))
  190. {
  191. if (cardSource.CanJogressFromTargetPermanent(card.PermanentOfThisCard(), true))
  192. {
  193. return true;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. return false;
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  204. }
  205. bool CanActivateCondition(Hashtable hashtable)
  206. {
  207. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  208. {
  209. if (CardEffectCommons.IsOwnerTurn(card))
  210. {
  211. if(CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  212. {
  213. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsDigimon && permanent != card.PermanentOfThisCard()))
  214. {
  215. return true;
  216. }
  217. }
  218. }
  219. }
  220. return false;
  221. }
  222. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  223. {
  224. yield return ContinuousController.instance.StartCoroutine(
  225. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  226. CanSelectCardCondition,
  227. payCost: true,
  228. isHand: true,
  229. activateClass,
  230. permanentConditions: new Func<Permanent, bool>[] { (permanent) => permanent == card.PermanentOfThisCard() },
  231. successProcess: OnDNASuccess
  232. ));
  233. IEnumerator OnDNASuccess(CardSource cardSource)
  234. {
  235. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  236. selectAttackEffect.SetUp(
  237. attacker: cardSource.PermanentOfThisCard(),
  238. canAttackPlayerCondition: () => true,
  239. defenderCondition: _ => true,
  240. cardEffect: activateClass);
  241. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  242. }
  243. }
  244. }
  245. #endregion
  246. #region Redirect - ESS
  247. if (timing == EffectTiming.OnAllyAttack)
  248. {
  249. ActivateClass activateClass = new ActivateClass();
  250. activateClass.SetUpICardEffect("You may change the attack target to this Digimon.", CanUseCondition, card);
  251. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  252. activateClass.SetHashString("Redirect_BT20-036");
  253. activateClass.SetIsInheritedEffect(true);
  254. cardEffects.Add(activateClass);
  255. string EffectDescription()
  256. {
  257. return "[Opponent's Turn] [Once Per Turn] When any of your opponent's Digimon attack, you may change the attack target to this Digimon.";
  258. }
  259. bool IsOpponentDigimon(Permanent permanent)
  260. {
  261. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  262. }
  263. bool IsThisDigimon(Permanent permanent)
  264. {
  265. return permanent == card.PermanentOfThisCard();
  266. }
  267. bool CanUseCondition(Hashtable hashtable)
  268. {
  269. return CardEffectCommons.IsOpponentTurn(card) &&
  270. CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentDigimon);
  271. }
  272. bool CanActivateCondition(Hashtable hashtable)
  273. {
  274. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  275. }
  276. IEnumerator ActivateCoroutine(Hashtable hashtable)
  277. {
  278. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  279. selectPermanentEffect.SetUp(
  280. selectPlayer: card.Owner,
  281. canTargetCondition: IsThisDigimon,
  282. canTargetCondition_ByPreSelecetedList: null,
  283. canEndSelectCondition: null,
  284. maxCount: 1,
  285. canNoSelect: false,
  286. canEndNotMax: false,
  287. selectPermanentCoroutine: SelectPermanentCoroutine,
  288. afterSelectPermanentCoroutine: null,
  289. mode: SelectPermanentEffect.Mode.Custom,
  290. cardEffect: activateClass);
  291. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to attack.",
  292. "The opponent is selecting 1 Digimon to attack.");
  293. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  294. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  295. {
  296. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  297. activateClass,
  298. false,
  299. permanent));
  300. }
  301. }
  302. }
  303. #endregion
  304. return cardEffects;
  305. }
  306. }
  307. }