Tweak suggestion behavior

Prefer lowest level wild encounter; expand suggestion for evolved pkm.
Add click event to Current Level (for gen1+ pkm since Met Location not
visible).
Add Nickname CheckIdentifier to change incorrect identifiers in Nickname
check.
This commit is contained in:
Kurt 2017-02-14 17:33:57 -08:00
parent 1087b31586
commit f9cc9c10ca
5 changed files with 66 additions and 36 deletions

View file

@ -926,6 +926,7 @@
this.Label_CurLevel.TabIndex = 7;
this.Label_CurLevel.Text = "Level:";
this.Label_CurLevel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.Label_CurLevel.Click += new System.EventHandler(this.clickMetLocation);
//
// TB_Level
//

View file

@ -1940,8 +1940,12 @@ namespace PKHeX.WinForms
return;
pkm = preparePKM();
updateLegality();
if (Legality.Valid)
return;
var encounter = Legality.getSuggestedMetInfo();
if (encounter == null || encounter.Location < 0)
if (encounter == null || (pkm.Format >= 3 && encounter.Location < 0))
{
WinFormsUtil.Alert("Unable to provide a suggestion.");
return;
@ -1950,21 +1954,35 @@ namespace PKHeX.WinForms
int level = encounter.Level;
int location = encounter.Location;
int minlvl = Legal.getLowestLevel(pkm, encounter.Species);
if (pkm.Met_Level == level && pkm.Met_Location == location && pkm.CurrentLevel >= minlvl)
if (minlvl == 0)
minlvl = level;
if (pkm.CurrentLevel >= minlvl && pkm.Met_Level == level && pkm.Met_Location == location)
return;
var met_list = GameInfo.getLocationList((GameVersion)pkm.Version, SAV.Generation, egg: false);
var locstr = met_list.FirstOrDefault(loc => loc.Value == location)?.Text;
string suggestion = $"Suggested:\nMet Location: {locstr}\nMet Level: {level}";
var suggestion = new List<string> {"Suggested:"};
if (pkm.Format >= 3)
{
var met_list = GameInfo.getLocationList((GameVersion)pkm.Version, SAV.Generation, egg: false);
var locstr = met_list.FirstOrDefault(loc => loc.Value == location)?.Text;
suggestion.Add($"Met Location: {locstr}");
suggestion.Add($"Met Level: {level}");
}
if (pkm.CurrentLevel < minlvl)
suggestion += $"\nCurrent Level {minlvl}";
suggestion.Add($"Current Level: {minlvl}");
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, suggestion) != DialogResult.Yes)
if (suggestion.Count == 1) // no suggestion
return;
TB_MetLevel.Text = level.ToString();
CB_MetLocation.SelectedValue = location;
string suggest = string.Join(Environment.NewLine, suggestion);
if (WinFormsUtil.Prompt(MessageBoxButtons.YesNo, suggest) != DialogResult.Yes)
return;
if (pkm.Format >= 3)
{
TB_MetLevel.Text = level.ToString();
CB_MetLocation.SelectedValue = location;
}
if (pkm.CurrentLevel < minlvl)
TB_Level.Text = minlvl.ToString();

View file

