Make moveflags of gen 7 plugin shared statically

This commit is contained in:
Deukhoofd 2025-07-26 14:36:47 +02:00
parent 77d7b86a3c
commit 6eba332096
33 changed files with 223 additions and 146 deletions

View File

@ -65,7 +65,7 @@ public partial class ExplicitAI
var abilityName = pokemon.ActiveAbility.Name; var abilityName = pokemon.ActiveAbility.Name;
if (abilityName == BulletproofName) if (abilityName == BulletproofName)
return move.HasFlag("bomb"); return move.HasFlag("ballistics");
if (abilityName == FlashFireName) if (abilityName == FlashFireName)
return moveType.Name == FireName; return moveType.Name == FireName;
if (abilityName == LightningRodName || abilityName == MotorDriveName || abilityName == VoltAbsorbName) if (abilityName == LightningRodName || abilityName == MotorDriveName || abilityName == VoltAbsorbName)

View File

@ -143,6 +143,11 @@ public interface IMoveData : INamedValue
/// Arbitrary flags that can be applied to the move. /// Arbitrary flags that can be applied to the move.
/// </summary> /// </summary>
bool HasFlag(StringKey key); bool HasFlag(StringKey key);
/// <summary>
/// A readonly list of all flags on the move.
/// </summary>
IReadOnlyCollection<StringKey> Flags { get; }
} }
/// <inheritdoc /> /// <inheritdoc />
@ -196,6 +201,9 @@ public class MoveDataImpl : IMoveData
/// <inheritdoc /> /// <inheritdoc />
public bool HasFlag(StringKey key) => _flags.Contains(key); public bool HasFlag(StringKey key) => _flags.Contains(key);
/// <inheritdoc />
public IReadOnlyCollection<StringKey> Flags => _flags;
} }
public static class MoveTargetHelpers public static class MoveTargetHelpers

View File

