PKHeX/PKHeX.Core/Editing/PKM/QR/QRPKM.cs
Kurt fc754b346b
File scoped namespaces (#3529)
[Language Reference](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-10.0/file-scoped-namespaces)

Updates all the files, one less level of indentation.

Some small changes were made to API surfaces, renaming `PKM pkm` -> `PKM pk`, and `LegalityAnalysis.pkm` -> `LegalityAnalysis.Entity`
2022-06-18 11:04:24 -07:00

59 lines
1.9 KiB
C#

using System.Collections.Generic;
using System.Linq;
namespace PKHeX.Core;
public static class QRPKM
{
/// <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);
string moves = string.Join(" / ", pk.Moves.Select(move => move < s.movelist.Length ? s.movelist[move] : "ERROR"));
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),
moves,
IVs + " " + EVs,
};
}
private static IEnumerable<string> GetHeader(PKM pk, GameStrings s)
{
string filename = pk.Nickname;
if ((uint) pk.Species < s.Species.Count)
{
var name = s.Species[pk.Species];
if (pk.Nickname != name)
filename += $" ({name})";
}
yield return filename;
if (pk.Format >= 3 && (uint)pk.Ability < s.Ability.Count)
yield return $"[{s.Ability[pk.Ability]}]";
var level = pk.Stat_Level;
if (level == 0)
level = pk.CurrentLevel;
yield return $"lv{level}";
if (pk.HeldItem > 0)
{
var items = s.GetItemStrings(pk.Format);
if ((uint)pk.HeldItem < items.Length)
yield return $" @ {items[pk.HeldItem]}";
}
if (pk.Format >= 3 && (uint)pk.Nature < s.Natures.Count)
yield return s.natures[pk.Nature];
}
}