Misc reductions

hide setters for LegalInfo outside assembly (shouldn't overwrite the
stored values)
update GenNumber to Gen* if appropriate; GenNumber checks for first Gen*
to match, is a little more explicit and quicker than calling twice when
checking a range
This commit is contained in:
Kurt 2019-02-21 20:41:04 -08:00
parent 0156958f1a
commit c9e894a46d
7 changed files with 21 additions and 22 deletions

View file

@ -32,16 +32,14 @@ namespace PKHeX.Core
public class LevelUpRestriction
{
public readonly int EncounterSpecies;
public readonly IReadOnlyList<EvoCriteria>[] EvolutionChains;
public readonly int MinimumLevelGen1;
public readonly int MinimumLevelGen2;
public LevelUpRestriction(PKM pkm, LegalInfo info)
{
MinimumLevelGen1 = pkm.GenNumber <= 2 ? info.EncounterMatch.LevelMin + 1 : 0;
MinimumLevelGen1 = info.Generation <= 2 ? info.EncounterMatch.LevelMin + 1 : 0;
MinimumLevelGen2 = ParseSettings.AllowGen2MoveReminder(pkm) ? 1 : info.EncounterMatch.LevelMin + 1;
EncounterSpecies = info.EncounterMatch.Species;
EvolutionChains = info.EvoChainsAllGens;
}
}

View file

@ -11,10 +11,10 @@ namespace PKHeX.Core
private readonly PKM pkm;
/// <summary>The generation of games the <see cref="PKM"/> originated from.</summary>
public int Generation { get; set; }
public int Generation { get; internal set; }
/// <summary>The Game the <see cref="PKM"/> originated from.</summary>
public GameVersion Game { get; set; }
public GameVersion Game { get; internal set; }
/// <summary>The matched Encounter details for the <see cref="PKM"/>. </summary>
public IEncounterable EncounterMatch
@ -35,28 +35,28 @@ namespace PKHeX.Core
public bool WasXD => pkm?.Version == 15 && EncounterMatch is IVersion v && v.Version == GameVersion.XD;
/// <summary>Base Relearn Moves for the <see cref="EncounterMatch"/>.</summary>
public int[] RelearnBase { get; set; }
public int[] RelearnBase { get; internal set; }
/// <summary>Top level Legality Check result list for the <see cref="EncounterMatch"/>.</summary>
public readonly List<CheckResult> Parse = new List<CheckResult>();
public CheckResult[] Relearn { get; set; } = new CheckResult[4];
public CheckMoveResult[] Moves { get; set; } = new CheckMoveResult[4];
public CheckResult[] Relearn { get; internal set; } = new CheckResult[4];
public CheckMoveResult[] Moves { get; internal set; } = new CheckMoveResult[4];
public ValidEncounterMoves EncounterMoves { get; set; }
public ValidEncounterMoves EncounterMoves { get; internal set; }
public IReadOnlyList<EvoCriteria>[] EvoChainsAllGens => _evochains ?? (_evochains = EvolutionChain.GetEvolutionChainsAllGens(pkm, EncounterMatch));
private IReadOnlyList<EvoCriteria>[] _evochains;
/// <summary><see cref="RNG"/> related information that generated the <see cref="PKM.PID"/>/<see cref="PKM.IVs"/> value(s).</summary>
public PIDIV PIDIV { get; set; }
public PIDIV PIDIV { get; internal set; }
/// <summary>Indicates whether or not the <see cref="PIDIV"/> can originate from the <see cref="EncounterMatch"/>.</summary>
/// <remarks>This boolean is true until all valid <see cref="PIDIV"/> encounters are tested, after which it is false.</remarks>
public bool PIDIVMatches { get; set; } = true;
public bool PIDIVMatches { get; internal set; } = true;
/// <summary>Indicates whether or not the <see cref="PIDIV"/> can originate from the <see cref="EncounterMatch"/> with explicit <see cref="RNG"/> <see cref="Frame"/> matching.</summary>
/// <remarks>This boolean is true until all valid <see cref="Frame"/> entries are tested for all possible <see cref="EncounterSlot"/> matches, after which it is false.</remarks>
public bool FrameMatches { get; set; } = true;
public bool FrameMatches { get; internal set; } = true;
public readonly bool Korean;

