Deukhoofd 7c270a6d52
All checks were successful
Build / Build (push) Successful in 1m1s
Finish script interface refactor
2025-07-06 10:27:56 +02:00

37 lines
1.3 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "electric_terrain")]
public class ElectricTerrain : Script, IScriptChangeBasePower, IScriptPreventStatusChange, IScriptPreventVolatileAdd
{
private static bool IsAffectedByTerrain(IPokemon pokemon) =>
!pokemon.IsFloating;
/// <inheritdoc />
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
if (!IsAffectedByTerrain(move.User))
return;
var type = move.GetHitData(target, hit).Type;
if (type?.Name == "electric")
basePower = basePower.MultiplyOrMax(1.5f);
}
/// <inheritdoc />
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
{
if (!IsAffectedByTerrain(pokemon))
return;
if (status == ScriptUtils.ResolveName<Status.Sleep>())
preventStatus = true;
}
/// <inheritdoc />
public void PreventVolatileAdd(IScriptSource parent, Script script, ref bool preventVolatileAdd)
{
if (parent is IPokemon pokemon && !IsAffectedByTerrain(pokemon))
return;
if (script is Pokemon.YawnEffect)
preventVolatileAdd = true;
}
}