Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -10,12 +10,12 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Abilities;
|
||||
[Script(ScriptCategory.Ability, "dry_skin")]
|
||||
public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IAIInfoScriptExpectedEndOfTurnDamage
|
||||
{
|
||||
private IPokemon? _owningPokemon;
|
||||
private IBattlePokemon? _owningPokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAddedToParent(IScriptSource source)
|
||||
{
|
||||
if (source is not IPokemon pokemon)
|
||||
if (source is not IBattlePokemon pokemon)
|
||||
{
|
||||
throw new ArgumentException("DrySkin script must be added to a Pokemon.", nameof(source));
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
|
||||
public void ChangeDamageModifier(IExecutingMove move, IBattlePokemon target, byte hit, ref float modifier)
|
||||
{
|
||||
var hitType = move.GetHitData(target, hit).Type;
|
||||
if (hitType?.Name == TypeNames.Fire)
|
||||
@@ -33,7 +33,7 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
else if (hitType?.Name == TypeNames.Water)
|
||||
{
|
||||
modifier = 0;
|
||||
target.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Battle.EventHook.Invoke(new AbilityTriggerEvent(target));
|
||||
target.Heal(target.MaxHealth / 4);
|
||||
}
|
||||
}
|
||||
@@ -46,20 +46,20 @@ public class DrySkin : Script, IScriptChangeDamageModifier, IScriptOnEndTurn, IA
|
||||
var weather = battle.WeatherName;
|
||||
if (weather == ScriptUtils.ResolveName<Weather.Rain>())
|
||||
{
|
||||
_owningPokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Heal(_owningPokemon.MaxHealth / 8);
|
||||
}
|
||||
else if (weather == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
{
|
||||
_owningPokemon.BattleData?.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Battle.EventHook.Invoke(new AbilityTriggerEvent(_owningPokemon));
|
||||
_owningPokemon.Damage(_owningPokemon.MaxHealth / 8, DamageSource.Weather);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ExpectedEndOfTurnDamage(IPokemon pokemon, ref int damage)
|
||||
public void ExpectedEndOfTurnDamage(IBattlePokemon pokemon, ref int damage)
|
||||
{
|
||||
if (pokemon.BattleData?.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
if (pokemon.Battle.WeatherName == ScriptUtils.ResolveName<Weather.HarshSunlight>())
|
||||
{
|
||||
damage += (int)(pokemon.MaxHealth / 8f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user