|
|
|
@ -9,92 +9,51 @@ using Random = PkmnLibSharp.Utilities.Random;
|
|
|
|
|
namespace PkmnLibSharp.Battling
|
|
|
|
|
{
|
|
|
|
|
public abstract class BasePokemonBuilder<TPokemon, TLearnedMove>
|
|
|
|
|
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<byte> IVs;
|
|
|
|
|
public StatisticSet<byte> EVs;
|
|
|
|
|
|
|
|
|
|
public StatisticSet<byte> IVs { get; set; }
|
|
|
|
|
public StatisticSet<byte> 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<TPokemon, TLearnedMove> WithForme(string forme)
|
|
|
|
|
{
|
|
|
|
|
Forme = forme;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithGender(Gender gender)
|
|
|
|
|
{
|
|
|
|
|
Gender = gender;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> ForceShiny(bool value)
|
|
|
|
|
{
|
|
|
|
|
IsForceShiny = value;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithHeldItem(string heldItem)
|
|
|
|
|
{
|
|
|
|
|
HeldItem = heldItem;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithNickname(string nickname)
|
|
|
|
|
{
|
|
|
|
|
Nickname = nickname;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithNature(string nature)
|
|
|
|
|
{
|
|
|
|
|
Nature = nature;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithIVs(StatisticSet<byte> ivs)
|
|
|
|
|
{
|
|
|
|
|
IVs = ivs;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> WithEVs(StatisticSet<byte> evs)
|
|
|
|
|
{
|
|
|
|
|
EVs = evs;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> MakeEgg()
|
|
|
|
|
{
|
|
|
|
|
IsEgg = true;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BasePokemonBuilder<TPokemon, TLearnedMove> 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<TPokemon>(Finalize(species, forme!, heldItem, moves, nature));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|