@ -4,7 +4,9 @@ using PkmnLib.Dynamic.Libraries;
using PkmnLib.Dynamic.Plugins; using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling; using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry; using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Plugin.Gen7.Common;
using PkmnLib.Static.Moves; using PkmnLib.Static.Moves;
using PkmnLib.Static.Utils;
namespace PkmnLib.Plugin.Gen7.Tests.DataTests; namespace PkmnLib.Plugin.Gen7.Tests.DataTests;
@ -89,6 +91,26 @@ public class MoveDataTests
await Assert.That(test.Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out _)).IsTrue(); await Assert.That(test.Library.ScriptResolver.TryResolve(ScriptCategory.Status, status, null, out _)).IsTrue();
} }
public static IEnumerable<Func<StringKey>> AllMoveFlagsAreIncludedInMoveFlagsData()
{
var library = LibraryHelpers.LoadLibrary();
var moveLibrary = library.StaticLibrary.Moves;
foreach (var flag in moveLibrary.SelectMany(x => x.Flags).Distinct())
{
yield return () => flag;
}
}
private static readonly HashSet<StringKey> CompileTimeMoveFlags = typeof(MoveFlags).GetFields()
.Where(x => x is { IsStatic: true, IsPublic: true } && x.FieldType == typeof(StringKey))
.Select(x => (StringKey)x.GetValue(null)!).ToHashSet();
[Test, MethodDataSource(nameof(AllMoveFlagsAreIncludedInMoveFlagsData))]
public async Task AllMoveFlagsAreIncludedInMoveFlagsClass(StringKey flag)
{
await Assert.That(CompileTimeMoveFlags.Contains(flag)).IsTrue();
}
public record HasEitherEffectOrComment(string MoveName, bool HasEffect, bool HasComment) public record HasEitherEffectOrComment(string MoveName, bool HasEffect, bool HasComment)
{ {
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,5 +1,6 @@
using PkmnLib.Dynamic.Models; using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling; using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Plugin.Gen7.Common;
using PkmnLib.Plugin.Gen7.Scripts.Abilities; using PkmnLib.Plugin.Gen7.Scripts.Abilities;
using PkmnLib.Plugin.Gen7.Scripts.Moves; using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Static; using PkmnLib.Static;
@ -20,7 +21,7 @@ public class MegaLauncherTests
var user = Substitute.For<IPokemon>(); var user = Substitute.For<IPokemon>();
move.User.Returns(user); move.User.Returns(user);
move.UseMove.Category.Returns(MoveCategory.Special); move.UseMove.Category.Returns(MoveCategory.Special);
move.UseMove.HasFlag("pulse").Returns(true); move.UseMove.HasFlag(MoveFlags.Pulse).Returns(true);
var megaLauncher = new ScriptContainer(new MegaLauncher()); var megaLauncher = new ScriptContainer(new MegaLauncher());
move.User.AbilityScript.Returns(megaLauncher); move.User.AbilityScript.Returns(megaLauncher);
move.GetScripts().Returns(new ScriptIterator([megaLauncher])); move.GetScripts().Returns(new ScriptIterator([megaLauncher]));

View File

@ -26,7 +26,7 @@ public static class AIDamageFunctions
if (damage > target.CurrentHealth * 1.1f) if (damage > target.CurrentHealth * 1.1f)
{ {
score += 10; score += 10;
if ((option.Move.Move.HasFlag("multi_hit") && target.CurrentHealth == target.MaxHealth && if ((option.Move.Move.HasFlag(MoveFlags.MultiHit) && target.CurrentHealth == target.MaxHealth &&
target.ActiveAbility?.Name == "sturdy") || target.HasHeldItem("focus_sash")) target.ActiveAbility?.Name == "sturdy") || target.HasHeldItem("focus_sash"))
{ {
score += 8; score += 8;

View File

@ -0,0 +1,37 @@
namespace PkmnLib.Plugin.Gen7.Common;
public static class MoveFlags
{
public static readonly StringKey Ballistics = "ballistics";
public static readonly StringKey Bite = "bite";
public static readonly StringKey Charge = "charge";
public static readonly StringKey Contact = "contact";
public static readonly StringKey Dance = "dance";
public static readonly StringKey Defrost = "defrost";
public static readonly StringKey Distance = "distance";
public static readonly StringKey EffectiveAgainstFly = "effective_against_fly";
public static readonly StringKey EffectiveAgainstUnderground = "effective_against_underground";
public static readonly StringKey EffectiveAgainstUnderwater = "effective_against_underwater";
public static readonly StringKey Gravity = "gravity";
public static readonly StringKey Heal = "heal";
public static readonly StringKey HitFlying = "hit_flying";
public static readonly StringKey HitUnderground = "hit_underground";
public static readonly StringKey HitUnderwater = "hit_underwater";
public static readonly StringKey IgnoreSubstitute = "ignore_substitute";
public static readonly StringKey LimitMoveChoice = "limit_move_choice";
public static readonly StringKey Mental = "mental";
public static readonly StringKey Mirror = "mirror";
public static readonly StringKey MultiHit = "multi_hit";
public static readonly StringKey NonSkyBattle = "non_sky_battle";
public static readonly StringKey NotSketchable = "not_sketchable";
public static readonly StringKey Powder = "powder";
public static readonly StringKey Protect = "protect";
public static readonly StringKey Pulse = "pulse";
public static readonly StringKey Punch = "punch";
public static readonly StringKey Recoil = "recoil";
public static readonly StringKey Recharge = "recharge";
public static readonly StringKey Reflectable = "reflectable";
public static readonly StringKey Snatch = "snatch";
public static readonly StringKey Sound = "sound";
public static readonly StringKey UsableWhileAsleep = "usable_while_asleep";
}

View File

@ -218,7 +218,7 @@
"target": "Any", "target": "Any",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "after_you" "name": "after_you"
@ -472,7 +472,7 @@
"target": "AdjacentAlly", "target": "AdjacentAlly",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_special_defense", "name": "change_target_special_defense",
@ -562,7 +562,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"mental" "mental"
], ],
"effect": { "effect": {
@ -822,7 +822,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "bestow" "name": "bestow"
@ -1043,7 +1043,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "set_status", "name": "set_status",
@ -1141,7 +1141,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
] ]
// No secondary effect // No secondary effect
}, },
@ -1337,7 +1337,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_special_defense", "name": "change_target_special_defense",
@ -1379,7 +1379,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "change_target_speed", "name": "change_target_speed",
@ -1596,7 +1596,7 @@
"mirror", "mirror",
"sound", "sound",
"distance", "distance",
"ignore-substitute", "ignore_substitute",
"not_sketchable" "not_sketchable"
], ],
"effect": { "effect": {
@ -1670,7 +1670,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_user_defense", "name": "change_user_defense",
@ -1772,7 +1772,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_special_attack", "name": "change_target_special_attack",
@ -1889,7 +1889,7 @@
"target": "Any", "target": "Any",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "conversion_2" "name": "conversion_2"
@ -2191,7 +2191,7 @@
"target": "Self", "target": "Self",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "curse" "name": "curse"
@ -2339,7 +2339,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "defog" "name": "defog"
@ -2355,7 +2355,7 @@
"target": "Self", "target": "Self",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "destiny_bond" "name": "destiny_bond"
@ -2434,7 +2434,7 @@
"charge", "charge",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "dig" "name": "dig"
@ -2453,7 +2453,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"limit_move_choice" "limit_move_choice"
], ],
"effect": { "effect": {
@ -2473,7 +2473,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
] ]
// No secondary effect // No secondary effect
}, },
@ -2512,7 +2512,7 @@
"charge", "charge",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "dive" "name": "dive"
@ -2987,7 +2987,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "change_target_special_defense", "name": "change_target_special_defense",
@ -3009,7 +3009,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle", "non_sky_battle",
"hit_underground", "hit_underground",
"effective_against_underground" "effective_against_underground"
] ]
@ -3028,7 +3028,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "echoed_voice" "name": "echoed_voice"
@ -3081,7 +3081,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "electric_terrain" "name": "electric_terrain"
@ -3194,7 +3194,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"mental", "mental",
"limit_move_choice" "limit_move_choice"
], ],
@ -3388,7 +3388,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "fairy_lock" "name": "fairy_lock"
@ -3649,7 +3649,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "fire_pledge" "name": "fire_pledge"
@ -3726,7 +3726,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "one_hit_ko" "name": "one_hit_ko"
@ -4018,7 +4018,7 @@
"mirror", "mirror",
"gravity", "gravity",
"distance", "distance",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "flying_press" "name": "flying_press"
@ -4129,7 +4129,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "foresight" "name": "foresight"
@ -4219,7 +4219,7 @@
"recharge", "recharge",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "requires_recharge" "name": "requires_recharge"
@ -4412,7 +4412,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"snatch", "snatch",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "gear_up" "name": "gear_up"
@ -4443,7 +4443,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"charge", "charge",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "geomancy" "name": "geomancy"
@ -4567,7 +4567,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "grass_knot" "name": "grass_knot"
@ -4585,7 +4585,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "grass_pledge" "name": "grass_pledge"
@ -4605,7 +4605,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "set_status", "name": "set_status",
@ -4624,7 +4624,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "grassy_terrain" "name": "grassy_terrain"
@ -4640,7 +4640,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "gravity" "name": "gravity"
@ -4660,7 +4660,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_attack", "name": "change_target_attack",
@ -4696,7 +4696,7 @@
"target": "Self", "target": "Self",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "grudge" "name": "grudge"
@ -4730,7 +4730,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "guard_swap" "name": "guard_swap"
@ -4908,7 +4908,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "reset_target_stats" "name": "reset_target_stats"
@ -4990,7 +4990,7 @@
"snatch", "snatch",
"sound", "sound",
"distance", "distance",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "heal_bell" "name": "heal_bell"
@ -5106,7 +5106,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "heart_swap" "name": "heart_swap"
@ -5125,7 +5125,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "heat_crash" "name": "heat_crash"
@ -5165,7 +5165,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "heat_crash" "name": "heat_crash"
@ -5181,7 +5181,7 @@
"target": "AdjacentAlly", "target": "AdjacentAlly",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "helping_hand" "name": "helping_hand"
@ -5285,7 +5285,7 @@
"target": "AdjacentAlly", "target": "AdjacentAlly",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
] ]
// No secondary effect // No secondary effect
}, },
@ -5510,7 +5510,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
] ]
// No secondary effect // No secondary effect
}, },
@ -5525,7 +5525,7 @@
"category": "physical", "category": "physical",
"flags": [ "flags": [
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"protect" "protect"
], ],
"effect": { "effect": {
@ -5543,7 +5543,7 @@
"category": "special", "category": "special",
"flags": [ "flags": [
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"protect" "protect"
], ],
"effect": { "effect": {
@ -5776,7 +5776,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"snatch", "snatch",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "imprison" "name": "imprison"
@ -5873,7 +5873,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"snatch", "snatch",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "ingrain" "name": "ingrain"
@ -5890,7 +5890,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"protect", "protect",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "instruct" "name": "instruct"
@ -6090,7 +6090,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
] ]
// No secondary effect // No secondary effect
}, },
@ -6643,7 +6643,7 @@
"flags": [ "flags": [
"snatch", "snatch",
"distance", "distance",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "magnetic_flux" "name": "magnetic_flux"
@ -6661,7 +6661,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "magnitude" "name": "magnitude"
@ -6692,7 +6692,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"snatch", "snatch",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "mat_block" "name": "mat_block"
@ -6709,7 +6709,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"protect", "protect",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "me_first" "name": "me_first"
@ -6891,7 +6891,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_special_defense", "name": "change_target_special_defense",
@ -6968,7 +6968,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"protect", "protect",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "mimic" "name": "mimic"
@ -7023,7 +7023,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "miracle_eye" "name": "miracle_eye"
@ -7127,7 +7127,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "misty_terrain" "name": "misty_terrain"
@ -7277,7 +7277,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "mud_sport" "name": "mud_sport"
@ -7295,7 +7295,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "change_target_accuracy", "name": "change_target_accuracy",
@ -7540,7 +7540,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_multiple_target_stat_boosts", "name": "change_multiple_target_stat_boosts",
@ -7640,7 +7640,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "foresight" "name": "foresight"
@ -7769,7 +7769,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "parting_shot" "name": "parting_shot"
@ -7839,7 +7839,7 @@
"flags": [ "flags": [
"sound", "sound",
"distance", "distance",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "perish_song" "name": "perish_song"
@ -7927,7 +7927,7 @@
"flags": [ "flags": [
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_attack", "name": "change_target_attack",
@ -8149,7 +8149,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"powder" "powder"
], ],
"effect": { "effect": {
@ -8220,7 +8220,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "power_swap" "name": "power_swap"
@ -8310,7 +8310,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
] ]
// No secondary effect // No secondary effect
}, },
@ -8391,7 +8391,7 @@
"target": "Any", "target": "Any",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "psych_up" "name": "psych_up"
@ -8446,7 +8446,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "psychic_terrain" "name": "psychic_terrain"
@ -8882,7 +8882,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"protect", "protect",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "reflect_type" "name": "reflect_type"
@ -8917,7 +8917,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "set_status", "name": "set_status",
@ -9047,7 +9047,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "roar" "name": "roar"
@ -9231,7 +9231,7 @@
"target": "Any", "target": "Any",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "role_play" "name": "role_play"
@ -9302,7 +9302,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"distance", "distance",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "rototiller" "name": "rototiller"
@ -9321,7 +9321,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "round" "name": "round"
@ -9534,7 +9534,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_defense", "name": "change_target_defense",
@ -9648,7 +9648,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "night_shade" "name": "night_shade"
@ -10002,7 +10002,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "set_status", "name": "set_status",
@ -10033,7 +10033,7 @@
"target": "Any", "target": "Any",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "sketch" "name": "sketch"
@ -10051,7 +10051,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "skill_swap" "name": "skill_swap"
@ -10167,7 +10167,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
] ]
// No secondary effect // No secondary effect
}, },
@ -10303,7 +10303,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle", "non_sky_battle",
"hit_flying" "hit_flying"
], ],
"effect": { "effect": {
@ -10399,7 +10399,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "change_target_special_attack", "name": "change_target_special_attack",
@ -10418,7 +10418,7 @@
"target": "Self", "target": "Self",
"category": "status", "category": "status",
"flags": [ "flags": [
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "snatch" "name": "snatch"
@ -10437,7 +10437,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute", "ignore_substitute",
"usable_while_asleep" "usable_while_asleep"
], ],
"effect": { "effect": {
@ -10606,7 +10606,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "sparkling_aria" "name": "sparkling_aria"
@ -10625,7 +10625,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "spectral_thief" "name": "spectral_thief"
@ -10643,7 +10643,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "speed_swap" "name": "speed_swap"
@ -10696,7 +10696,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"reflectable", "reflectable",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "spikes" "name": "spikes"
@ -10762,7 +10762,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "spite" "name": "spite"
@ -10961,7 +10961,7 @@
"contact", "contact",
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "flinch", "name": "flinch",
@ -11169,7 +11169,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"snatch", "snatch",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "substitute" "name": "substitute"
@ -11302,7 +11302,7 @@
"reflectable", "reflectable",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "confuse" "name": "confuse"
@ -11344,7 +11344,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle", "non_sky_battle",
"effective_against_underwater" "effective_against_underwater"
] ]
// No secondary effect // No secondary effect
@ -11635,7 +11635,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"mental", "mental",
"limit_move_choice" "limit_move_choice"
], ],
@ -11786,7 +11786,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle", "non_sky_battle",
"hit_flying" "hit_flying"
], ],
"effect": { "effect": {
@ -11805,7 +11805,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "thousand_waves" "name": "thousand_waves"
@ -12027,7 +12027,7 @@
"protect", "protect",
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute", "ignore_substitute",
"mental", "mental",
"limit_move_choice" "limit_move_choice"
], ],
@ -12067,7 +12067,7 @@
"category": "status", "category": "status",
"flags": [ "flags": [
"reflectable", "reflectable",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "toxic_spikes" "name": "toxic_spikes"
@ -12324,7 +12324,7 @@
"protect", "protect",
"mirror", "mirror",
"sound", "sound",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "uproar" "name": "uproar"
@ -12532,7 +12532,7 @@
"flags": [ "flags": [
"protect", "protect",
"mirror", "mirror",
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "water_pledge" "name": "water_pledge"
@ -12586,7 +12586,7 @@
"target": "All", "target": "All",
"category": "status", "category": "status",
"flags": [ "flags": [
"nonskybattle" "non_sky_battle"
], ],
"effect": { "effect": {
"name": "water_sport" "name": "water_sport"
@ -12678,7 +12678,7 @@
"flags": [ "flags": [
"reflectable", "reflectable",
"mirror", "mirror",
"ignore-substitute" "ignore_substitute"
], ],
"effect": { "effect": {
"name": "roar" "name": "roar"

View File

@ -5,3 +5,4 @@ global using PkmnLib.Dynamic.Models;
global using PkmnLib.Dynamic.Models.Choices; global using PkmnLib.Dynamic.Models.Choices;
global using PkmnLib.Static; global using PkmnLib.Static;
global using PkmnLib.Static.Utils; global using PkmnLib.Static.Utils;
global using PkmnLib.Plugin.Gen7.Common;

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary> /// <summary>
@ -12,7 +14,7 @@ public class Bulletproof : Script, IScriptFailIncomingMove
/// <inheritdoc /> /// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail) public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{ {
if (move.UseMove.HasFlag("ballistics")) if (move.UseMove.HasFlag(MoveFlags.Ballistics))
fail = true; fail = true;
} }
} }

View File

@ -11,7 +11,7 @@ public class IronFist : Script, IScriptChangeBasePower
/// <inheritdoc /> /// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{ {
if (move.UseMove.HasFlag("punch")) if (move.UseMove.HasFlag(MoveFlags.Punch))
basePower = basePower.MultiplyOrMax(1.2f); basePower = basePower.MultiplyOrMax(1.2f);
} }
} }

