PkmnLib.NET/PkmnLib.Dynamic/Models/Serialized/SerializedPokemon.cs

71 lines
2.5 KiB
C#

using System.Diagnostics.CodeAnalysis;
using PkmnLib.Static;
using PkmnLib.Static.Species;
namespace PkmnLib.Dynamic.Models.Serialized;
public class SerializedPokemon
{
public SerializedPokemon(){}
[SetsRequiredMembers]
public SerializedPokemon(IPokemon pokemon)
{
Species = pokemon.Species.Name;
Form = pokemon.Form.Name;
Level = pokemon.Level;
Experience = pokemon.Experience;
PersonalityValue = pokemon.PersonalityValue;
Gender = pokemon.Gender;
Coloring = pokemon.Coloring;
HeldItem = pokemon.HeldItem?.Name;
CurrentHealth = pokemon.CurrentHealth;
Happiness = pokemon.Happiness;
IndividualValues = new IndividualValueStatisticSet(pokemon.IndividualValues);
EffortValues = new EffortValueStatisticSet(pokemon.EffortValues);
Nature = pokemon.Nature.Name;
Nickname = pokemon.Nickname;
Ability = pokemon.Form.GetAbility(pokemon.AbilityIndex);
Moves = pokemon.Moves.Select(move =>
{
if (move == null)
return null;
return new SerializedLearnedMove
{
MoveName = move.MoveData.Name,
LearnMethod = move.LearnMethod,
CurrentPp = move.CurrentPp,
};
}).ToArray();
AllowedExperience = pokemon.AllowedExperience;
IsEgg = pokemon.IsEgg;
Status = pokemon.StatusScript.Script?.Name;
}
public required string Species { get; set; }
public required string Form { get; set; }
public LevelInt Level { get; set; }
public uint Experience { get; set; }
public uint PersonalityValue { get; set; }
public Gender Gender { get; set; }
public byte Coloring { get; set; }
public string? HeldItem { get; set; }
public uint CurrentHealth { get; set; }
public byte Happiness { get; set; }
public required IndividualValueStatisticSet IndividualValues { get; set; }
public required EffortValueStatisticSet EffortValues { get; set; }
public required string Nature { get; set; }
public string? Nickname { get; set; }
public required string Ability { get; set; }
public required SerializedLearnedMove?[] Moves { get; set; }
public bool AllowedExperience { get; set; }
public bool IsEgg { get; set; }
public string? Status { get; set; }
}
public class SerializedLearnedMove
{
public required string MoveName { get; set; }
public required MoveLearnMethod LearnMethod { get; set; }
public required byte CurrentPp { get; set; }
}