mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-05-09 04:24:36 -05:00
Clean up dexlevel/evocriteria constructor usage
DexLevel was the initial abstraction, which was expanded/reused for evolution details I should probably merge the two classes since everything is passed as EvoCriteria The encounter generators do some silly form fuzzy match which can now be more accurately checked since I've moved Form to DexLevel... maybe a future commit can clean that up. encounterarea2 was reusing this class, just use a throwaway readonly struct as our temp value storage
This commit is contained in:
parent
b49c5a5a8a
commit
eac3804c7b
|
|
@ -196,9 +196,9 @@ private static List<EncounterArea2> GetAreas2Fishing(byte[] data, ref int ofs)
|
|||
}
|
||||
|
||||
// Read TimeFishGroups
|
||||
var dl = new List<DexLevel>();
|
||||
var dl = new List<SlotTemplate>();
|
||||
while (ofs < data.Length)
|
||||
dl.Add(new DexLevel { Species = data[ofs++], Level = data[ofs++] });
|
||||
dl.Add(new SlotTemplate(data[ofs++], data[ofs++]));
|
||||
|
||||
// Add TimeSlots
|
||||
foreach (var area in areas)
|
||||
|
|
@ -228,6 +228,18 @@ private static List<EncounterArea2> GetAreas2Fishing(byte[] data, ref int ofs)
|
|||
return areas;
|
||||
}
|
||||
|
||||
private readonly struct SlotTemplate
|
||||
{
|
||||
public readonly byte Species;
|
||||
public readonly byte Level;
|
||||
|
||||
public SlotTemplate(byte species, byte level)
|
||||
{
|
||||
Species = species;
|
||||
Level = level;
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<EncounterArea2> GetAreas2Headbutt(byte[] data, ref int ofs)
|
||||
{
|
||||
// Read Location Table
|
||||
|
|
|
|||
|
|
@ -686,19 +686,16 @@ internal static EvoCriteria GetBaseSpecies(PKM pkm, int skipOption = 0, int gene
|
|||
|
||||
internal static EvoCriteria GetBaseSpecies(PKM pkm, IReadOnlyList<EvoCriteria> evos, int skipOption = 0) => GetBaseSpecies(pkm.Species, evos, skipOption);
|
||||
|
||||
private static readonly EvoCriteria Nincada = new EvoCriteria
|
||||
private static readonly EvoCriteria Nincada = new EvoCriteria(290, 0)
|
||||
{
|
||||
Method = (int)EvolutionType.LevelUp,
|
||||
MinLevel = 20, Level = 20,
|
||||
RequiresLvlUp = true,
|
||||
Species = 290, Form = 0,
|
||||
};
|
||||
|
||||
private static readonly EvoCriteria EvoEmpty = new EvoCriteria
|
||||
private static readonly EvoCriteria EvoEmpty = new EvoCriteria(290, 0)
|
||||
{
|
||||
Method = (int)EvolutionType.None,
|
||||
Species = 0,
|
||||
Form = 0,
|
||||
};
|
||||
|
||||
internal static EvoCriteria GetBaseSpecies(int species, IReadOnlyList<EvoCriteria> evos, int skipOption = 0)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,15 @@
|
|||
/// </summary>
|
||||
public class DexLevel
|
||||
{
|
||||
public int Species { get; set; }
|
||||
public readonly int Species;
|
||||
public readonly int Form;
|
||||
|
||||
public int Level { get; set; }
|
||||
|
||||
protected DexLevel(int species, int form)
|
||||
{
|
||||
Species = species;
|
||||
Form = form;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,12 @@
|
|||
{
|
||||
public sealed class EvoCriteria : DexLevel
|
||||
{
|
||||
public EvoCriteria(int species, int form) : base(species, form)
|
||||
{
|
||||
}
|
||||
|
||||
public int MinLevel { get; set; }
|
||||
public bool RequiresLvlUp { get; set; }
|
||||
public int Form { get; set; } = -1;
|
||||
public int Method { get; set; } = -1;
|
||||
|
||||
public bool IsTradeRequired => ((EvolutionType) Method).IsTrade();
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ internal static List<EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspecieso
|
|||
{
|
||||
return new List<EvoCriteria>(1)
|
||||
{
|
||||
new EvoCriteria { Species = pkm.Species, Level = lvl, MinLevel = lvl },
|
||||
new EvoCriteria(pkm.Species, pkm.AltForm) { Level = lvl, MinLevel = lvl },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -248,8 +248,8 @@ internal static List<EvoCriteria> GetValidPreEvolutions(PKM pkm, int maxspecieso
|
|||
{
|
||||
return new List<EvoCriteria>(2)
|
||||
{
|
||||
new EvoCriteria { Species = (int)Species.Shedinja, Level = lvl, MinLevel = 20, Form = 0 },
|
||||
new EvoCriteria { Species = (int)Species.Nincada, Level = lvl, MinLevel = 1, Form = 0 }
|
||||
new EvoCriteria((int)Species.Shedinja, 0) { Level = lvl, MinLevel = 20 },
|
||||
new EvoCriteria((int)Species.Nincada, 0) { Level = lvl, MinLevel = 1 },
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,11 +105,9 @@ private bool HasMetLevelIncreased(PKM pkm, int lvl)
|
|||
|
||||
public EvoCriteria GetEvoCriteria(int species, int form, int lvl)
|
||||
{
|
||||
return new EvoCriteria
|
||||
return new EvoCriteria(species, form)
|
||||
{
|
||||
Species = species,
|
||||
Level = lvl,
|
||||
Form = form,
|
||||
Method = Method,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ private IEnumerable<int> GetEvolutions(int species, int form)
|
|||
private List<EvoCriteria> GetExplicitLineage(PKM pkm, int maxLevel, bool skipChecks, int maxSpeciesOrigin, int minLevel)
|
||||
{
|
||||
int lvl = maxLevel;
|
||||
var first = new EvoCriteria { Species = pkm.Species, Level = lvl, Form = pkm.AltForm };
|
||||
var first = new EvoCriteria(pkm.Species, pkm.AltForm) { Level = lvl, };
|
||||
|
||||
const int maxEvolutions = 3;
|
||||
var dl = new List<EvoCriteria>(maxEvolutions) { first };
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user