@ -92,6 +92,7 @@ namespace PKHeX.Core
updateEncounterChain();
updateMoveLegality();
updateEncounterInfo();
verifyNickname();
verifyDVs();
verifyG1OT();
@ -105,6 +106,7 @@ namespace PKHeX.Core
updateRelearnLegality();
updateEncounterChain();
updateMoveLegality();
updateEncounterInfo();
updateChecks();
}
private void parsePK7(PKM pk)
@ -116,6 +118,7 @@ namespace PKHeX.Core
updateRelearnLegality();
updateEncounterChain();
updateMoveLegality();
updateEncounterInfo();
updateChecks();
}
@ -141,13 +144,16 @@ namespace PKHeX.Core
Parse.Add(Encounter);
EvoChain = Legal.getEvolutionChain(pkm, EncounterMatch);
}
private void updateChecks()
private void updateEncounterInfo()
{
EncounterMatch = EncounterMatch ?? pkm.Species;
EncounterType = EncounterMatch?.GetType();
if (EncounterType == typeof (MysteryGift))
EncounterType = EncounterType.BaseType;
}
private void updateChecks()
{
History = verifyHistory();
AddLine(Encounter);
@ -269,15 +275,19 @@ namespace PKHeX.Core
Level = 1,
};
var capture = Legal.getCaptureLocation(pkm);
if (capture != null)
var area = Legal.getCaptureLocation(pkm);
if (area != null)
{
var slots = area.Slots.OrderBy(s => s.LevelMin);
return new EncounterStatic
{
Species = capture.Slots.First().Species,
Location = capture.Location,
Level = capture.Slots.First().LevelMin,
Species = slots.First().Species,
Location = area.Location,
Level = slots.First().LevelMin,
};
}
var encounter = Legal.getStaticLocation(pkm);
return encounter;
}

View file

