P_203.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Justimon: Accel Arm
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_203 : 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.IsLevel5 && targetPermanent.TopCard.ContainsCardName("Cyberdramon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Alternative Digivolution Condition
  29. if (timing == EffectTiming.None)
  30. {
  31. bool PermanentCondition(Permanent targetPermanent)
  32. {
  33. return targetPermanent.TopCard.EqualsCardName("Justimon: Blitz Arm") || targetPermanent.TopCard.EqualsCardName("Justimon: Critical Arm");
  34. }
  35. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  36. permanentCondition: PermanentCondition,
  37. digivolutionCost: 1,
  38. ignoreDigivolutionRequirement: false,
  39. card: card,
  40. condition: null)
  41. );
  42. }
  43. #endregion
  44. #region Shared OP/WD/WA
  45. bool SharedCanSelectPermanentCondition(Permanent permanent)
  46. {
  47. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  48. }
  49. bool SharedIsOptionInBattleArea(Permanent permanent)
  50. {
  51. return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
  52. && permanent.IsOption;
  53. }
  54. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  55. {
  56. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanentCondition))
  57. {
  58. Permanent selectedPermanent = null;
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition));
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: SharedCanSelectPermanentCondition,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  74. {
  75. selectedPermanent = permanent;
  76. yield return null;
  77. }
  78. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(new IDegeneration(
  81. permanent: selectedPermanent,
  82. DegenerationCount: 1,
  83. cardEffect: activateClass).Degeneration()
  84. );
  85. }
  86. if (CardEffectCommons.HasMatchConditionPermanent(SharedIsOptionInBattleArea))
  87. {
  88. Permanent selectedPermanent = null;
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedIsOptionInBattleArea));
  91. selectPermanentEffect.SetUp(
  92. selectPlayer: card.Owner,
  93. canTargetCondition: SharedIsOptionInBattleArea,
  94. canTargetCondition_ByPreSelecetedList: null,
  95. canEndSelectCondition: null,
  96. maxCount: maxCount,
  97. canNoSelect: true,
  98. canEndNotMax: false,
  99. selectPermanentCoroutine: SelectPermanentCoroutine,
  100. afterSelectPermanentCoroutine: null,
  101. mode: SelectPermanentEffect.Mode.Custom,
  102. cardEffect: activateClass);
  103. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  104. {
  105. selectedPermanent = permanent;
  106. yield return null;
  107. }
  108. selectPermanentEffect.SetUpCustomMessage("Select 1 option to trash.", "The opponent is selecting 1 option to trash.");
  109. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  110. if (selectedPermanent != null)
  111. {
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  113. targetPermanents: new List<Permanent> { selectedPermanent },
  114. activateClass: activateClass,
  115. successProcess: SuccessProcess,
  116. failureProcess: null)
  117. );
  118. IEnumerator SuccessProcess(List<Permanent> permanents)
  119. {
  120. Permanent thisPermanent = card.PermanentOfThisCard();
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  122. targetPermanent: thisPermanent,
  123. effectDuration: EffectDuration.UntilEachTurnEnd,
  124. activateClass: activateClass));
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  126. targetPermanent: thisPermanent,
  127. changeValue: 1,
  128. effectDuration: EffectDuration.UntilEachTurnEnd,
  129. activateClass: activateClass));
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. #region On Play
  136. if (timing == EffectTiming.OnEnterFieldAnyone)
  137. {
  138. ActivateClass activateClass = new ActivateClass();
  139. activateClass.SetUpICardEffect("De-Digivolve 1, then by trashing 1 option in battle area, gain Piercing & Sec +1 for the turn", CanUseCondition, card);
  140. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, EffectDiscription());
  141. activateClass.SetHashString("P_203_OP/WD/WA");
  142. cardEffects.Add(activateClass);
  143. string EffectDiscription()
  144. {
  145. return "[On Play] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon. Then, by trashing 1 Option card in the battle area, this Digimon gains <Piercing> and <Security A. +1> for the turn.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  150. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  155. }
  156. }
  157. #endregion
  158. #region When Digivolving
  159. if (timing == EffectTiming.OnEnterFieldAnyone)
  160. {
  161. ActivateClass activateClass = new ActivateClass();
  162. activateClass.SetUpICardEffect("De-Digivolve 1, then by trashing 1 option in battle area, gain Piercing & Sec +1 for the turn", CanUseCondition, card);
  163. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, EffectDiscription());
  164. activateClass.SetHashString("P_203_OP/WD/WA");
  165. cardEffects.Add(activateClass);
  166. string EffectDiscription()
  167. {
  168. return "[When Digivolving] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon. Then, by trashing 1 Option card in the battle area, this Digimon gains <Piercing> and <Security A. +1> for the turn.";
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  173. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  178. }
  179. }
  180. #endregion
  181. #region When Attacking
  182. if (timing == EffectTiming.OnAllyAttack)
  183. {
  184. ActivateClass activateClass = new ActivateClass();
  185. activateClass.SetUpICardEffect("De-Digivolve 1, then by trashing 1 option in battle area, gain Piercing & Sec +1 for the turn", CanUseCondition, card);
  186. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, EffectDiscription());
  187. activateClass.SetHashString("P_203_OP/WD/WA");
  188. cardEffects.Add(activateClass);
  189. string EffectDiscription()
  190. {
  191. return "[When Attacking] [Once Per Turn] <De-Digivolve 1> 1 of your opponent's Digimon. Then, by trashing 1 Option card in the battle area, this Digimon gains <Piercing> and <Security A. +1> for the turn.";
  192. }
  193. bool CanUseCondition(Hashtable hashtable)
  194. {
  195. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  196. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  197. }
  198. bool CanActivateCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  201. }
  202. }
  203. #endregion
  204. #region All Turns - OPT
  205. if (timing == EffectTiming.OnDestroyedAnyone)
  206. {
  207. ActivateClass activateClass = new ActivateClass();
  208. activateClass.SetUpICardEffect("1 digimon can't attack or digivolve", CanUseCondition, card);
  209. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  210. activateClass.SetHashString("P_203_AT");
  211. cardEffects.Add(activateClass);
  212. string EffectDiscription()
  213. {
  214. return "[All Turns] [Once Per Turn] When Option cards in the battle area are trashed, 1 of your opponent's Digimon can't digivolve or attack players until their turn ends.";
  215. }
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  219. && CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass);
  220. }
  221. bool CanActivateCondition(Hashtable hashtable)
  222. {
  223. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  224. }
  225. bool PermanentCondition(Permanent permanent)
  226. {
  227. return permanent.IsOption;
  228. }
  229. bool CanSelectPermamentCondition(Permanent permanent)
  230. {
  231. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable hashtable)
  234. {
  235. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermamentCondition))
  236. {
  237. Permanent selectedPermament = null;
  238. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  239. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermamentCondition));
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermamentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: false,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: SelectPermanentCoroutine,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Custom,
  251. cardEffect: activateClass);
  252. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  253. {
  254. selectedPermament = permanent;
  255. yield return null;
  256. }
  257. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain cant digivolve & can't attack players.", "The opponent is selecting 1 Digimon that will gain cant digivolve & can't attack players.");
  258. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  259. if (selectedPermament != null)
  260. {
  261. CanNotDigivolveClass canNotPutFieldClass = new CanNotDigivolveClass();
  262. canNotPutFieldClass.SetUpICardEffect("Can't Digivolve", CanUseCondition1, card);
  263. canNotPutFieldClass.SetUpCanNotEvolveClass(permanentCondition: PermanentCondition, cardCondition: CardCondition);
  264. selectedPermament.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  265. ContinuousController.instance.PlaySE(GManager.instance.GetComponent<Effects>().DebuffSE);
  266. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermament));
  267. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttack(
  268. targetPermanent: selectedPermament,
  269. defenderCondition: DefenderCondition,
  270. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  271. activateClass: activateClass,
  272. effectName: "Cannot attack player"));
  273. #region Cant Attack/Digivolve Functions
  274. bool CanUseCondition1(Hashtable hashtable)
  275. {
  276. return true;
  277. }
  278. bool PermanentCondition(Permanent permanent)
  279. {
  280. if (permanent == selectedPermament)
  281. {
  282. if (permanent.TopCard != null)
  283. {
  284. if (permanent.TopCard.IsDigimon)
  285. {
  286. if (!permanent.TopCard.CanNotBeAffected(canNotPutFieldClass))
  287. {
  288. return true;
  289. }
  290. }
  291. }
  292. }
  293. return false;
  294. }
  295. bool CardCondition(CardSource cardSource)
  296. {
  297. if (cardSource.Owner == card.Owner.Enemy)
  298. {
  299. if (cardSource.IsDigimon || cardSource.IsTamer)
  300. {
  301. if (!cardSource.CanNotBeAffected(canNotPutFieldClass))
  302. {
  303. return true;
  304. }
  305. }
  306. }
  307. return false;
  308. }
  309. ICardEffect GetCardEffect(EffectTiming _timing)
  310. {
  311. if (_timing == EffectTiming.None)
  312. {
  313. return canNotPutFieldClass;
  314. }
  315. return null;
  316. }
  317. bool DefenderCondition(Permanent defender)
  318. {
  319. return defender == null;
  320. }
  321. #endregion
  322. }
  323. }
  324. }
  325. }
  326. #endregion
  327. return cardEffects;
  328. }
  329. }
  330. }