Add randomSeed parameter to BattleImpl, fix flaky test
This commit is contained in:
parent
853d6dd1cb
commit
78114afd80
|
@ -123,7 +123,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="BattleImpl"/>
|
/// <inheritdoc cref="BattleImpl"/>
|
||||||
public BattleImpl(IDynamicLibrary library, IReadOnlyList<IBattleParty> parties, bool canFlee, byte numberOfSides,
|
public BattleImpl(IDynamicLibrary library, IReadOnlyList<IBattleParty> parties, bool canFlee, byte numberOfSides,
|
||||||
byte positionsPerSide)
|
byte positionsPerSide, int? randomSeed = null)
|
||||||
{
|
{
|
||||||
Library = library;
|
Library = library;
|
||||||
Parties = parties;
|
Parties = parties;
|
||||||
|
@ -134,7 +134,7 @@ public class BattleImpl : ScriptSource, IBattle
|
||||||
for (byte i = 0; i < numberOfSides; i++)
|
for (byte i = 0; i < numberOfSides; i++)
|
||||||
sides[i] = new BattleSideImpl(i, positionsPerSide, this);
|
sides[i] = new BattleSideImpl(i, positionsPerSide, this);
|
||||||
Sides = sides;
|
Sides = sides;
|
||||||
Random = new BattleRandomImpl();
|
Random = randomSeed.HasValue ? new BattleRandomImpl(randomSeed.Value) : new BattleRandomImpl();
|
||||||
EventHook = new EventHook();
|
EventHook = new EventHook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,14 @@ public interface IBattleRandom : IRandom
|
||||||
/// <inheritdoc cref="IBattleRandom"/>
|
/// <inheritdoc cref="IBattleRandom"/>
|
||||||
public class BattleRandomImpl : RandomImpl, IBattleRandom
|
public class BattleRandomImpl : RandomImpl, IBattleRandom
|
||||||
{
|
{
|
||||||
|
public BattleRandomImpl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public BattleRandomImpl(int seed) : base(seed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
public bool EffectChance(float chance, IExecutingMove executingMove, IPokemon target, byte hitNumber)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class IntegrationTestRunner
|
||||||
return new BattlePartyImpl(party, x.Indices.Select(y => new ResponsibleIndex(y[0], y[1])).ToArray());
|
return new BattlePartyImpl(party, x.Indices.Select(y => new ResponsibleIndex(y[0], y[1])).ToArray());
|
||||||
}).ProcessOneAtATime().GetResultsAsync();
|
}).ProcessOneAtATime().GetResultsAsync();
|
||||||
var battle = new BattleImpl(library, parties, test.BattleSetup.CanFlee, test.BattleSetup.NumberOfSides,
|
var battle = new BattleImpl(library, parties, test.BattleSetup.CanFlee, test.BattleSetup.NumberOfSides,
|
||||||
test.BattleSetup.PositionsPerSide);
|
test.BattleSetup.PositionsPerSide, randomSeed: test.BattleSetup.Seed);
|
||||||
|
|
||||||
foreach (var action in test.Actions)
|
foreach (var action in test.Actions)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue