Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -3,19 +3,19 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
||||
[Script(ScriptCategory.Weather, "desolate_lands")]
|
||||
public class DesolateLands : HarshSunlight, IScriptFailMove, IScriptOnSwitchOut, IScriptPreventWeatherChange
|
||||
{
|
||||
private readonly HashSet<IPokemon> _placers = [];
|
||||
private readonly HashSet<IBattlePokemon> _placers = [];
|
||||
|
||||
public void MarkAsPlaced(IPokemon pokemon)
|
||||
public void MarkAsPlaced(IBattlePokemon pokemon)
|
||||
{
|
||||
_placers.Add(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
_placers.Remove(oldPokemon);
|
||||
if (_placers.Count == 0)
|
||||
oldPokemon.BattleData?.Battle.SetWeather(null, 0);
|
||||
oldPokemon.Battle.SetWeather(null, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -48,7 +48,7 @@ public class Hail : Script, ILimitedTurnsScript, IScriptOnEndTurn, IAIInfoScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
if (pokemon.Types.Any(x => x.Name == TypeNames.Ice))
|
||||
return; // Ice types are immune to Hail damage.
|
||||
|
||||
@@ -34,7 +34,7 @@ public class HarshSunlight : Script, ILimitedTurnsScript, IScriptChangeBasePower
|
||||
private static readonly StringKey HydroSteamName = "hydro_steam";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
var hitType = move.GetHitData(target, hit).Type;
|
||||
if (hitType?.Name == TypeNames.Fire || move.UseMove.Name == HydroSteamName)
|
||||
@@ -62,7 +62,8 @@ public class HarshSunlight : Script, ILimitedTurnsScript, IScriptChangeBasePower
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void PreventStatusChange(IPokemon pokemon, StringKey status, bool selfInflicted, ref bool preventStatus)
|
||||
public void PreventStatusChange(IBattlePokemon pokemon, StringKey status, bool selfInflicted,
|
||||
ref bool preventStatus)
|
||||
{
|
||||
if (status == ScriptUtils.ResolveName<Status.Frozen>())
|
||||
{
|
||||
@@ -71,7 +72,8 @@ public class HarshSunlight : Script, ILimitedTurnsScript, IScriptChangeBasePower
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
if (executingMove.UseMove.Name == MoveNames.Thunder || executingMove.UseMove.Name == MoveNames.Hurricane)
|
||||
{
|
||||
|
||||
@@ -3,19 +3,19 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
||||
[Script(ScriptCategory.Weather, "primordial_sea")]
|
||||
public class PrimordialSea : Rain, IScriptFailMove, IScriptOnSwitchOut, IScriptPreventWeatherChange
|
||||
{
|
||||
private HashSet<IPokemon> _placers = new();
|
||||
private HashSet<IBattlePokemon> _placers = new();
|
||||
|
||||
public void MarkAsPlaced(IPokemon pokemon)
|
||||
public void MarkAsPlaced(IBattlePokemon pokemon)
|
||||
{
|
||||
_placers.Add(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
_placers.Remove(oldPokemon);
|
||||
if (_placers.Count == 0)
|
||||
oldPokemon.BattleData?.Battle.SetWeather(null, 0);
|
||||
oldPokemon.Battle.SetWeather(null, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -25,7 +25,7 @@ public class Rain : Script, ILimitedTurnsScript, IScriptChangeBasePower, IScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
var hitType = move.GetHitData(target, hit).Type;
|
||||
if (hitType?.Name == TypeNames.Water)
|
||||
@@ -46,7 +46,8 @@ public class Rain : Script, ILimitedTurnsScript, IScriptChangeBasePower, IScript
|
||||
private static readonly StringKey SandsearStormName = "sandsear_storm";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref int modifiedAccuracy)
|
||||
public void ChangeAccuracy(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
ref int modifiedAccuracy)
|
||||
{
|
||||
var moveName = executingMove.UseMove.Name;
|
||||
if (moveName == MoveNames.Thunder || moveName == MoveNames.Hurricane || moveName == BleakwindStormName ||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class Sandstorm : Script, IScriptChangeBasePower, IScriptChangeDefensiveS
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeDefensiveStatValue(IExecutingMove move, IPokemon target, byte hit, uint offensiveStat,
|
||||
public void ChangeDefensiveStatValue(IExecutingMove move, IBattlePokemon target, byte hit, uint offensiveStat,
|
||||
ImmutableStatisticSet<uint> targetStats, Statistic stat, ref uint value)
|
||||
{
|
||||
if (stat == Statistic.SpecialDefense && target.Types.Any(x => x.Name == TypeNames.Rock))
|
||||
@@ -36,14 +36,14 @@ public class Sandstorm : Script, IScriptChangeBasePower, IScriptChangeDefensiveS
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
|
||||
public void ChangeBasePower(IExecutingMove move, IBattlePokemon target, byte hit, ref ushort basePower)
|
||||
{
|
||||
if (move.UseMove.Name == MoveNames.SolarBeam)
|
||||
basePower /= 2;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
if (pokemon.Types.Any(x => x.Name == TypeNames.Rock || x.Name == TypeNames.Ground || x.Name == TypeNames.Steel))
|
||||
return; // Rock, Ground, and Steel types are immune to Sandstorm damage.
|
||||
|
||||
@@ -8,19 +8,19 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Weather;
|
||||
[Script(ScriptCategory.Weather, "strong_winds")]
|
||||
public class StrongWinds : Script, IScriptOnSwitchOut, IScriptChangeTypesForMove, IScriptPreventWeatherChange
|
||||
{
|
||||
private HashSet<IPokemon> _placers = new();
|
||||
private HashSet<IBattlePokemon> _placers = new();
|
||||
|
||||
public void MarkAsPlaced(IPokemon pokemon)
|
||||
public void MarkAsPlaced(IBattlePokemon pokemon)
|
||||
{
|
||||
_placers.Add(pokemon);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void OnSwitchOut(IPokemon oldPokemon, byte position)
|
||||
public void OnSwitchOut(IBattlePokemon oldPokemon, byte position)
|
||||
{
|
||||
_placers.Remove(oldPokemon);
|
||||
if (_placers.Count == 0)
|
||||
oldPokemon.BattleData?.Battle.SetWeather(null, 0);
|
||||
oldPokemon.Battle.SetWeather(null, 0);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -33,7 +33,7 @@ public class StrongWinds : Script, IScriptOnSwitchOut, IScriptChangeTypesForMove
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeTypesForMove(IExecutingMove executingMove, IPokemon target, byte hitIndex,
|
||||
public void ChangeTypesForMove(IExecutingMove executingMove, IBattlePokemon target, byte hitIndex,
|
||||
IList<TypeIdentifier> types)
|
||||
{
|
||||
var flyingType = types.FirstOrDefault(x => x.Name == TypeNames.Flying);
|
||||
|
||||
Reference in New Issue
Block a user