AD1_004.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // WarGreymon
  6. namespace DCGO.CardEffects.AD1
  7. {
  8. public class AD1_004 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Raid and Piercing
  14. if (timing == EffectTiming.OnAllyAttack)
  15. {
  16. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  17. }
  18. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  19. {
  20. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Alternative Digivolution Condition
  24. if (timing == EffectTiming.None)
  25. {
  26. bool PermanentCondition(Permanent targetPermanent)
  27. {
  28. if (targetPermanent.TopCard.ContainsCardName("Greymon") || targetPermanent.TopCard.EqualsTraits("ADVENTURE") || targetPermanent.TopCard.EqualsTraits("HERO"))
  29. {
  30. return true;
  31. }
  32. return false;
  33. }
  34. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  35. level: 5,
  36. permanentCondition: PermanentCondition,
  37. digivolutionCost: 3,
  38. ignoreDigivolutionRequirement: false,
  39. card: card,
  40. condition: null)
  41. );
  42. }
  43. #endregion
  44. #region Shared OP/WD
  45. string SharedEffectName() => "Delete 1 enemy Digimon";
  46. string SharedEffectDescription(string tag) => $"[{tag}] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon.";
  47. bool SharedCanActivateCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  50. }
  51. bool SharedCanSelectPermanentCondition(Permanent permanent)
  52. {
  53. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  54. && permanent.HasDP
  55. && permanent.DP <= card.PermanentOfThisCard().DP;
  56. }
  57. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  58. {
  59. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, SharedCanSelectPermanentCondition))
  60. {
  61. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition));
  62. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  63. selectPermanentEffect.SetUp(
  64. selectPlayer: card.Owner,
  65. canTargetCondition: SharedCanSelectPermanentCondition,
  66. canTargetCondition_ByPreSelecetedList: null,
  67. canEndSelectCondition: null,
  68. maxCount: maxCount,
  69. canNoSelect: false,
  70. canEndNotMax: false,
  71. selectPermanentCoroutine: null,
  72. afterSelectPermanentCoroutine: null,
  73. mode: SelectPermanentEffect.Mode.Destroy,
  74. cardEffect: activateClass);
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. }
  77. }
  78. #endregion
  79. #region On Play
  80. if (timing == EffectTiming.OnEnterFieldAnyone)
  81. {
  82. ActivateClass activateClass = new ActivateClass();
  83. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  84. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("On Play"));
  85. cardEffects.Add(activateClass);
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  89. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  90. }
  91. }
  92. #endregion
  93. #region When Digivolving
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect(SharedEffectName(), CanUseCondition, card);
  98. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, SharedEffectDescription("When Digivolving"));
  99. cardEffects.Add(activateClass);
  100. bool CanUseCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  103. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  104. }
  105. }
  106. #endregion
  107. #region All Turns
  108. if (timing == EffectTiming.None)
  109. {
  110. int count()
  111. {
  112. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  113. {
  114. List<CardSource> cards = card.Owner.GetBattleAreaPermanents()
  115. .Map(card => card.TopCard)
  116. .Where(x => x.IsTamer).ToList();
  117. var colourCount = Combinations.GetDifferenetColorCardCount(cards);
  118. var newDP = colourCount * 1000;
  119. return newDP;
  120. }
  121. return 0;
  122. }
  123. bool Condition()
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  126. card.PermanentOfThisCard().TopCard == card;
  127. }
  128. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<Func<int>>(
  129. changeValue: count,
  130. isInheritedEffect: false,
  131. card: card,
  132. condition: Condition));
  133. }
  134. if (timing == EffectTiming.None)
  135. {
  136. int count()
  137. {
  138. if (CardEffectCommons.IsExistOnBattleArea(card))
  139. {
  140. List<CardSource> cards = card.Owner.GetBattleAreaPermanents()
  141. .Map(card => card.TopCard)
  142. .Where(x => x.IsTamer).ToList();
  143. var colourCount = Combinations.GetDifferenetColorCardCount(cards);
  144. return colourCount / 3;
  145. }
  146. return 0;
  147. }
  148. bool Condition()
  149. {
  150. if (CardEffectCommons.IsExistOnBattleArea(card))
  151. {
  152. if (count() >= 1)
  153. {
  154. return true;
  155. }
  156. }
  157. return false;
  158. }
  159. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect<Func<int>>(changeValue: count, isInheritedEffect: false, card: card, condition: Condition));
  160. }
  161. #endregion
  162. #region End of Turn
  163. if (timing == EffectTiming.OnEndTurn)
  164. {
  165. ActivateClass activateClass = new ActivateClass();
  166. activateClass.SetUpICardEffect("May attack", CanUseCondition, card);
  167. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  168. cardEffects.Add(activateClass);
  169. string EffectDescription()
  170. {
  171. return "[End of Your Turn] 1 of your Digimon may attack.";
  172. }
  173. bool IsYourDigimon(Permanent permanent)
  174. {
  175. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  176. && permanent.CanAttack(activateClass);
  177. }
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  181. }
  182. bool CanActivateCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  185. {
  186. if (CardEffectCommons.IsOwnerTurn(card))
  187. {
  188. return true;
  189. }
  190. }
  191. return false;
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable hashtable)
  194. {
  195. Permanent selectedPermanent = null;
  196. if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon))
  197. {
  198. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsYourDigimon));
  199. SelectPermanentEffect selectPermanentEffect =
  200. GManager.instance.GetComponent<SelectPermanentEffect>();
  201. selectPermanentEffect.SetUp(
  202. selectPlayer: card.Owner,
  203. canTargetCondition: IsYourDigimon,
  204. canTargetCondition_ByPreSelecetedList: null,
  205. canEndSelectCondition: null,
  206. maxCount: maxCount,
  207. canNoSelect: true,
  208. canEndNotMax: false,
  209. selectPermanentCoroutine: SelectPermanentCoroutine,
  210. afterSelectPermanentCoroutine: null,
  211. mode: SelectPermanentEffect.Mode.Custom,
  212. cardEffect: activateClass);
  213. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.",
  214. "The opponent is selecting 1 Digimon that will attack.");
  215. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  216. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  217. {
  218. selectedPermanent = permanent;
  219. yield return null;
  220. }
  221. }
  222. if (selectedPermanent != null)
  223. {
  224. if (selectedPermanent.CanAttack(activateClass))
  225. {
  226. SelectAttackEffect selectAttackEffect =
  227. GManager.instance.GetComponent<SelectAttackEffect>();
  228. selectAttackEffect.SetUp(
  229. attacker: selectedPermanent,
  230. canAttackPlayerCondition: () => true,
  231. defenderCondition: (permanent) => true,
  232. cardEffect: activateClass);
  233. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  234. }
  235. }
  236. }
  237. }
  238. #endregion
  239. #region When Attacking - ESS
  240. if (timing == EffectTiming.OnAllyAttack)
  241. {
  242. ActivateClass activateClass = new ActivateClass();
  243. activateClass.SetUpICardEffect("Delete 1 of your opponent's Digimon with as much or less DP than this Digimon", CanUseCondition, card);
  244. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  245. activateClass.SetIsInheritedEffect(true);
  246. activateClass.SetHashString("ESS_AD01_004");
  247. cardEffects.Add(activateClass);
  248. string EffectDescription()
  249. {
  250. return
  251. "[When Attacking][Once Per Turn] Delete 1 of your opponent's Digimon with as much or less DP as this Digimon with [Greymon] or [Omnimon] in it's name.";
  252. }
  253. bool CanUseCondition(Hashtable hashtable)
  254. {
  255. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  256. && CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  257. }
  258. bool CanActivateCondition(Hashtable hashtable)
  259. {
  260. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  261. }
  262. bool CanSelectPermanentCondition(Permanent permanent)
  263. {
  264. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  265. && permanent.HasDP
  266. && permanent.DP <= card.PermanentOfThisCard().DP;
  267. }
  268. IEnumerator ActivateCoroutine(Hashtable hashtable)
  269. {
  270. if ((card.PermanentOfThisCard().TopCard.ContainsCardName("Omnimon") || card.PermanentOfThisCard().TopCard.ContainsCardName("Greymon")) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  271. {
  272. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  273. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  274. selectPermanentEffect.SetUp(
  275. selectPlayer: card.Owner,
  276. canTargetCondition: CanSelectPermanentCondition,
  277. canTargetCondition_ByPreSelecetedList: null,
  278. canEndSelectCondition: null,
  279. maxCount: maxCount,
  280. canNoSelect: false,
  281. canEndNotMax: false,
  282. selectPermanentCoroutine: null,
  283. afterSelectPermanentCoroutine: null,
  284. mode: SelectPermanentEffect.Mode.Destroy,
  285. cardEffect: activateClass);
  286. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  287. }
  288. }
  289. }
  290. #endregion
  291. return cardEffects;
  292. }
  293. }
  294. }