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:
@@ -1,23 +1,27 @@
|
||||
using PkmnLib.Plugin.Gen7.Scripts.Status;
|
||||
|
||||
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
|
||||
|
||||
[Script(ScriptCategory.Move, "refresh")]
|
||||
public class Refresh : Script, IScriptOnSecondaryEffect
|
||||
{
|
||||
private static readonly StringKey[] CurableStatuses =
|
||||
[
|
||||
ScriptUtils.ResolveName<Paralyzed>(), ScriptUtils.ResolveName<Burned>(),
|
||||
ScriptUtils.ResolveName<Poisoned>(), ScriptUtils.ResolveName<BadlyPoisoned>(),
|
||||
];
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSecondaryEffect(IExecutingMove move, IPokemon target, byte hit)
|
||||
{
|
||||
var userStatus = move.User.StatusScript;
|
||||
switch (userStatus.Script?.Name)
|
||||
if (userStatus.Script is { } statusScript && CurableStatuses.Contains(statusScript.Name))
|
||||
{
|
||||
case "paralyzed":
|
||||
case "burned":
|
||||
case "poisoned":
|
||||
case "badly_poisoned":
|
||||
move.User.ClearStatus();
|
||||
break;
|
||||
default:
|
||||
move.GetHitData(target, hit).Fail();
|
||||
break;
|
||||
move.User.ClearStatus();
|
||||
}
|
||||
else
|
||||
{
|
||||
move.GetHitData(target, hit).Fail();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user