Replace all raw string comparisons with StringKey, source generator that creates cache keys for all names for Gen7 plugin
All checks were successful
Build / Build (push) Successful in 2m21s
All checks were successful
Build / Build (push) Successful in 2m21s
This commit is contained in:
@@ -3,6 +3,14 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
[Script(ScriptCategory.Move, "techno_blast")]
|
||||
public class TechnoBlast : Script, IScriptChangeMoveType
|
||||
{
|
||||
private static readonly Dictionary<StringKey, StringKey> DriveTypes = new()
|
||||
{
|
||||
{ ItemNames.BurnDrive, TypeNames.Fire },
|
||||
{ ItemNames.ChillDrive, TypeNames.Ice },
|
||||
{ ItemNames.DouseDrive, TypeNames.Water },
|
||||
{ ItemNames.ShockDrive, TypeNames.Electric },
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeMoveType(IExecutingMove move, IPokemon target, byte hit, ref TypeIdentifier? moveType)
|
||||
{
|
||||
@@ -11,13 +19,10 @@ public class TechnoBlast : Script, IScriptChangeMoveType
|
||||
return;
|
||||
var typeLibrary = target.Library.StaticLibrary.Types;
|
||||
|
||||
moveType = heldItem.Name.ToString().ToLowerInvariant() switch
|
||||
if (DriveTypes.TryGetValue(heldItem.Name, out var typeName) &&
|
||||
typeLibrary.TryGetTypeIdentifier(typeName, out var type))
|
||||
{
|
||||
"burn_drive" when typeLibrary.TryGetTypeIdentifier("fire", out var fire) => fire,
|
||||
"chill_drive" when typeLibrary.TryGetTypeIdentifier("ice", out var ice) => ice,
|
||||
"douse_drive" when typeLibrary.TryGetTypeIdentifier("water", out var water) => water,
|
||||
"shock_drive" when typeLibrary.TryGetTypeIdentifier("electric", out var electric) => electric,
|
||||
_ => moveType,
|
||||
};
|
||||
moveType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user