PKHeX/PKHeX.Core/Saves/Substructures/Gen3/SecretBase3PKM.cs

73 lines
2.1 KiB
C#
Raw Normal View History

using System;
2023-11-13 05:11:11 +00:00
using System.Collections.Generic;
using System.Text;
namespace PKHeX.Core;
2023-11-13 05:11:11 +00:00
public sealed class SecretBase3PKM : ISpeciesForm
{
public uint PID { get; set; }
2023-11-13 05:11:11 +00:00
public ushort Move1 { get; set; }
public ushort Move2 { get; set; }
public ushort Move3 { get; set; }
public ushort Move4 { get; set; }
public ushort Species { get; set; }
2023-11-13 05:11:11 +00:00
public ushort HeldItem { get; set; }
public byte Level { get; set; }
public byte EVAll { get; set; }
2023-11-13 05:11:11 +00:00
private PersonalInfo3 PersonalInfo => PersonalTable.E.GetFormEntry(Species, Form);
public byte Form => Species == (int)Core.Species.Unown ? EntityPID.GetUnownForm3(PID) : (byte)0;
public byte Gender => EntityGender.GetFromPIDAndRatio(PID, PersonalInfo.Gender);
2023-11-13 05:11:11 +00:00
public void GetMoves(Span<ushort> moves)
{
moves[3] = Move4;
moves[2] = Move3;
moves[1] = Move2;
moves[0] = Move1;
}
public string Summary => GetSummary(GameInfo.Strings);
private string GetSummary(IBasicStrings g)
{
var sb = new StringBuilder(128);
return GetSummary(sb, g);
}
private string GetSummary(StringBuilder sb, IBasicStrings g)
{
2023-11-13 05:11:11 +00:00
sb.Append($"{Species:000} - {g.Species[Species]}");
if (HeldItem != 0)
sb.Append(" @ ").Append(g.Item[HeldItem]);
sb.AppendLine();
var moveNames = g.Move;
Span<ushort> moves = stackalloc ushort[4];
GetMoves(moves);
AddMoves(sb, moves, moveNames);
sb.AppendLine();
sb.Append($"Level: {Level}, EVs: {EVAll}, PID: {PID}");
return sb.ToString();
}
private static void AddMoves(StringBuilder sb, Span<ushort> moves, IReadOnlyList<string> moveNames)
{
sb.Append("Moves: ");
var first = true;
foreach (var move in moves)
{
2023-11-13 05:11:11 +00:00
if (move == 0)
continue;
if (!first)
sb.Append(Moveset.DefaultSeparator);
var moveName = move >= moveNames.Count ? move.ToString() : moveNames[move];
sb.Append(moveName);
first = false;
}
}
}