36 lines
1.2 KiB
C#

namespace PkmnLib.Plugin.Gen7.Scripts.Terrain;
[Script(ScriptCategory.Terrain, "psychic_terrain")]
public class PsychicTerrain : Script, IScriptIsInvulnerableToMove, IScriptChangeBasePower
{
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;
// It boosts the power of Psychic-type moves used by affected Pokémon by 50% (regardless of whether the target of
// the move is affected by Psychic Terrain).
var type = move.GetHitData(target, hit).Type;
if (type?.Name == "psychic")
{
basePower = basePower.MultiplyOrMax(1.5f);
}
}
/// <inheritdoc />
public void IsInvulnerableToMove(IExecutingMove move, IPokemon target, ref bool invulnerable)
{
if (!IsAffectedByTerrain(target))
return;
// Psychic Terrain prevents priority moves from affecting affected Pokémon.
if (move.MoveChoice.Priority > 0)
{
invulnerable = true;
}
}
}