diff --git a/PkmnLibSharp/Battling/PokemonBuilder.cs b/PkmnLibSharp/Battling/PokemonBuilder.cs index 41872cb..5dbca12 100644 --- a/PkmnLibSharp/Battling/PokemonBuilder.cs +++ b/PkmnLibSharp/Battling/PokemonBuilder.cs @@ -11,6 +11,8 @@ namespace PkmnLibSharp.Battling where TPokemon : Pokemon where TLearnedMove :LearnedMove { + private static readonly Random _defaultRandom = new Random(); + protected readonly BattleLibrary Library; public string Species { get; } public string Forme { get; private set; } = "default"; @@ -148,7 +150,7 @@ namespace PkmnLibSharp.Battling protected abstract TLearnedMove CreateLearnedMove(MoveData move, byte maxUses, MoveLearnMethod learnMethod); - public TPokemon Build() + public TPokemon Build(Random? random = null) { if (!Library.StaticLibrary.SpeciesLibrary.TryGet(Species, out var species)) { @@ -160,7 +162,10 @@ namespace PkmnLibSharp.Battling throw new Exception($"Forme '{Forme}' was not found on species '{Species}'"); } - var random = new Random(); + if (random == null) + { + random = _defaultRandom; + } Item? heldItem = null; if (HeldItem != null)