More unit tests, fixes

This commit is contained in:
2026-07-05 19:45:40 +02:00
parent db839ac214
commit 2f51e27811
18 changed files with 1499 additions and 19 deletions

View File

@@ -3,10 +3,9 @@ using PkmnLib.Plugin.Gen7.Scripts.Side;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
[Script(ScriptCategory.Move, "echoed_voice")]
public class EchoedVoice : Script, IScriptOnSecondaryEffect, IScriptChangeDamageModifier
public class EchoedVoice : Script, IScriptOnSecondaryEffect, IScriptChangeBasePower
{
/// <inheritdoc />
public void ChangeDamageModifier(IExecutingMove move, IPokemon target, byte hit, ref float modifier)
public void ChangeBasePower(IExecutingMove move, IPokemon target, byte hit, ref ushort basePower)
{
var battleData = move.User.BattleData;
if (battleData == null)
@@ -16,7 +15,8 @@ public class EchoedVoice : Script, IScriptOnSecondaryEffect, IScriptChangeDamage
if (echoedVoiceData == null)
return;
modifier *= 2;
var newBasePower = basePower + (ushort)(echoedVoiceData.Stacks * 40);
basePower = (ushort)Math.Min(newBasePower, 200);
}
/// <inheritdoc />

View File

@@ -9,14 +9,19 @@ public class ElectroBall : Script, IScriptChangeBasePower
var user = move.User;
var targetSpeed = target.BoostedStats.Speed;
var userSpeed = user.BoostedStats.Speed;
if (targetSpeed == 0)
{
basePower = 40;
return;
}
var ratio = (float)userSpeed / targetSpeed;
basePower = ratio switch
{
> 4 => 150,
> 3 => 120,
> 2 => 80,
> 1 => 60,
>= 4 => 150,
>= 3 => 120,
>= 2 => 80,
>= 1 => 60,
_ => 40,
};
}

View File

@@ -1,3 +1,4 @@
using System.Collections.Frozen;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
namespace PkmnLib.Plugin.Gen7.Scripts.Moves;
@@ -13,7 +14,8 @@ public class Encore : Script, IScriptOnSecondaryEffect
return;
var lastMove = target.BattleData?.LastMoveChoice;
if (lastMove == null || battle.Library.MiscLibrary.IsReplacementChoice(lastMove))
if (lastMove == null || battle.Library.MiscLibrary.IsReplacementChoice(lastMove) ||
lastMove.ChosenMove.MoveData.HasFlag(MoveFlags.CantRepeat))
{
move.GetHitData(target, hit).Fail();
return;

View File

@@ -6,7 +6,7 @@ public class EndureEffect : Script, IScriptOnEndTurn, IScriptChangeIncomingDamag
/// <inheritdoc />
public void ChangeIncomingDamage(IPokemon pokemon, DamageSource source, ref uint damage)
{
if (damage > pokemon.CurrentHealth)
if (damage >= pokemon.CurrentHealth)
damage = pokemon.CurrentHealth - 1;
}

View File

@@ -4,11 +4,22 @@ namespace PkmnLib.Plugin.Gen7.Scripts.Side;
/// Just here to indicate that a Pokemon on this side has used Echoed Voice.
/// </summary>
[Script(ScriptCategory.Side, "echoed_voice_data")]
public class EchoedVoiceData : Script, IScriptOnEndTurn
public class EchoedVoiceData : Script, IScriptOnBeforeMoveChoice, IScriptStack
{
/// <inheritdoc />
public void OnEndTurn(IScriptSource owner, IBattle battle)
private int _stacks = 1;
public int Stacks => _stacks;
public void OnBeforeMoveChoice(IMoveChoice moveChoice)
{
RemoveSelf();
if (moveChoice.ChosenMove.MoveData.Name != "echoed_voice")
{
RemoveSelf();
}
}
public void Stack()
{
_stacks++;
}
}