Files
PkmnLib.NET/Plugins/PkmnLib.Plugin.Gen7/Scripts/Moves/NaturePower.cs
Deukhoofd cc091d5327
Some checks failed
Build / Build (push) Failing after 35s
Update TUnit, warning cleanup
2026-07-05 13:46:57 +02:00

51 lines
2.2 KiB
C#

using PkmnLib.Plugin.Gen7.Scripts.Utils;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "nature_power")]
public class NaturePower : Script, IScriptChangeMove
{
/// <inheritdoc />
public void ChangeMove(IMoveChoice choice, ref StringKey moveName)
{
var battleData = choice.User.BattleData;
if (battleData is null)
return;
var newMoveName = GetMoveName(battleData.Battle);
if (newMoveName is null)
{
choice.Fail();
return;
}
moveName = newMoveName.Value;
}
private static StringKey? GetMoveName(IBattle battle)
{
var movesLibrary = battle.Library.StaticLibrary.Moves;
var environmentCategory = battle.GetEnvironmentCategory();
var moveName = environmentCategory switch
{
EnvironmentHelper.EnvironmentCategory.Electric when movesLibrary.TryGet("thunderbolt",
out var thunderboltMove) => (StringKey?)thunderboltMove.Name,
EnvironmentHelper.EnvironmentCategory.Fairy when movesLibrary.TryGet("moonblast", out var moonblastMove) =>
moonblastMove.Name,
EnvironmentHelper.EnvironmentCategory.Grass when movesLibrary.TryGet("energy_ball", out var energyballMove)
=> energyballMove.Name,
EnvironmentHelper.EnvironmentCategory.Psychic when movesLibrary.TryGet("psychic", out var psychicMove) =>
psychicMove.Name,
EnvironmentHelper.EnvironmentCategory.Rock when movesLibrary.TryGet("power_gem", out var rockMove) =>
rockMove.Name,
EnvironmentHelper.EnvironmentCategory.Ground when movesLibrary.TryGet("earth_power", out var groundMove) =>
groundMove.Name,
EnvironmentHelper.EnvironmentCategory.Ice when movesLibrary.TryGet("ice_beam", out var iceMove) => iceMove
.Name,
EnvironmentHelper.EnvironmentCategory.Water when movesLibrary.TryGet("hydro_pump", out var waterMove) =>
waterMove.Name,
EnvironmentHelper.EnvironmentCategory.Normal when movesLibrary.TryGet("tri_attack", out var normalMove) =>
normalMove.Name,
_ => null,
};
return moveName;
}
}