Initial setup for testing AI performance, random fixes
All checks were successful
Build / Build (push) Successful in 54s

This commit is contained in:
2025-07-05 13:56:33 +02:00
parent 4499927551
commit 32aaa5150a
33 changed files with 511 additions and 26 deletions

View File

@@ -11,6 +11,9 @@ public class WonderGuard : Script, IScriptBlockIncomingHit
/// <inheritdoc />
public void BlockIncomingHit(IExecutingMove executingMove, IPokemon target, byte hitIndex, ref bool block)
{
var type = executingMove.GetHitData(target, hitIndex).Type;
if (type is null || type.Value.Value == 0)
return;
var effectiveness = executingMove.GetHitData(target, hitIndex).Effectiveness;
if (!(effectiveness <= 1.0))
return;

View File

@@ -14,8 +14,8 @@ public class Encore : Script, IScriptOnSecondaryEffect
var currentTurn = battle.ChoiceQueue!.LastRanChoice;
var lastMove = battle.PreviousTurnChoices.SelectMany(x => x).OfType<IMoveChoice>()
.TakeWhile(x => x != currentTurn).LastOrDefault(x => x.User == target);
if (lastMove == null)
.TakeWhile(x => !Equals(x, currentTurn)).LastOrDefault(x => x.User == target);
if (lastMove == null || battle.Library.MiscLibrary.IsReplacementChoice(lastMove))
{
move.GetHitData(target, hit).Fail();
return;

View File

@@ -48,7 +48,6 @@ public class BideEffect : Script, IScriptForceTurnSelection, IScriptOnIncomingHi
choice = _choice;
return;
}
var opposingSideIndex = (byte)(_owner.BattleData?.SideIndex == 0 ? 1 : 0);
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", opposingSideIndex, position);
choice = _choice = TurnChoiceHelper.CreateMoveChoice(_owner, "bide", ownerBattleData.SideIndex, position);
}
}

View File

@@ -1,3 +1,4 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
[Script(ScriptCategory.Pokemon, "require_charge")]
public class RequireChargeEffect(IPokemon owner, StringKey moveName) : BaseChargeEffect(owner, moveName);

View File

@@ -1,10 +1,17 @@
namespace PkmnLib.Plugin.Gen7.Scripts.Pokemon;
public class TruantEffect(IPokemon owner) : Script, IScriptForceTurnSelection
[Script(ScriptCategory.Pokemon, "truant_effect")]
public class TruantEffect(IPokemon owner) : Script, IScriptForceTurnSelection, IScriptOnEndTurn
{
/// <inheritdoc />
public void ForceTurnSelection(IBattle battle, byte sideIndex, byte position, ref ITurnChoice? choice)
{
choice = new PassChoice(owner);
}
/// <inheritdoc />
public void OnEndTurn(IScriptSource _, IBattle battle)
{
RemoveSelf();
}
}

View File

@@ -61,6 +61,7 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
if (_user == null)
return;
List<PokemonTurn>? pokemonToRemove = null;
foreach (var pokemonTurn in _targetedPokemon.Where(x => x.Pokemon.BattleData?.IsOnBattlefield == true))
{
var pokemon = pokemonTurn.Pokemon;
@@ -68,8 +69,15 @@ public class WhirlpoolEffect : Script, IScriptOnEndTurn, IScriptPreventOpponentR
pokemonTurn.Turns--;
if (pokemonTurn.Turns <= 0)
{
_targetedPokemon.Remove(pokemonTurn);
pokemonToRemove ??= [];
pokemonToRemove.Add(pokemonTurn);
}
}
if (pokemonToRemove == null)
return;
foreach (var turn in pokemonToRemove)
{
_targetedPokemon.Remove(turn);
}
}
}