View File

@ -11,7 +11,7 @@ public class LiquidVoice : Script, IScriptChangeMoveType
/// <inheritdoc /> /// <inheritdoc />
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier) public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? typeIdentifier)
{ {
if (move.UseMove.HasFlag("sound") && if (move.UseMove.HasFlag(MoveFlags.Sound) &&
move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("water", out var waterType)) move.Battle.Library.StaticLibrary.Types.TryGetTypeIdentifier("water", out var waterType))
{ {
typeIdentifier = waterType; typeIdentifier = waterType;

View File

@ -11,7 +11,7 @@ public class MagicBounce : Script, IScriptChangeIncomingTargets
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets) public void ChangeIncomingTargets(IMoveChoice moveChoice, ref IReadOnlyList<IPokemon?> targets)
{ {
if (moveChoice.ChosenMove.MoveData.HasFlag("reflectable")) if (moveChoice.ChosenMove.MoveData.HasFlag(MoveFlags.Reflectable))
{ {
var target = targets[0]; var target = targets[0];
target?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target)); target?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));

View File

@ -11,7 +11,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
/// <inheritdoc /> /// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{ {
if (move.UseMove.HasFlag("pulse")) if (move.UseMove.HasFlag(MoveFlags.Pulse))
{ {
basePower = basePower.MultiplyOrMax(1.5f); basePower = basePower.MultiplyOrMax(1.5f);
} }
@ -23,7 +23,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs) if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
return; return;
if (healArgs.Move.UseMove.HasFlag("pulse")) if (healArgs.Move.UseMove.HasFlag(MoveFlags.Pulse))
healArgs.HealPercent *= 1.5f; healArgs.HealPercent *= 1.5f;
} }
} }