View file

@ -267,10 +267,11 @@ namespace PKHeX.Core
if (pkm.Format <= 2)
return 2;
if (!pkm.HasOriginalMetLocation && generation != pkm.GenNumber)
var origin = pkm.GenNumber;
if (!pkm.HasOriginalMetLocation && generation != origin)
return pkm.Met_Level;
if (pkm.GenNumber <= 3)
if (origin <= 3)
return 2;
return 1;

View file

@ -339,7 +339,7 @@ namespace PKHeX.Core
return specific;
if (pk.Version == 15)
return PIDType.CXD;
if (pk.GenNumber == 3 && pk.Species == 201)
if (pk.Gen3 && pk.Species == 201)
return PIDType.Method_1_Unown + Util.Rand.Next(3);
return PIDType.Method_1;

View file

@ -889,7 +889,7 @@ namespace PKHeX.Core
{
while (!IsShiny)
PID = PKX.GetRandomPID(Species, Gender, Version, Nature, AltForm, PID);
if (Format >= 6 && 3 <= GenNumber && GenNumber <= 5)
if (Format >= 6 && (Gen3 || Gen4 || Gen5))
EncryptionConstant = PID;
}
@ -913,7 +913,7 @@ namespace PKHeX.Core
public void SetPIDGender(int gender)
{
do PID = PKX.GetRandomPID(Species, gender, Version, Nature, AltForm, PID); while (IsShiny);
if (Format >= 6 && 3 <= GenNumber && GenNumber <= 5)
if (Format >= 6 && (Gen3 || Gen4 || Gen5))
EncryptionConstant = PID;
}
@ -927,7 +927,7 @@ namespace PKHeX.Core
public void SetPIDNature(int nature)
{
do PID = PKX.GetRandomPID(Species, Gender, Version, nature, AltForm, PID); while (IsShiny);
if (Format >= 6 && 3 <= GenNumber && GenNumber <= 5)
if (Format >= 6 && (Gen3 || Gen4 || Gen5))
EncryptionConstant = PID;
}
@ -942,7 +942,7 @@ namespace PKHeX.Core
public void SetPIDUnown3(int form)
{
do PID = Util.Rand32(); while (PKX.GetUnownForm(PID) != form);
if (Format >= 6 && 3 <= GenNumber && GenNumber <= 5)
if (Format >= 6 && (Gen3 || Gen4 || Gen5))
EncryptionConstant = PID;
}

View file

@ -162,7 +162,7 @@ namespace PKHeX.Core
if (pk.CurrentLevel < 100) // can't be hyper trained
return false;
if (pk.GenNumber != 4) // can't have encounter type
if (!pk.Gen4) // can't have encounter type
return true;
if (et > 24) // invalid encountertype
return true;

View file

@ -756,7 +756,7 @@ namespace PKHeX.WinForms.Controls
TB_MetLevel.Text = level.ToString();
CB_MetLocation.SelectedValue = location;
if (pkm.GenNumber == 6 && pkm.WasEgg && ModifyPKM)
if (pkm.Gen6 && pkm.WasEgg && ModifyPKM)
pkm.SetHatchMemory6();
}
@ -851,7 +851,7 @@ namespace PKHeX.WinForms.Controls
pkm.SetAbilityIndex(CB_Ability.SelectedIndex);
TB_PID.Text = pkm.PID.ToString("X8");
if (pkm.Format >= 6 && 3 <= pkm.GenNumber && pkm.GenNumber <= 5)
if (pkm.Format >= 6 && (pkm.Gen3 || pkm.Gen4 || pkm.Gen5))
TB_EC.Text = TB_PID.Text;
Update_ID(TB_EC, e);
}