diff --git a/PkmnLibSharp/Battling/PokemonBuilder.cs b/PkmnLibSharp/Battling/PokemonBuilder.cs index 4b66ed9..a288467 100644 --- a/PkmnLibSharp/Battling/PokemonBuilder.cs +++ b/PkmnLibSharp/Battling/PokemonBuilder.cs @@ -9,92 +9,51 @@ using Random = PkmnLibSharp.Utilities.Random; namespace PkmnLibSharp.Battling { public abstract class BasePokemonBuilder - where TPokemon : Pokemon - where TLearnedMove :LearnedMove + 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"; - public string Nickname { get; private set; } = ""; - public string Ability { get; private set; } = ""; - public string Nature { get; private set; } = ""; - public Gender Gender { get; private set; } = (Gender) (-1); - public uint Identifier { get; private set; } = 0; + public string Forme { get; set; } = "default"; + public string Nickname { get; set; } = ""; + public string Ability { get; set; } = ""; + public string Nature { get; set; } = ""; + public Gender Gender { get; set; } = (Gender) (-1); + public uint Identifier { get; set; } = 0; public byte Level { get; } - public StatisticSet IVs; - public StatisticSet EVs; - + public StatisticSet IVs { get; set; } + public StatisticSet EVs { get; set; } + public bool? IsForceShiny { get; private set; } - public string? HeldItem { get; private set; } + public string? HeldItem { get; set; } public bool IsEgg { get; private set; } public bool IsAllowedExperienceGain { get; private set; } = true; public List<(string moveName, MoveLearnMethod learnMethod)> LearnedMoves { get; } = new List<(string moveName, MoveLearnMethod learnMethod)>(); - + public BasePokemonBuilder(BattleLibrary library, string species, byte level) { Library = library; Species = species; Level = level; } - - public BasePokemonBuilder WithForme(string forme) - { - Forme = forme; - return this; - } - - public BasePokemonBuilder WithGender(Gender gender) - { - Gender = gender; - return this; - } - + public BasePokemonBuilder ForceShiny(bool value) { IsForceShiny = value; return this; } - public BasePokemonBuilder WithHeldItem(string heldItem) - { - HeldItem = heldItem; - return this; - } - - public BasePokemonBuilder WithNickname(string nickname) - { - Nickname = nickname; - return this; - } - - public BasePokemonBuilder WithNature(string nature) - { - Nature = nature; - return this; - } - - public BasePokemonBuilder WithIVs(StatisticSet ivs) - { - IVs = ivs; - return this; - } - public BasePokemonBuilder WithEVs(StatisticSet evs) - { - EVs = evs; - return this; - } - public BasePokemonBuilder MakeEgg() { IsEgg = true; return this; } - + public BasePokemonBuilder AllowedExperienceGain(bool value) { IsAllowedExperienceGain = value; @@ -108,6 +67,7 @@ namespace PkmnLibSharp.Battling { throw new Exception("Too many moves for Pokemon."); } + LearnedMoves.Add((moveName, moveLearnMethod)); return this; } @@ -127,6 +87,7 @@ namespace PkmnLibSharp.Battling { Gender = species.GetRandomGender(random); } + Coloring = 0; if (IsForceShiny.HasValue) { @@ -181,6 +142,7 @@ namespace PkmnLibSharp.Battling { random = _defaultRandom; } + PopulateUninitialized(species, forme!, random); Item? heldItem = null; @@ -191,7 +153,7 @@ namespace PkmnLibSharp.Battling throw new Exception($"Item '{HeldItem}' was not found."); } } - + var moves = new LearnedMove[Library.StaticLibrary.Settings.MaximalMoves]; for (var i = 0; i < LearnedMoves.Count; i++) { @@ -214,7 +176,7 @@ namespace PkmnLibSharp.Battling { Gender = species.GetRandomGender(random); } - + return new ScopedOwner(Finalize(species, forme!, heldItem, moves, nature)); } } diff --git a/PkmnLibSharp/Native/Linux/libpkmnLib.so b/PkmnLibSharp/Native/Linux/libpkmnLib.so index 42803c1..ec8ecb4 100755 --- a/PkmnLibSharp/Native/Linux/libpkmnLib.so +++ b/PkmnLibSharp/Native/Linux/libpkmnLib.so @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:50a6ddcd2210085235b46de2afea095e5403f8edba8db99acaf2edad4be5ae59 -size 4136224 +oid sha256:5252791a55da6ffddb30673c900c00a2ed4e159a307cb271933b562a39e6eaf7 +size 4139616 diff --git a/PkmnLibSharp/PkmnLibSharp.csproj b/PkmnLibSharp/PkmnLibSharp.csproj index 3d22caf..d1d56ee 100644 --- a/PkmnLibSharp/PkmnLibSharp.csproj +++ b/PkmnLibSharp/PkmnLibSharp.csproj @@ -5,7 +5,7 @@ x64 enable CS8600;CS8601;CS8602;CS8603;CS8604;CS8618 - 8 + 9 netstandard2.0;netstandard2.1 diff --git a/PkmnLibSharpTests/Battling/PokemonBuilderTests.cs b/PkmnLibSharpTests/Battling/PokemonBuilderTests.cs index 1e9b524..2e95ca7 100644 --- a/PkmnLibSharpTests/Battling/PokemonBuilderTests.cs +++ b/PkmnLibSharpTests/Battling/PokemonBuilderTests.cs @@ -24,8 +24,9 @@ namespace PkmnLibSharpTests.Battling { var lib = BattleLibraryHelper.GetLibrary(); var pokemon = new PokemonBuilder(lib, "testSpecies", 50) - .WithNickname("cuteNickname") - .Build(); + { + Nickname = "cuteNickname" + }.Build(); Assert.AreEqual("cuteNickname", pokemon.Value.Nickname); pokemon.Dispose(); } @@ -35,7 +36,9 @@ namespace PkmnLibSharpTests.Battling { var lib = BattleLibraryHelper.GetLibrary(); var pokemon = new PokemonBuilder(lib, "testSpecies", 50) - .WithGender(Gender.Female) + { + Gender = Gender.Female + } .Build(); Assert.AreEqual(Gender.Female, pokemon.Value.Gender); pokemon.Dispose();