@ -25,6 +25,7 @@ namespace PKHeX.Core
Gender,
EVs,
Language,
Nickname,
Trainer,
IVs,
None,
@ -143,12 +144,12 @@ namespace PKHeX.Core
// If the Pokémon is not nicknamed, it should match one of the language strings.
if (pkm.Nickname.Length == 0)
{
AddLine(Severity.Invalid, "Nickname is empty.", CheckIdentifier.EVs);
AddLine(Severity.Invalid, "Nickname is empty.", CheckIdentifier.Nickname);
return;
}
if (pkm.Species > PKX.SpeciesLang[0].Length)
{
AddLine(Severity.Indeterminate, "Species index invalid for Nickname comparison.", CheckIdentifier.EVs);
AddLine(Severity.Indeterminate, "Species index invalid for Nickname comparison.", CheckIdentifier.Nickname);
return;
}
@ -159,7 +160,7 @@ namespace PKHeX.Core
int lang = Array.IndexOf(PKX.SpeciesLang, langset);
if (pk.Length > (lang == 2 ? 10 : 5))
AddLine(Severity.Invalid, "Nickname too long.", CheckIdentifier.Trainer);
AddLine(Severity.Invalid, "Nickname too long.", CheckIdentifier.Nickname);
}
if (!Encounter.Valid)
@ -193,7 +194,7 @@ namespace PKHeX.Core
else if (pkm.SM)
{
// TODO
AddLine(Severity.Valid, "Ingame Trade for Sun/Moon un-implemented.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Ingame Trade for Sun/Moon un-implemented.", CheckIdentifier.Nickname);
return;
}
@ -212,11 +213,11 @@ namespace PKHeX.Core
string OT = validOT[validOT.Length/2 + index];
if (nick != pkm.Nickname)
AddLine(Severity.Fishy, "Ingame Trade nickname has been altered.", CheckIdentifier.EVs);
AddLine(Severity.Fishy, "Ingame Trade nickname has been altered.", CheckIdentifier.Nickname);
else if (OT != pkm.OT_Name)
AddLine(Severity.Invalid, "Ingame Trade OT has been altered.", CheckIdentifier.Trainer);
else
AddLine(Severity.Valid, "Ingame Trade OT/Nickname have not been altered.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Ingame Trade OT/Nickname have not been altered.", CheckIdentifier.Nickname);
return;
}
@ -224,11 +225,11 @@ namespace PKHeX.Core
if (pkm.IsEgg)
{
if (!pkm.IsNicknamed && (pkm.Format != 7))
AddLine(Severity.Invalid, "Eggs must be nicknamed.", CheckIdentifier.EVs);
AddLine(Severity.Invalid, "Eggs must be nicknamed.", CheckIdentifier.Egg);
else if (PKX.SpeciesLang[pkm.Language][0] != pkm.Nickname)
AddLine(Severity.Invalid, "Egg name does not match language Egg name.", CheckIdentifier.EVs);
AddLine(Severity.Invalid, "Egg name does not match language Egg name.", CheckIdentifier.Egg);
else
AddLine(Severity.Valid, "Egg matches language Egg name.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Egg matches language Egg name.", CheckIdentifier.Egg);
return;
}
@ -245,15 +246,15 @@ namespace PKHeX.Core
AddLine(Severity.Fishy, index == pkm.Species && i != pkm.Language
? "Nickname matches another species name (+language)."
: "Nickname flagged, matches species name.", CheckIdentifier.EVs);
: "Nickname flagged, matches species name.", CheckIdentifier.Nickname);
return;
}
AddLine(Severity.Valid, "Nickname does not match another species name.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Nickname does not match another species name.", CheckIdentifier.Nickname);
}
else if (pkm.Format < 3)
{
// pk1/pk2 IsNicknamed getter checks for match, logic should only reach here if matches.
AddLine(Severity.Valid, "Nickname matches species name.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Nickname matches species name.", CheckIdentifier.Nickname);
}
else
{
@ -262,9 +263,9 @@ namespace PKHeX.Core
|| PKX.SpeciesLang[pkm.Language][pkm.Species] == nickname;
if (!match)
AddLine(Severity.Invalid, "Nickname does not match species name.", CheckIdentifier.EVs);
AddLine(Severity.Invalid, "Nickname does not match species name.", CheckIdentifier.Nickname);
else
AddLine(Severity.Valid, "Nickname matches species name.", CheckIdentifier.EVs);
AddLine(Severity.Valid, "Nickname matches species name.", CheckIdentifier.Nickname);
}
}
private void verifyEVs()
@ -571,7 +572,7 @@ namespace PKHeX.Core
var result = verifyEncounterG1();
if (pkm.Format > 2) // transported to 7+
Parse.Add(verifyVCEncounter(baseSpecies));
AddLine(verifyVCEncounter(baseSpecies));
return result;
}
@ -622,10 +623,10 @@ namespace PKHeX.Core
// Check existing EncounterMatch
if (EncounterMatch == null)
Parse.Add(new CheckResult(Severity.Invalid, "Unable to match an encounter from origin game.", CheckIdentifier.Encounter));
AddLine(new CheckResult(Severity.Invalid, "Unable to match an encounter from origin game.", CheckIdentifier.Encounter));
var s = EncounterMatch as EncounterStatic;
if (s != null && s.Version == GameVersion.SPECIAL)
Parse.Add(new CheckResult(Severity.Invalid, "Special encounter is not available to Virtual Console games.", CheckIdentifier.Encounter));
AddLine(new CheckResult(Severity.Invalid, "Special encounter is not available to Virtual Console games.", CheckIdentifier.Encounter));
EncounterMatch = new EncounterStatic
{

View file

@ -637,11 +637,11 @@ namespace PKHeX.Core
select new EncounterArea
{
Location = area.Location, Slots = slots,
}).FirstOrDefault();
}).OrderBy(area => area.Slots.Min(x => x.LevelMin)).FirstOrDefault();
}
internal static EncounterStatic getStaticLocation(PKM pkm)
{
return getStaticEncounters(pkm).FirstOrDefault();
return getStaticEncounters(pkm, 100).OrderBy(s => s.Level).FirstOrDefault();
}
public static int getLowestLevel(PKM pkm, int refSpecies = -1)
@ -889,7 +889,7 @@ namespace PKHeX.Core
List<EncounterSlot> slotdata = new List<EncounterSlot>();
// Get Valid levels
IEnumerable<DexLevel> vs = getValidPreEvolutions(pkm);
IEnumerable<DexLevel> vs = getValidPreEvolutions(pkm, ignoreLevel ? 100 : -1, ignoreLevel);
// Get slots where pokemon can exist
bool ignoreSlotLevel = ignoreLevel;