Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -17,7 +17,7 @@ public class EvolutionItem : ItemScript
|
||||
public override ItemTargetType TargetType => ItemTargetType.OwnPokemon;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IPokemon target)
|
||||
public override bool IsTargetValid(IBattlePokemon target)
|
||||
{
|
||||
foreach (var x in target.Species.EvolutionData)
|
||||
{
|
||||
@@ -33,7 +33,7 @@ public class EvolutionItem : ItemScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
||||
{
|
||||
var evolutionData = target.Species.EvolutionData.FirstOrDefault(x =>
|
||||
{
|
||||
|
||||
@@ -29,10 +29,11 @@ public class HealingItem : ItemScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsTargetValid(IPokemon target) => !target.IsFainted && target.CurrentHealth < target.MaxHealth;
|
||||
public override bool IsTargetValid(IBattlePokemon target) =>
|
||||
!target.IsFainted && target.CurrentHealth < target.MaxHealth;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUseWithTarget(IPokemon target, EventHook eventHook)
|
||||
public override void OnUseWithTarget(IBattlePokemon target, EventHook eventHook)
|
||||
{
|
||||
target.Heal(_healAmount, customEventHook: eventHook);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class FastBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
var modifier = target.Form.BaseStats.Speed >= 100 ? 4f : 1f;
|
||||
catchRate = catchRate.MultiplyOrMax(modifier);
|
||||
|
||||
@@ -9,12 +9,12 @@ public class FriendBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAfterSuccessfulCapture(IPokemon target)
|
||||
public override void OnAfterSuccessfulCapture(IBattlePokemon target)
|
||||
{
|
||||
target.Happiness = 200;
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@ public class HealBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnAfterSuccessfulCapture(IPokemon target)
|
||||
public override void OnAfterSuccessfulCapture(IBattlePokemon target)
|
||||
{
|
||||
target.Heal(target.MaxHealth, true, forceHeal: true);
|
||||
target.ClearStatus();
|
||||
|
||||
@@ -9,7 +9,7 @@ public class HeavyBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
var weight = target.WeightInKg;
|
||||
switch (weight)
|
||||
|
||||
@@ -9,12 +9,10 @@ public class LevelBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.BattleData is null)
|
||||
return;
|
||||
var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0;
|
||||
var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
|
||||
var opponentSide = target.SideIndex == 0 ? 1 : 0;
|
||||
var opponent = target.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
|
||||
if (opponent is null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ public class LoveBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.BattleData is null)
|
||||
return;
|
||||
var opponentSide = target.BattleData.SideIndex == 0 ? 1 : 0;
|
||||
var opponent = target.BattleData.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
|
||||
var opponentSide = target.SideIndex == 0 ? 1 : 0;
|
||||
var opponent = target.Battle.Sides[opponentSide].Pokemon.FirstOrDefault(x => x is not null);
|
||||
if (opponent is null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class MoonBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.Species.EvolutionData.Any(x =>
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ public class NestBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.Level >= 30)
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@ public class NetBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.Types.Any(x => x.Name == TypeNames.Water || x.Name == TypeNames.Bug))
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PokeballFlatModifier : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
catchRate = catchRate.MultiplyOrMax(_catchModifier);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public class QuickBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
var battleData = target;
|
||||
if (battleData is null)
|
||||
return;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RepeatBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
if (target.Library.CaptureLibrary is Gen7CaptureLibrary captureLibrary &&
|
||||
captureLibrary.HasPokemonBeenCaughtBefore(target.Species))
|
||||
|
||||
@@ -9,9 +9,9 @@ public class TimerBall : PokeballScript
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void ChangeCatchRate(IPokemon target, ref byte catchRate)
|
||||
public override void ChangeCatchRate(IBattlePokemon target, ref byte catchRate)
|
||||
{
|
||||
var battleData = target.BattleData;
|
||||
var battleData = target;
|
||||
if (battleData is null)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user