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;
if (abilityName == BulletproofName)
return move.HasFlag("bomb");
return move.HasFlag("ballistics");
if (abilityName == FlashFireName)
return moveType.Name == FireName;
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.
/// </summary>
bool HasFlag(StringKey key);
/// <summary>
/// A readonly list of all flags on the move.
/// </summary>
IReadOnlyCollection<StringKey> Flags { get; }
}
/// <inheritdoc />
@ -196,6 +201,9 @@ public class MoveDataImpl : IMoveData
/// <inheritdoc />
public bool HasFlag(StringKey key) => _flags.Contains(key);
/// <inheritdoc />
public IReadOnlyCollection<StringKey> Flags => _flags;
}
public static class MoveTargetHelpers

View File

@ -4,7 +4,9 @@ using PkmnLib.Dynamic.Libraries;
using PkmnLib.Dynamic.Plugins;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Dynamic.ScriptHandling.Registry;
using PkmnLib.Plugin.Gen7.Common;
using PkmnLib.Static.Moves;
using PkmnLib.Static.Utils;
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();
}
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)
{
/// <inheritdoc />

View File

@ -1,5 +1,6 @@
using PkmnLib.Dynamic.Models;
using PkmnLib.Dynamic.ScriptHandling;
using PkmnLib.Plugin.Gen7.Common;
using PkmnLib.Plugin.Gen7.Scripts.Abilities;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Static;
@ -20,7 +21,7 @@ public class MegaLauncherTests
var user = Substitute.For<IPokemon>();
move.User.Returns(user);
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());
move.User.AbilityScript.Returns(megaLauncher);
move.GetScripts().Returns(new ScriptIterator([megaLauncher]));

View File

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

View File

@ -4,4 +4,5 @@ global using PkmnLib.Dynamic.Events;
global using PkmnLib.Dynamic.Models;
global using PkmnLib.Dynamic.Models.Choices;
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;
/// <summary>
@ -12,7 +14,7 @@ public class Bulletproof : Script, IScriptFailIncomingMove
/// <inheritdoc />
public void FailIncomingMove(IExecutingMove move, IPokemon target, ref bool fail)
{
if (move.UseMove.HasFlag("ballistics"))
if (move.UseMove.HasFlag(MoveFlags.Ballistics))
fail = true;
}
}

View File

@ -11,7 +11,7 @@ public class IronFist : Script, IScriptChangeBasePower
/// <inheritdoc />
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);
}
}

View File

@ -11,7 +11,7 @@ public class LiquidVoice : Script, IScriptChangeMoveType
/// <inheritdoc />
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))
{
typeIdentifier = waterType;

View File

@ -11,7 +11,7 @@ public class MagicBounce : Script, IScriptChangeIncomingTargets
/// <inheritdoc />
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];
target?.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));

View File

@ -11,7 +11,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
/// <inheritdoc />
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);
}
@ -23,7 +23,7 @@ public class MegaLauncher : Script, IScriptChangeBasePower, IScriptCustomTrigger
if (eventName != CustomTriggers.ModifyHealPercent || args is not CustomTriggers.ModifyHealPercentArgs healArgs)
return;
if (healArgs.Move.UseMove.HasFlag("pulse"))
if (healArgs.Move.UseMove.HasFlag(MoveFlags.Pulse))
healArgs.HealPercent *= 1.5f;
}
}

View File

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

View File

@ -11,7 +11,7 @@ public class Reckless : Script, IScriptChangeBasePower
/// <inheritdoc />
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);
}

View File

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

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
/// <summary>
@ -11,7 +13,7 @@ public class StrongJaw : Script, IScriptChangeBasePower
/// <inheritdoc />
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);
}

View File

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

View File

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

View File

@ -35,7 +35,7 @@ public class SnatchEffect : Script, IScriptStopBeforeMove, IScriptOnEndTurn
/// <inheritdoc />
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;
var battleData = snatcher.BattleData;

View File

@ -22,7 +22,7 @@ public class Sketch : Script, IScriptOnSecondaryEffect
}
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();
return;

View File

@ -23,14 +23,14 @@ public class ChargeBounceEffect : Script, IScriptForceTurnSelection, IScriptChan
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}

View File

@ -23,14 +23,14 @@ public class ChargeFlyEffect : Script, IScriptForceTurnSelection, IScriptChangeI
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}

View File

@ -23,14 +23,14 @@ public class ChargeSkyDropEffect : Script, IScriptForceTurnSelection, IScriptCha
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}

View File

@ -23,14 +23,14 @@ public class DigEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomin
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}

View File

@ -23,14 +23,14 @@ public class DiveEffect : Script, IScriptForceTurnSelection, IScriptChangeIncomi
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}

View File

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

View File

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

View File

@ -8,7 +8,7 @@ public class SubstituteEffect(uint health) : Script, IScriptBlockIncomingHit
/// <inheritdoc />
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;
var args = new CustomTriggers.BypassSubstituteArgs(executingMove, target, hitIndex, false);

View File

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

View File

@ -19,14 +19,14 @@ public class AromaVeilEffect : Script, IScriptFailIncomingMove, IScriptPreventIn
/// <inheritdoc />
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;
}
/// <inheritdoc />
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;
}
}

View File

@ -1,3 +1,5 @@
using PkmnLib.Plugin.Gen7.Common;
namespace PkmnLib.Plugin.Gen7.Scripts.Status;
[Script(ScriptCategory.Status, "frozen")]
@ -18,7 +20,7 @@ public class Frozen : Script, IScriptPreventMove, IScriptOnEndTurn
/// <inheritdoc />
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();
return;

View File

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