mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-26 22:10:21 +00:00
Evolution check fixes
Evolution info was not checked for non-eggs; for mystery gifts check that the level of the evolution is not less than the level of the matched encounter fix spacing (cosmetic) add temp flagging for magnetpull/static slots (will eventually refactor into something functional that considers a set of slots including swarm/etc)
This commit is contained in:
parent
f674d45854
commit
4e1a520b0a
6 changed files with 68 additions and 9 deletions
|
@ -1158,7 +1158,7 @@ namespace PKHeX.Core
|
|||
}
|
||||
else if (lvl < pkm.Met_Level)
|
||||
AddLine(Severity.Invalid, V85, CheckIdentifier.Level);
|
||||
else if ((pkm.WasEgg || EncounterMatch == null) && !Legal.getEvolutionValid(pkm) && pkm.Species != 350)
|
||||
else if (!verifyEvolution()) // flag if invalid evo
|
||||
AddLine(Severity.Invalid, V86, CheckIdentifier.Level);
|
||||
else if (lvl > pkm.Met_Level && lvl > 1 && lvl != 100 && pkm.EXP == PKX.getEXP(pkm.Stat_Level, pkm.Species))
|
||||
AddLine(Severity.Fishy, V87, CheckIdentifier.Level);
|
||||
|
@ -2595,6 +2595,20 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
}
|
||||
private bool verifyEvolution()
|
||||
{
|
||||
if ((pkm.WasEgg || EncounterMatch == null) && !Legal.getEvolutionValid(pkm) && pkm.Species != 350)
|
||||
return false;
|
||||
|
||||
var match = EncounterMatch as IEncounterable;
|
||||
if (match == null)
|
||||
return true;
|
||||
|
||||
var evos = Legal.getValidPreEvolutions(pkm);
|
||||
var matchEvo = evos.FirstOrDefault(z => z.Species == match.Species);
|
||||
bool IsValid = matchEvo == null || matchEvo.Level < match.LevelMin;
|
||||
return IsValid;
|
||||
}
|
||||
private void verifyVersionEvolution()
|
||||
{
|
||||
if (pkm.Format < 7)
|
||||
|
|
|
@ -270,6 +270,34 @@ namespace PKHeX.Core
|
|||
: new EncounterArea {Location = t.First().Location, Slots = t.SelectMany(s => s.Slots).ToArray()})
|
||||
.ToArray();
|
||||
}
|
||||
private static void MarkEncountersStaticMagnetPull(ref EncounterArea[] Areas, PersonalTable t)
|
||||
{
|
||||
const int steel = 8;
|
||||
const int electric = 12;
|
||||
foreach (EncounterArea Area in Areas)
|
||||
{
|
||||
var s = new List<EncounterSlot>(); // Static
|
||||
var m = new List<EncounterSlot>(); // Magnet Pull
|
||||
foreach (EncounterSlot Slot in Area.Slots)
|
||||
{
|
||||
var types = t[Slot.Species].Types;
|
||||
if (types[0] == steel || types[1] == steel)
|
||||
m.Add(Slot);
|
||||
if (types[0] == electric || types[1] == electric)
|
||||
s.Add(Slot);
|
||||
}
|
||||
foreach (var slot in s)
|
||||
{
|
||||
slot.Static = true;
|
||||
slot.StaticCount = s.Count;
|
||||
}
|
||||
foreach (var slot in m)
|
||||
{
|
||||
slot.MagnetPull = true;
|
||||
slot.MagnetPullCount = s.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void MarkEncountersGeneration(ref EncounterStatic[] Encounters, int Generation)
|
||||
{
|
||||
foreach (EncounterStatic Encounter in Encounters)
|
||||
|
@ -764,6 +792,12 @@ namespace PKHeX.Core
|
|||
MarkG3SlotsSafariZones(ref FR_Slots, 136);
|
||||
MarkG3SlotsSafariZones(ref LG_Slots, 136);
|
||||
|
||||
MarkEncountersStaticMagnetPull(ref R_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref S_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref E_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref FR_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref LG_Slots, PersonalTable.SM);
|
||||
|
||||
SlotsR = addExtraTableSlots(R_Slots, SlotsRSEAlt);
|
||||
SlotsS = addExtraTableSlots(S_Slots, SlotsRSEAlt);
|
||||
SlotsE = addExtraTableSlots(E_Slots, SlotsRSEAlt);
|
||||
|
@ -796,6 +830,13 @@ namespace PKHeX.Core
|
|||
var Pt_Slots = getEncounterTables(GameVersion.Pt);
|
||||
var HG_Slots = getEncounterTables(GameVersion.HG);
|
||||
var SS_Slots = getEncounterTables(GameVersion.SS);
|
||||
|
||||
MarkEncountersStaticMagnetPull(ref D_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref P_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref Pt_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref HG_Slots, PersonalTable.SM);
|
||||
MarkEncountersStaticMagnetPull(ref SS_Slots, PersonalTable.SM);
|
||||
|
||||
var DP_Trophy = EncounterArea.getTrophyArea(TrophyDP, new[] {16, 18});
|
||||
var Pt_Trophy = EncounterArea.getTrophyArea(TrophyPt, new[] {22, 22});
|
||||
var HG_Headbutt_Slots = EncounterArea.getArray4HGSS_Headbutt(Data.unpackMini(Util.getBinaryResource("encunters_hb_hg.pkl"), "hg"));
|
||||
|
@ -3322,7 +3363,7 @@ namespace PKHeX.Core
|
|||
return new List<DexLevel>
|
||||
{
|
||||
new DexLevel { Species = 292, Level = lvl, MinLevel = 20 },
|
||||
new DexLevel { Species = 290, Level = lvl-1, MinLevel = 1 }
|
||||
new DexLevel { Species = 290, Level = lvl - 1, MinLevel = 1 }
|
||||
};
|
||||
if (maxspeciesorigin == -1 && pkm.InhabitedGeneration(2) && pkm.GenNumber == 1)
|
||||
maxspeciesorigin = MaxSpeciesID_2;
|
||||
|
@ -3330,7 +3371,7 @@ namespace PKHeX.Core
|
|||
var et = maxspeciesorigin == MaxSpeciesID_2 ? getEvolutionTable(2) : getEvolutionTable(pkm);
|
||||
return et.getValidPreEvolutions(pkm, lvl: lvl, maxSpeciesOrigin: maxspeciesorigin, skipChecks: skipChecks);
|
||||
}
|
||||
private static IEnumerable<EncounterStatic> getStatic(PKM pkm, IEnumerable<EncounterStatic> table, int maxspeciesorigin =-1, int lvl = -1)
|
||||
private static IEnumerable<EncounterStatic> getStatic(PKM pkm, IEnumerable<EncounterStatic> table, int maxspeciesorigin = -1, int lvl = -1)
|
||||
{
|
||||
IEnumerable<DexLevel> dl = getValidPreEvolutions(pkm, maxspeciesorigin: maxspeciesorigin, lvl: lvl);
|
||||
return table.Where(e => dl.Any(d => d.Species == e.Species));
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
public bool EggEncounter => false;
|
||||
public int Generation { get; set; } = -1;
|
||||
|
||||
public bool Static;
|
||||
public bool MagnetPull;
|
||||
public int StaticCount;
|
||||
public int MagnetPullCount;
|
||||
|
||||
public virtual EncounterSlot Clone()
|
||||
{
|
||||
return new EncounterSlot
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace PKHeX.Core
|
|||
|
||||
return Personal.getFormeIndex(evolvesToSpecies, evolvesToForm);
|
||||
}
|
||||
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl, int maxSpeciesOrigin =-1 ,bool skipChecks = false)
|
||||
public IEnumerable<DexLevel> getValidPreEvolutions(PKM pkm, int lvl, int maxSpeciesOrigin = -1, bool skipChecks = false)
|
||||
{
|
||||
int index = getIndex(pkm);
|
||||
if (maxSpeciesOrigin <= 0)
|
||||
|
@ -610,7 +610,7 @@ namespace PKHeX.Core
|
|||
public IEnumerable<DexLevel> getExplicitLineage(PKM pkm, int lvl, bool skipChecks, int maxSpeciesTree, int maxSpeciesOrigin)
|
||||
{
|
||||
List<DexLevel> dl = new List<DexLevel> { new DexLevel { Species = pkm.Species, Level = lvl, Form = pkm.AltForm } };
|
||||
for (int i = Chain.Count-1; i >= 0; i--) // reverse evolution!
|
||||
for (int i = Chain.Count - 1; i >= 0; i--) // reverse evolution!
|
||||
{
|
||||
bool oneValid = false;
|
||||
foreach (var evo in Chain[i].StageEntryMethods)
|
||||
|
@ -626,10 +626,9 @@ namespace PKHeX.Core
|
|||
if (evo.Species > maxSpeciesTree)
|
||||
species = pkm.Species - Chain.Count + i;
|
||||
|
||||
dl.Add(evo.GetDexLevel(species, lvl));
|
||||
|
||||
if (evo.RequiresLevelUp)
|
||||
lvl--;
|
||||
dl.Add(evo.GetDexLevel(species, lvl));
|
||||
break;
|
||||
}
|
||||
if (!oneValid)
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace PKHeX.Core
|
|||
1, 2, 4, 5, 157, 159, 160, 161, 164, 165, 166
|
||||
};
|
||||
internal static readonly ushort[] Pouch_Key_GS = {
|
||||
7, 54, 55, 58, 59, 61, 66, 67, 68 , 69, 71, 127, 128, 130, 133, 134, 175, 178
|
||||
7, 54, 55, 58, 59, 61, 66, 67, 68, 69, 71, 127, 128, 130, 133, 134, 175, 178
|
||||
};
|
||||
internal static readonly ushort[] Pouch_Key_C = Pouch_Key_GS.Concat(new ushort[]{70, 115, 116, 129}).ToArray();
|
||||
internal static readonly ushort[] Pouch_TMHM_GSC = {
|
||||
|
|
|
@ -1333,7 +1333,7 @@ namespace PKHeX.Core
|
|||
};
|
||||
internal static readonly int[] ValidMet_Pt = ValidMet_DP.Concat(new[]
|
||||
{
|
||||
63, 79 , 85, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
|
||||
63, 79, 85, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125,
|
||||
}).ToArray();
|
||||
internal static readonly int[] ValidMet_HGSS =
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue