2018-07-08 07:26:31 +00:00
|
|
|
using System;
|
2023-11-13 05:11:11 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
2018-07-08 07:26:31 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
2023-11-13 05:11:11 +00:00
|
|
|
public sealed class SecretBase3PKM : ISpeciesForm
|
2018-07-08 07:26:31 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
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; }
|
2022-08-27 06:43:36 +00:00
|
|
|
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; }
|
2018-07-08 07:26:31 +00:00
|
|
|
|
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;
|
2024-02-23 03:20:54 +00:00
|
|
|
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)
|
2022-06-18 18:04:24 +00:00
|
|
|
{
|
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)
|
2018-07-08 07:26:31 +00:00
|
|
|
{
|
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;
|
2018-07-08 07:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
}
|