Some initial work on prescient AI, AI runner, and some random fixes
All checks were successful
Build / Build (push) Successful in 1m3s

This commit is contained in:
2025-07-05 17:48:51 +02:00
parent 7b25161a8d
commit d57076374f
9 changed files with 174 additions and 21 deletions

View File

@@ -2,6 +2,8 @@ using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Pcg;
using PkmnLib.Dynamic.Models;
using PkmnLib.Plugin.Gen7.Scripts.Moves;
using PkmnLib.Plugin.Gen7.Scripts.Pokemon;
using PkmnLib.Static;
using PkmnLib.Static.Species;
using PkmnLib.Static.Utils;
@@ -113,6 +115,7 @@ public class DeepCloneTests
battle.Sides[1].SwapPokemon(0, party2[0]);
party1[0]!.ChangeStatBoost(Statistic.Defense, 2, true, false);
await Assert.That(party1[0]!.StatBoost.Defense).IsEqualTo((sbyte)2);
party1[0]!.Volatile.Add(new ChargeBounceEffect(party1[0]!));
var clone = battle.DeepClone();
await Assert.That(clone).IsNotEqualTo(battle);
@@ -125,12 +128,26 @@ public class DeepCloneTests
await Assert.That(clone.Library).IsEqualTo(battle.Library);
var pokemon = clone.Sides[0].Pokemon[0]!;
await Assert.That(pokemon).IsNotNull();
await Assert.That(pokemon).IsNotEqualTo(battle.Sides[0].Pokemon[0]);
await Assert.That(pokemon.BattleData).IsNotNull();
await Assert.That(pokemon.BattleData).IsNotEqualTo(battle.Sides[0].Pokemon[0]!.BattleData);
await Assert.That(pokemon.BattleData!.Battle).IsEqualTo(clone);
await Assert.That(pokemon.BattleData!.SeenOpponents).Contains(clone.Sides[1].Pokemon[0]!);
await Assert.That(pokemon.BattleData!.SeenOpponents).DoesNotContain(battle.Sides[1].Pokemon[0]!);
await Assert.That(pokemon.StatBoost.Defense).IsEqualTo((sbyte)2);
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNotNull();
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNotEqualTo(
battle.Sides[0].Pokemon[0]!.Volatile.Get<ChargeBounceEffect>());
var ownerGetter =
typeof(ChargeBounceEffect).GetField("_owner", BindingFlags.NonPublic | BindingFlags.Instance)!;
var owner = ownerGetter.GetValue(pokemon.Volatile.Get<ChargeBounceEffect>()!);
await Assert.That(owner).IsEqualTo(pokemon);
pokemon.Volatile.Remove<ChargeBounceEffect>();
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNull();
await Assert.That(battle.Sides[0].Pokemon[0]!.Volatile.Get<ChargeBounceEffect>()).IsNotNull();
}
/// <summary>