2022-06-26 06:08:28 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
2018-04-28 01:24:07 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
namespace PKHeX.Core;
|
|
|
|
|
|
|
|
public static class QRPKM
|
2018-04-28 01:24:07 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Summarizes the details of a <see cref="PKM"/> into multiple lines for display in an image.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="pk">Pokémon to generate details for.</param>
|
|
|
|
/// <returns>Lines representing a Header, Moves, and IVs/EVs</returns>
|
|
|
|
public static string[] GetQRLines(this PKM pk)
|
|
|
|
{
|
|
|
|
var s = GameInfo.Strings;
|
|
|
|
|
|
|
|
var header = GetHeader(pk, s);
|
2022-06-26 06:08:28 +00:00
|
|
|
var sb = new StringBuilder(48);
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
var move = pk.GetMove(i);
|
|
|
|
if (move == 0)
|
|
|
|
continue;
|
|
|
|
if (sb.Length != 0)
|
|
|
|
sb.Append(" / ");
|
|
|
|
var moveName = move < s.movelist.Length ? s.movelist[move] : "ERROR";
|
|
|
|
sb.Append(moveName);
|
|
|
|
}
|
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
string IVs = $"IVs: {pk.IV_HP:00}/{pk.IV_ATK:00}/{pk.IV_DEF:00}/{pk.IV_SPA:00}/{pk.IV_SPD:00}/{pk.IV_SPE:00}";
|
|
|
|
string EVs = $"EVs: {pk.EV_HP:00}/{pk.EV_ATK:00}/{pk.EV_DEF:00}/{pk.EV_SPA:00}/{pk.EV_SPD:00}/{pk.EV_SPE:00}";
|
|
|
|
|
|
|
|
return new[]
|
|
|
|
{
|
|
|
|
string.Join(" ", header),
|
2022-06-26 06:08:28 +00:00
|
|
|
sb.ToString(),
|
2022-06-18 18:04:24 +00:00
|
|
|
IVs + " " + EVs,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private static IEnumerable<string> GetHeader(PKM pk, GameStrings s)
|
2018-04-28 01:24:07 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
string filename = pk.Nickname;
|
|
|
|
if ((uint) pk.Species < s.Species.Count)
|
2018-04-28 01:24:07 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var name = s.Species[pk.Species];
|
|
|
|
if (pk.Nickname != name)
|
|
|
|
filename += $" ({name})";
|
2018-04-28 01:24:07 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
yield return filename;
|
|
|
|
|
|
|
|
if (pk.Format >= 3 && (uint)pk.Ability < s.Ability.Count)
|
|
|
|
yield return $"[{s.Ability[pk.Ability]}]";
|
2018-04-28 01:24:07 +00:00
|
|
|
|
2022-06-18 18:04:24 +00:00
|
|
|
var level = pk.Stat_Level;
|
|
|
|
if (level == 0)
|
|
|
|
level = pk.CurrentLevel;
|
|
|
|
yield return $"lv{level}";
|
|
|
|
|
|
|
|
if (pk.HeldItem > 0)
|
2018-04-28 01:24:07 +00:00
|
|
|
{
|
2022-06-18 18:04:24 +00:00
|
|
|
var items = s.GetItemStrings(pk.Format);
|
|
|
|
if ((uint)pk.HeldItem < items.Length)
|
|
|
|
yield return $" @ {items[pk.HeldItem]}";
|
2018-04-28 01:24:07 +00:00
|
|
|
}
|
2022-06-18 18:04:24 +00:00
|
|
|
|
|
|
|
if (pk.Format >= 3 && (uint)pk.Nature < s.Natures.Count)
|
|
|
|
yield return s.natures[pk.Nature];
|
2018-04-28 01:24:07 +00:00
|
|
|
}
|
|
|
|
}
|