View File

@ -25,7 +25,7 @@ public class Overcoat : Script, IScriptIsInvulnerableToMove, IScriptCustomTrigge
/// <inheritdoc /> /// <inheritdoc />
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable) public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
{ {
if (move.UseMove.HasFlag("powder")) if (move.UseMove.HasFlag(MoveFlags.Powder))
{ {
invulnerable = true; invulnerable = true;
} }

View File

@ -11,7 +11,7 @@ public class Reckless : Script, IScriptChangeBasePower
/// <inheritdoc /> /// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{ {
if (move.UseMove.HasFlag("recoil")) if (move.UseMove.HasFlag(MoveFlags.Recoil))
{ {
basePower = basePower.MultiplyOrMax(1.2f); basePower = basePower.MultiplyOrMax(1.2f);
} }

View File

@ -11,7 +11,7 @@ public class Soundproof : Script, IScriptIsInvulnerableToMove
/// <inheritdoc /> /// <inheritdoc />
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable) public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
{ {
if (move.UseMove.HasFlag("sound")) if (move.UseMove.HasFlag(MoveFlags.Sound))
invulnerable = true; invulnerable = true;
} }
} }

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities; namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary> /// <summary>
@ -11,7 +13,7 @@ public class StrongJaw : Script, IScriptChangeBasePower
/// <inheritdoc /> /// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower) public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{ {
if (move.UseMove.HasFlag("bite")) if (move.UseMove.HasFlag(MoveFlags.Bite))
{ {
basePower = basePower.MultiplyOrMax(1.5f); basePower = basePower.MultiplyOrMax(1.5f);
} }

