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

@@ -684,6 +684,13 @@
"tinted_lens": {
"effect": "tinted_lens"
},
"torrent": {
"effect": "power_up_type_at_low_health",
"parameters": {
"type": "water",
"threshold": 0.33333
}
},
"tough_claws": {
"effect": "tough_claws"
},

View File

@@ -11852,6 +11852,25 @@
}
}
},
{
"name": "thunder_fang",
"type": "electric",
"power": 65,
"pp": 15,
"accuracy": 95,
"priority": 0,
"target": "Any",
"category": "physical",
"flags": [
"contact",
"protect",
"mirror",
"bite"
],
"effect": {
"name": "thunder_fang"
}
},
{
"name": "thunder_punch",
"type": "electric",

View File

@@ -132,7 +132,7 @@ public class Gen7BattleStatCalculator : IBattleStatCalculator
4 => 6.0f / 2.0f,
5 => 7.0f / 2.0f,
6 => 8.0f / 2.0f,
_ => throw new ArgumentException("Stat boost was out of expected range of -6 to 6"),
_ => throw new ArgumentException($"Stat boost was out of expected range of -6 to 6: {boost}"),
};
}
}

View File

@@ -14,6 +14,10 @@ public class Gen7MiscLibrary : IMiscLibrary
public ITurnChoice ReplacementChoice(IPokemon user, byte targetSide, byte targetPosition) =>
new MoveChoice(user, new LearnedMoveImpl(_struggleData, MoveLearnMethod.Unknown), targetSide, targetPosition);
/// <inheritdoc />
public bool IsReplacementChoice(ITurnChoice choice) =>
choice is MoveChoice moveChoice && moveChoice.ChosenMove.MoveData == _struggleData;
/// <inheritdoc />
public TimeOfDay GetTimeOfDay()
{

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);
}
}
}