Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/Camouflage.cs

44 lines
2.2 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "camouflage")]
public class Camouflage : Script, IScriptOnSecondaryEffect
{
/// <inheritdoc />
public void OnSecondaryEffect(IExecutingMove move, IBattlePokemon target, byte hit)
{
var type = GetTypeIdentifier(move.Battle);
if (type == null)
return;
move.User.SetTypes([type.Value]);
}
private static TypeIdentifier? GetTypeIdentifier(IBattle battle)
{
var typesLibrary = battle.Library.StaticLibrary.Types;
var environmentCategory = battle.GetEnvironmentCategory();
return environmentCategory switch
{
EnvironmentHelper.EnvironmentCategory.Electric when typesLibrary.TryGetTypeIdentifier(TypeNames.Electric,
out var electricType) => electricType,
EnvironmentHelper.EnvironmentCategory.Fairy when typesLibrary.TryGetTypeIdentifier(TypeNames.Fairy,
out var fairyType) => fairyType,
EnvironmentHelper.EnvironmentCategory.Grass when typesLibrary.TryGetTypeIdentifier(TypeNames.Grass,
out var grassType) => grassType,
EnvironmentHelper.EnvironmentCategory.Psychic when typesLibrary.TryGetTypeIdentifier(TypeNames.Psychic,
out var psychicType) => psychicType,
EnvironmentHelper.EnvironmentCategory.Rock when typesLibrary.TryGetTypeIdentifier(TypeNames.Rock,
out var rockType) => rockType,
EnvironmentHelper.EnvironmentCategory.Ground when typesLibrary.TryGetTypeIdentifier(TypeNames.Ground,
out var groundType) => groundType,
EnvironmentHelper.EnvironmentCategory.Ice when typesLibrary.TryGetTypeIdentifier(TypeNames.Ice,
out var iceType) => iceType,
EnvironmentHelper.EnvironmentCategory.Water when typesLibrary.TryGetTypeIdentifier(TypeNames.Water,
out var waterType) => waterType,
EnvironmentHelper.EnvironmentCategory.Normal when typesLibrary.TryGetTypeIdentifier(TypeNames.Normal,
out var normalType) => normalType,
_ => null,
};
}
}