View File

@ -11,7 +11,7 @@ public class Triage : Script, IScriptChangePriority
/// <inheritdoc /> /// <inheritdoc />
public void ChangePriority(IMoveChoice choice, ref sbyte priority) public void ChangePriority(IMoveChoice choice, ref sbyte priority)
{ {
if (!choice.ChosenMove.MoveData.HasFlag("heal")) if (!choice.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
return; return;
if (priority == sbyte.MaxValue) if (priority == sbyte.MaxValue)
return; return;

View File

@ -21,7 +21,7 @@ public class Gravity : Script, IScriptFailIncomingMove, IScriptOnEndTurn, IScrip
/// <inheritdoc /> /// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail) public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{ {
if (move.UseMove.HasFlag("gravity")) if (move.UseMove.HasFlag(MoveFlags.Gravity))
fail = true; fail = true;
} }

View File

@ -35,7 +35,7 @@ public class SnatchEffect : Script, IScriptStopBeforeMove, IScriptOnEndTurn
/// <inheritdoc /> /// <inheritdoc />
public void StopBeforeMove(IExecutingMove move, ref bool stop) public void StopBeforeMove(IExecutingMove move, ref bool stop)
{ {
if (move.UseMove.HasFlag("snatch") && TryGetSnatcher(out var snatcher)) if (move.UseMove.HasFlag(MoveFlags.Snatch) && TryGetSnatcher(out var snatcher))
{ {
stop = true; stop = true;
var battleData = snatcher.BattleData; var battleData = snatcher.BattleData;

View File

@ -22,7 +22,7 @@ public class Sketch : Script, IScriptOnSecondaryEffect
} }
var lastMove = target.BattleData?.LastMoveChoice; var lastMove = target.BattleData?.LastMoveChoice;
if (lastMove == null || lastMove.ChosenMove.MoveData.HasFlag("not_sketchable")) if (lastMove == null || lastMove.ChosenMove.MoveData.HasFlag(MoveFlags.NotSketchable))
{ {
move.GetHitData(target, hit).Fail(); move.GetHitData(target, hit).Fail();
return; return;

View File

@ -23,14 +23,14 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (!executingMove.UseMove.HasFlag("hit_flying")) if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true; block = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{ {
if (!move.UseMove.HasFlag("effective_against_fly")) if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2; damage *= 2;
} }

View File

@ -23,14 +23,14 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (!executingMove.UseMove.HasFlag("hit_flying")) if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true; block = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{ {
if (!move.UseMove.HasFlag("effective_against_fly")) if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2; damage *= 2;
} }

View File

@ -23,14 +23,14 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (!executingMove.UseMove.HasFlag("hit_flying")) if (!executingMove.UseMove.HasFlag(MoveFlags.HitFlying))
block = true; block = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{ {
if (!move.UseMove.HasFlag("effective_against_fly")) if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstFly))
damage *= 2; damage *= 2;
} }

View File

@ -23,14 +23,14 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (!executingMove.UseMove.HasFlag("hit_underground")) if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderground))
block = true; block = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{ {
if (!move.UseMove.HasFlag("effective_against_underground")) if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderground))
damage *= 2; damage *= 2;
} }

