mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-26 02:57:18 -05:00
Improve cctor times for Breeding; direct calls for splitbreed checks; inlined binary searches via generated IL instead of hashset Fix permitting alpha ribbon on non-alphas in Gen8/8a/8b, disallow Gen8a/8b ribbons for Gen7 Alolan Raichu Improve some IL generation of EvoChain logic Add xmldoc for new evotree additions
79 lines
2.4 KiB
C#
79 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using static PKHeX.Core.LegalityCheckStrings;
|
|
|
|
namespace PKHeX.Core;
|
|
|
|
/// <summary>
|
|
/// Default formatter for Legality Result displays.
|
|
/// </summary>
|
|
public sealed class BaseLegalityFormatter : ILegalityFormatter
|
|
{
|
|
/// <summary>
|
|
/// Gets a minimal report string for the analysis.
|
|
/// </summary>
|
|
public string GetReport(LegalityAnalysis l)
|
|
{
|
|
if (l.Valid)
|
|
return L_ALegal;
|
|
if (!l.Parsed)
|
|
return L_AnalysisUnavailable;
|
|
|
|
var lines = GetLegalityReportLines(l);
|
|
return string.Join(Environment.NewLine, lines);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gets a verbose report string for the analysis.
|
|
/// </summary>
|
|
public string GetReportVerbose(LegalityAnalysis l)
|
|
{
|
|
if (!l.Parsed)
|
|
return L_AnalysisUnavailable;
|
|
|
|
var lines = GetVerboseLegalityReportLines(l);
|
|
return string.Join(Environment.NewLine, lines);
|
|
}
|
|
|
|
private static List<string> GetLegalityReportLines(LegalityAnalysis l)
|
|
{
|
|
var lines = new List<string>();
|
|
var info = l.Info;
|
|
var pk = l.Entity;
|
|
|
|
LegalityFormatting.AddMoves(info.Moves, lines, pk.Format, false, pk, l.Info.EvoChainsAllGens);
|
|
if (pk.Format >= 6)
|
|
LegalityFormatting.AddRelearn(info.Relearn, lines, false, pk, l.Info.EvoChainsAllGens);
|
|
LegalityFormatting.AddSecondaryChecksInvalid(l.Results, lines);
|
|
return lines;
|
|
}
|
|
|
|
private static IReadOnlyList<string> GetVerboseLegalityReportLines(LegalityAnalysis l)
|
|
{
|
|
var lines = l.Valid ? new List<string> {L_ALegal} : GetLegalityReportLines(l);
|
|
var info = l.Info;
|
|
var pk = l.Entity;
|
|
const string separator = "===";
|
|
lines.Add(separator);
|
|
lines.Add(string.Empty);
|
|
int initialCount = lines.Count;
|
|
|
|
var format = pk.Format;
|
|
LegalityFormatting.AddMoves(info.Moves, lines, format, true, pk, l.Info.EvoChainsAllGens);
|
|
|
|
if (format >= 6)
|
|
LegalityFormatting.AddRelearn(info.Relearn, lines, true, pk, l.Info.EvoChainsAllGens);
|
|
|
|
if (lines.Count != initialCount) // move info added, break for next section
|
|
lines.Add(string.Empty);
|
|
|
|
LegalityFormatting.AddSecondaryChecksValid(l.Results, lines);
|
|
|
|
lines.Add(separator);
|
|
lines.Add(string.Empty);
|
|
LegalityFormatting.AddEncounterInfo(l, lines);
|
|
|
|
return lines;
|
|
}
|
|
}
|