EX8_033.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX8
  6. {
  7. public class EX8_033 : 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 Conditions
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4)
  18. return targetPermanent.TopCard.EqualsTraits("NSo");
  19. return false;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region DNA Digivolution
  31. if (timing == EffectTiming.None)
  32. {
  33. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  34. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  35. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  36. addJogressConditionClass.SetNotShowUI(true);
  37. cardEffects.Add(addJogressConditionClass);
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return true;
  41. }
  42. JogressCondition GetJogress(CardSource cardSource)
  43. {
  44. if (cardSource == card)
  45. {
  46. bool YellowDigimonTarget(Permanent permanent)
  47. {
  48. if (permanent != null)
  49. {
  50. if (permanent.TopCard != null)
  51. {
  52. if (permanent.TopCard.Owner == card.Owner)
  53. {
  54. if (permanent.IsDigimon)
  55. {
  56. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  57. {
  58. if (permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  59. {
  60. if (permanent.Levels_ForJogress(card).Contains(4))
  61. {
  62. return true;
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. bool PurpleRedDigimonTarget(Permanent permanent)
  73. {
  74. if (permanent != null)
  75. {
  76. if (permanent.TopCard != null)
  77. {
  78. if (permanent.TopCard.Owner == card.Owner)
  79. {
  80. if (permanent.IsDigimon)
  81. {
  82. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  83. {
  84. if (permanent.TopCard.CardColors.Contains(CardColor.Purple) || permanent.TopCard.CardColors.Contains(CardColor.Red))
  85. {
  86. if (permanent.Levels_ForJogress(card).Contains(4))
  87. {
  88. return true;
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. JogressConditionElement[] elements =
  99. {
  100. new(YellowDigimonTarget, "a level 4 Yellow Digimon"),
  101. new(PurpleRedDigimonTarget, "a level 4 Purple or Red Digimon")
  102. };
  103. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  104. return jogressCondition;
  105. }
  106. return null;
  107. }
  108. }
  109. #endregion
  110. #region Shared OP/WD Methods
  111. bool SharedCanSelectCardCondition(CardSource cardSource)
  112. {
  113. if (cardSource != null)
  114. {
  115. if (cardSource.Owner == card.Owner)
  116. {
  117. if (cardSource.ContainsTraits("NSo"))
  118. {
  119. return true;
  120. }
  121. }
  122. }
  123. return false;
  124. }
  125. bool SharedActivateCondition(Hashtable hashtable)
  126. {
  127. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  128. {
  129. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectCardCondition))
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. IEnumerator SharedActivateCoroutine(Hashtable _hashtable, ActivateClass activateClass)
  137. {
  138. if (isExistOnField(card))
  139. {
  140. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, SharedCanSelectCardCondition))
  141. {
  142. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(SharedCanSelectCardCondition));
  143. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  144. selectCardEffect.SetUp(
  145. canTargetCondition: SharedCanSelectCardCondition,
  146. canTargetCondition_ByPreSelecetedList: null,
  147. canEndSelectCondition: null,
  148. canNoSelect: () => false,
  149. selectCardCoroutine: null,
  150. afterSelectCardCoroutine: null,
  151. message: "Select 1 card to add to your hand.",
  152. maxCount: maxCount,
  153. canEndNotMax: false,
  154. isShowOpponent: true,
  155. mode: SelectCardEffect.Mode.AddHand,
  156. root: SelectCardEffect.Root.Trash,
  157. customRootCardList: null,
  158. canLookReverseCard: true,
  159. selectPlayer: card.Owner,
  160. cardEffect: activateClass);
  161. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  162. }
  163. }
  164. }
  165. #endregion
  166. #region On Play
  167. if (timing == EffectTiming.OnEnterFieldAnyone)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(SharedActivateCondition, (hashtable => SharedActivateCoroutine(hashtable, activateClass)), -1, false, EffectDescription());
  172. cardEffects.Add(activateClass);
  173. string EffectDescription()
  174. {
  175. return "[On Play] Return 1 [NSo] trait card from your trash to the hand.";
  176. }
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  180. {
  181. if (CardEffectCommons.CanTriggerOnPlay(hashtable, card))
  182. {
  183. return true;
  184. }
  185. }
  186. return false;
  187. }
  188. }
  189. #endregion
  190. #region When Digivolving
  191. if (timing == EffectTiming.OnEnterFieldAnyone)
  192. {
  193. ActivateClass activateClass = new ActivateClass();
  194. activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card);
  195. activateClass.SetUpActivateClass(SharedActivateCondition, (hashtable => SharedActivateCoroutine(hashtable, activateClass)), -1, false, EffectDescription());
  196. cardEffects.Add(activateClass);
  197. string EffectDescription()
  198. {
  199. return "[When Digivolving] Return 1 [NSo] trait card from your trash to the hand.";
  200. }
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  204. {
  205. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  206. {
  207. return true;
  208. }
  209. }
  210. return false;
  211. }
  212. }
  213. #endregion
  214. #region On Deletion
  215. if (timing == EffectTiming.OnDestroyedAnyone)
  216. {
  217. ActivateClass activateClass = new ActivateClass();
  218. activateClass.SetUpICardEffect("Give -4000 DP", CanUseCondition, card);
  219. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  220. cardEffects.Add(activateClass);
  221. string EffectDescription()
  222. {
  223. return "[On Deletion] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  224. }
  225. bool CanUseCondition(Hashtable hashtable)
  226. {
  227. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  228. }
  229. bool CanActivateCondition(Hashtable hashtable)
  230. {
  231. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  232. }
  233. bool CanSelectPermanentCondition(Permanent permanent)
  234. {
  235. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable hashtable)
  238. {
  239. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  240. {
  241. SelectPermanentEffect selectPermanentEffect =
  242. GManager.instance.GetComponent<SelectPermanentEffect>();
  243. selectPermanentEffect.SetUp(
  244. selectPlayer: card.Owner,
  245. canTargetCondition: CanSelectPermanentCondition,
  246. canTargetCondition_ByPreSelecetedList: null,
  247. canEndSelectCondition: null,
  248. maxCount: 1,
  249. canNoSelect: false,
  250. canEndNotMax: false,
  251. selectPermanentCoroutine: SelectPermanentCoroutine,
  252. afterSelectPermanentCoroutine: null,
  253. mode: SelectPermanentEffect.Mode.Custom,
  254. cardEffect: activateClass);
  255. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  256. "The opponent is selecting 1 Digimon that will get DP -4000.");
  257. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  258. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  259. {
  260. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  261. targetPermanent: permanent,
  262. changeValue: -4000,
  263. effectDuration: EffectDuration.UntilEachTurnEnd,
  264. activateClass: activateClass));
  265. }
  266. }
  267. }
  268. }
  269. #endregion
  270. #region Inherited Effect
  271. if (timing == EffectTiming.OnDestroyedAnyone)
  272. {
  273. ActivateClass activateClass = new ActivateClass();
  274. activateClass.SetUpICardEffect("Recovery +1", CanUseCondition, card);
  275. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  276. activateClass.SetIsInheritedEffect(true);
  277. cardEffects.Add(activateClass);
  278. string EffectDescription()
  279. {
  280. return "[On Deletion] Recovery +1.";
  281. }
  282. bool CanUseCondition(Hashtable hashtable)
  283. {
  284. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  285. }
  286. bool CanActivateCondition(Hashtable hashtable)
  287. {
  288. if (CardEffectCommons.CanActivateOnDeletion(card, activateClass))
  289. {
  290. if (card.Owner.CanAddSecurity(activateClass))
  291. {
  292. return true;
  293. }
  294. }
  295. return false;
  296. }
  297. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  298. {
  299. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  300. }
  301. }
  302. #endregion
  303. return cardEffects;
  304. }
  305. }
  306. }