Hide Generation/Game setters behind mutation method

This commit is contained in:
Kurt
2021-08-06 15:35:49 -07:00
parent 391c6d4af6
commit 9f8642f7d2
2 changed files with 11 additions and 7 deletions

View File

@@ -17,8 +17,7 @@ internal static IEnumerable<IEncounterable> GetEncounters12(PKM pkm, LegalInfo i
{
foreach (var z in GenerateFilteredEncounters12(pkm))
{
info.Generation = z.Generation;
info.Game = z.Version;
info.StoreMetadata(z.Version, z.Generation);
yield return z;
}
}

View File

@@ -11,10 +11,10 @@ public sealed class LegalInfo : IGeneration
private readonly PKM pkm;
/// <summary>The generation of games the <see cref="PKM"/> originated from.</summary>
public int Generation { get; internal set; }
public int Generation { get; private set; }
/// <summary>The Game the <see cref="PKM"/> originated from.</summary>
public GameVersion Game { get; internal set; }
public GameVersion Game { get; private set; }
/// <summary>The matched Encounter details for the <see cref="PKM"/>. </summary>
public IEncounterable EncounterMatch
@@ -78,10 +78,15 @@ public LegalInfo(PKM pk, List<CheckResult> parse)
{
pkm = pk;
Parse = parse;
StoreMetadata((GameVersion)pk.Version, pkm.Generation);
}
// Store repeatedly accessed values
Game = (GameVersion)pkm.Version;
Generation = pkm.Generation;
internal void StoreMetadata(GameVersion game, int gen)
{
// We can call this method at the start for any Gen3+ encounter iteration.
// We need to call this for each Gen1/2 encounter as Version is not stored for those origins.
Game = game;
Generation = gen;
}
/// <summary>List of all near-matches that were rejected for a given reason.</summary>