AD1_008.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using UnityEngine;
  6. // Gallantmon
  7. namespace DCGO.CardEffects.AD1
  8. {
  9. public class AD1_008 : CEntity_Effect
  10. {
  11. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  12. {
  13. List<ICardEffect> cardEffects = new List<ICardEffect>();
  14. #region Alternative Digivolution Condition
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.ContainsCardName("WarGrowlmon")
  20. || targetPermanent.TopCard.EqualsTraits("Hero");
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  23. level: 5,
  24. permanentCondition: PermanentCondition,
  25. digivolutionCost: 3,
  26. ignoreDigivolutionRequirement: false,
  27. card: card,
  28. condition: null)
  29. );
  30. }
  31. #endregion
  32. #region Rush
  33. if (timing == EffectTiming.None)
  34. {
  35. cardEffects.Add(CardEffectFactory.RushSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  36. }
  37. #endregion
  38. #region Raid
  39. if (timing == EffectTiming.OnAllyAttack)
  40. {
  41. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  42. }
  43. #endregion
  44. #region Piercing
  45. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  46. {
  47. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  48. }
  49. #endregion
  50. #region When Digivolving
  51. if (timing == EffectTiming.OnEnterFieldAnyone)
  52. {
  53. ActivateClass activateClass = new ActivateClass();
  54. activateClass.SetUpICardEffect("Delete opponent's Digimon whose total DP adds up to 10000 or less, Then may Attack", CanUseCondition, card);
  55. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  56. cardEffects.Add(activateClass);
  57. string EffectDescription() => "[When Digivolving] Delete up to 10000DP total worth of your opponent's Digimon. Then, this Digimon may attack.";
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.IsExistOnBattleArea(card)
  61. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  62. }
  63. bool CanSelectPermanentCondition(Permanent permanent)
  64. {
  65. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card)
  66. && permanent.HasDP
  67. && permanent.DP <= MaxDPForDeletion();
  68. }
  69. int MaxDPForDeletion() => card.Owner.MaxDP_DeleteEffect(10000, activateClass);
  70. bool CanActivateCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.IsExistOnBattleArea(card);
  73. }
  74. IEnumerator ActivateCoroutine(Hashtable hashtable)
  75. {
  76. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  77. {
  78. int maxCount = Math.Min(card.Owner.Enemy.GetBattleAreaDigimons().Count(CanSelectPermanentCondition),
  79. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: CanTargetConditionByPreSelectedList,
  85. canEndSelectCondition: CanEndSelectCondition,
  86. maxCount: maxCount,
  87. canNoSelect: false,
  88. canEndNotMax: true,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Destroy,
  92. cardEffect: activateClass);
  93. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  94. bool CanEndSelectCondition(List<Permanent> permanents)
  95. {
  96. if (permanents.Count <= 0)
  97. {
  98. return false;
  99. }
  100. int sumDP = 0;
  101. foreach (Permanent permanent in permanents)
  102. {
  103. sumDP += permanent.DP;
  104. }
  105. if (sumDP > MaxDPForDeletion())
  106. {
  107. return false;
  108. }
  109. return true;
  110. }
  111. bool CanTargetConditionByPreSelectedList(List<Permanent> permanents, Permanent permanent)
  112. {
  113. int sumDP = 0;
  114. foreach (Permanent permanent1 in permanents)
  115. {
  116. sumDP += permanent1.DP;
  117. }
  118. sumDP += permanent.DP;
  119. if (sumDP > MaxDPForDeletion())
  120. {
  121. return false;
  122. }
  123. return true;
  124. }
  125. }
  126. Permanent thisPermanent = card.PermanentOfThisCard();
  127. if (thisPermanent.CanAttack(activateClass))
  128. {
  129. SelectAttackEffect selectAttackEffect =
  130. GManager.instance.GetComponent<SelectAttackEffect>();
  131. selectAttackEffect.SetUp(
  132. attacker: thisPermanent,
  133. canAttackPlayerCondition: () => true,
  134. defenderCondition: (permanent) => true,
  135. cardEffect: activateClass);
  136. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  137. }
  138. }
  139. }
  140. #endregion
  141. #region Shared WD / WA
  142. string SharedHashString = "AD1_008_WD_WA";
  143. string SharedEffectName = "Delete lowest DP";
  144. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] Delete 1 of your opponent's lowest DP Digimon.";
  145. bool IsWeakestEnemyDigimon(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  146. bool SharedCanActivateCondition(Hashtable hashtable) => CardEffectCommons.IsExistOnBattleArea(card);
  147. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  148. {
  149. if (CardEffectCommons.HasMatchConditionPermanent(IsWeakestEnemyDigimon))
  150. {
  151. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  152. selectPermanentEffect.SetUp(
  153. selectPlayer: card.Owner,
  154. canTargetCondition: IsWeakestEnemyDigimon,
  155. canTargetCondition_ByPreSelecetedList: null,
  156. canEndSelectCondition: null,
  157. maxCount: 1,
  158. canNoSelect: false,
  159. canEndNotMax: false,
  160. selectPermanentCoroutine: null,
  161. afterSelectPermanentCoroutine: null,
  162. mode: SelectPermanentEffect.Mode.Destroy,
  163. cardEffect: activateClass);
  164. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. }
  167. }
  168. #endregion
  169. #region When Digivolving (OPT)
  170. if (timing == EffectTiming.OnEnterFieldAnyone)
  171. {
  172. ActivateClass activateClass = new ActivateClass();
  173. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  174. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Digivolving"));
  175. activateClass.SetHashString(SharedHashString);
  176. cardEffects.Add(activateClass);
  177. bool CanUseCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleArea(card)
  180. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  181. }
  182. }
  183. #endregion
  184. #region When Attacking
  185. if (timing == EffectTiming.OnAllyAttack)
  186. {
  187. ActivateClass activateClass = new ActivateClass();
  188. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  189. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), 1, false, SharedEffectDescription("When Attacking"));
  190. activateClass.SetHashString(SharedHashString);
  191. cardEffects.Add(activateClass);
  192. bool CanUseCondition(Hashtable hashtable)
  193. {
  194. return CardEffectCommons.IsExistOnBattleArea(card)
  195. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  196. }
  197. }
  198. #endregion
  199. #region Your Turn
  200. if (timing == EffectTiming.None)
  201. {
  202. bool Condition()
  203. {
  204. return CardEffectCommons.IsExistOnBattleArea(card)
  205. && CardEffectCommons.IsOwnerTurn(card)
  206. && card.PermanentOfThisCard().DigivolutionCards.Any(cardSource => cardSource.EqualsCardName("Takato Matsuki"));
  207. }
  208. #region Immunity
  209. CanNotAffectedClass canNotAffectedClass = new CanNotAffectedClass();
  210. canNotAffectedClass.SetUpICardEffect("Isn't affected by opponent's Digimon's effects", CanUseCondition, card);
  211. canNotAffectedClass.SetUpCanNotAffectedClass(CardCondition: CardCondition, SkillCondition: SkillCondition);
  212. cardEffects.Add(canNotAffectedClass);
  213. bool CanUseCondition(Hashtable hashtable) => Condition();
  214. bool CardCondition(CardSource cardSource) => cardSource == card;
  215. bool SkillCondition(ICardEffect cardEffect) => CardEffectCommons.IsOpponentEffect(cardEffect, card);
  216. #endregion
  217. #region +5000 DP
  218. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect<int>(
  219. changeValue: 5000,
  220. isInheritedEffect: false,
  221. card: card,
  222. condition: Condition));
  223. #endregion
  224. }
  225. #endregion
  226. return cardEffects;
  227. }
  228. }
  229. }