View File

@ -23,14 +23,14 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (!executingMove.UseMove.HasFlag("hit_underwater")) if (!executingMove.UseMove.HasFlag(MoveFlags.HitUnderwater))
block = true; block = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage) public void ChangeIncomingMoveDamage(IExecutingMove move, IPokemon target, byte hit, ref uint damage)
{ {
if (!move.UseMove.HasFlag("effective_against_underwater")) if (!move.UseMove.HasFlag(MoveFlags.EffectiveAgainstUnderwater))
damage *= 2; damage *= 2;
} }

View File

@ -22,14 +22,14 @@ public class HealBlockEffect : Script, IScriptPreventMoveSelection, IScriptPreve
/// <inheritdoc /> /// <inheritdoc />
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent) public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{ {
if (choice.ChosenMove.MoveData.HasFlag("heal")) if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
prevent = true; prevent = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void PreventMove(IExecutingMove move, ref bool prevent) public void PreventMove(IExecutingMove move, ref bool prevent)
{ {
if (move.ChosenMove.MoveData.HasFlag("heal")) if (move.ChosenMove.MoveData.HasFlag(MoveFlags.Heal))
prevent = true; prevent = true;
} }

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon; namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "protect")] [Script(ScriptCategory.Pokemon, "protect")]
@ -9,7 +11,7 @@ public class ProtectionEffectScript : Script, IScriptBlockIncomingHit
if (target.BattleData == null) if (target.BattleData == null)
return; return;
if (!executingMove.UseMove.HasFlag("protect")) if (!executingMove.UseMove.HasFlag(MoveFlags.Protect))
return; return;
var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false); var args = new CustomTriggers.BypassProtectionArgs(executingMove, target, hitIndex, false);
executingMove.User.RunScriptHook<IScriptCustomTrigger>(x => executingMove.User.RunScriptHook<IScriptCustomTrigger>(x =>

View File

@ -8,7 +8,7 @@ public class SubstituteEffect(uint health) : Script, IScriptBlockIncomingHit
/// <inheritdoc /> /// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block) public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{ {
if (executingMove.UseMove.HasFlag("ignore-substitute")) if (executingMove.UseMove.HasFlag(MoveFlags.IgnoreSubstitute))
return; return;
var args = new CustomTriggers.BypassSubstituteArgs(executingMove, target, hitIndex, false); var args = new CustomTriggers.BypassSubstituteArgs(executingMove, target, hitIndex, false);

View File

@ -8,14 +8,14 @@ public class ThroatChopEffect : Script, IScriptPreventMoveSelection, IScriptFail
/// <inheritdoc /> /// <inheritdoc />
public void PreventMoveSelection(IMoveChoice choice, ref bool prevent) public void PreventMoveSelection(IMoveChoice choice, ref bool prevent)
{ {
if (choice.ChosenMove.MoveData.HasFlag("sound")) if (choice.ChosenMove.MoveData.HasFlag(MoveFlags.Sound))
prevent = true; prevent = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void FailMove(IExecutingMove move, ref bool fail) public void FailMove(IExecutingMove move, ref bool fail)
{ {
if (move.UseMove.HasFlag("sound")) if (move.UseMove.HasFlag(MoveFlags.Sound))
fail = true; fail = true;
} }

View File

@ -19,14 +19,14 @@ public class AromaVeilEffect : Script, IScriptFailIncomingMove, IScriptPreventIn
/// <inheritdoc /> /// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail) public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{ {
if (move.UseMove.HasFlag("mental") && move.UseMove.Category == MoveCategory.Status) if (move.UseMove.HasFlag(MoveFlags.Mental) && move.UseMove.Category == MoveCategory.Status)
fail = true; fail = true;
} }
/// <inheritdoc /> /// <inheritdoc />
public void PreventIncomingSecondaryEffect(IExecutingMove move, IPokemon target, byte hit, ref bool prevent) public void PreventIncomingSecondaryEffect(IExecutingMove move, IPokemon target, byte hit, ref bool prevent)
{ {
if (move.UseMove.HasFlag("mental")) if (move.UseMove.HasFlag(MoveFlags.Mental))
prevent = true; prevent = true;
} }
} }

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Status; namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "frozen")] [Script(ScriptCategory.Status, "frozen")]
@ -18,7 +20,7 @@ public class Frozen : Script, IScriptPreventMove, IScriptOnEndTurn
/// <inheritdoc /> /// <inheritdoc />
public void PreventMove(IExecutingMove move, ref bool prevent) public void PreventMove(IExecutingMove move, ref bool prevent)
{ {
if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag("defrost")) if (move.UseMove.MoveType.Name == "fire" || move.UseMove.HasFlag(MoveFlags.Defrost))
{ {
_pokemon?.ClearStatus(); _pokemon?.ClearStatus();
return; return;

View File

@ -36,7 +36,7 @@ public class Sleep : Script, IScriptPreventMove, IAIInfoScriptNumberTurnsLeft
return; return;
} }
if (move.UseMove.HasFlag("usable_while_asleep")) if (move.UseMove.HasFlag(MoveFlags.UsableWhileAsleep))
return; return;
var args = new CustomTriggers.BypassSleepArgs(move, false); var args = new CustomTriggers.BypassSleepArgs(move, false);