Move all battle state from IPokemon to an ephemeral IBattlePokemon wrapper
This commit is contained in:
@@ -110,11 +110,12 @@ public class DeepCloneTests
|
||||
new BattlePartyImpl(party2, [new ResponsibleIndex(1, 0)]),
|
||||
};
|
||||
using var battle = new BattleImpl(library, parties, false, 2, 3, false, "grass", 0);
|
||||
battle.Sides[0].SwapPokemon(0, party1[0]);
|
||||
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]!));
|
||||
battle.Sides[0].SendOut(0, party1[0]!);
|
||||
battle.Sides[1].SendOut(0, party2[0]!);
|
||||
var battlePokemon1 = parties[0].GetBattlePokemon(party1[0]!)!;
|
||||
battlePokemon1.ChangeStatBoost(Statistic.Defense, 2, true, false);
|
||||
await Assert.That(battlePokemon1.StatBoost.Defense).IsEqualTo((sbyte)2);
|
||||
battlePokemon1.Volatile.Add(new ChargeBounceEffect(battlePokemon1));
|
||||
|
||||
var clone = battle.DeepClone();
|
||||
await Assert.That(clone).IsNotEqualTo(battle);
|
||||
@@ -129,11 +130,10 @@ public class DeepCloneTests
|
||||
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((IBattle)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.UnderlyingPokemon).IsNotEqualTo(battle.Sides[0].Pokemon[0]!.UnderlyingPokemon);
|
||||
await Assert.That(pokemon.Battle).IsEqualTo((IBattle)clone);
|
||||
await Assert.That(pokemon.SeenOpponents).Contains(clone.Sides[1].Pokemon[0]!);
|
||||
await Assert.That(pokemon.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(
|
||||
@@ -142,7 +142,7 @@ public class DeepCloneTests
|
||||
var ownerGetter =
|
||||
typeof(ChargeBounceEffect).GetField("_owner", BindingFlags.NonPublic | BindingFlags.Instance)!;
|
||||
var owner = ownerGetter.GetValue(pokemon.Volatile.Get<ChargeBounceEffect>()!);
|
||||
await Assert.That((IPokemon)owner!).IsEqualTo(pokemon);
|
||||
await Assert.That((IBattlePokemon)owner!).IsEqualTo(pokemon);
|
||||
pokemon.Volatile.Remove<ChargeBounceEffect>();
|
||||
|
||||
await Assert.That(pokemon.Volatile.Get<ChargeBounceEffect>()).IsNull();
|
||||
|
||||
Reference in New Issue
Block a user