mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-16 17:18:00 +00:00
7b874757f7
Previous approach was 'most likely to find valid', this approach is a little greedier to try to find a more fitting match. Will result in a small increase in computation time, but trying out EncounterTrades and static encounters first is preferred. Fix Rhydon ingame trade gender. Bulbapedia is wrong, that's a Male Rhydon with those IVs.
70 lines
2.3 KiB
C#
70 lines
2.3 KiB
C#
using System.Linq;
|
|
|
|
namespace PKHeX.Core
|
|
{
|
|
public enum GBEncounterType
|
|
{
|
|
EggEncounter,
|
|
WildEncounter,
|
|
StaticEncounter,
|
|
SpecialEncounter,
|
|
TradeEncounterG1,
|
|
TradeEncounterG2,
|
|
}
|
|
|
|
public class GBEncounterData : IEncounterable
|
|
{
|
|
public readonly int Level;
|
|
public int MoveLevel;
|
|
public GameVersion Game;
|
|
public readonly int Generation;
|
|
public readonly GBEncounterType Type;
|
|
public readonly IEncounterable Encounter;
|
|
|
|
public int Species => Encounter.Species;
|
|
public string Name => Encounter.Name;
|
|
public bool EggEncounter => Encounter.EggEncounter;
|
|
public int LevelMin => Encounter.LevelMin;
|
|
public int LevelMax => Encounter.LevelMax;
|
|
|
|
// Egg encounter
|
|
public GBEncounterData(int species, GameVersion game)
|
|
{
|
|
Generation = 2;
|
|
Game = game;
|
|
Encounter = new EncounterEgg { Species = species, Game = game, Level = Level };
|
|
}
|
|
|
|
public GBEncounterData(PKM pkm, int gen, IEncounterable enc, GameVersion game)
|
|
{
|
|
Game = game;
|
|
Generation = gen;
|
|
Encounter = enc;
|
|
if (Encounter is EncounterTrade trade)
|
|
{
|
|
if (pkm.HasOriginalMetLocation && trade.Level < pkm.Met_Level)
|
|
Level = pkm.Met_Level; // Crystal
|
|
else
|
|
Level = trade.Level;
|
|
Type = Generation == 2
|
|
? GBEncounterType.TradeEncounterG2
|
|
: GBEncounterType.TradeEncounterG1;
|
|
}
|
|
else if (Encounter is EncounterStatic statc)
|
|
{
|
|
Level = statc.Level;
|
|
Type = statc.Moves != null && statc.Moves[0] != 0 && pkm.Moves.Contains(statc.Moves[0])
|
|
? GBEncounterType.SpecialEncounter
|
|
: GBEncounterType.StaticEncounter;
|
|
}
|
|
else if (Encounter is EncounterSlot1 slot)
|
|
{
|
|
Level = pkm.HasOriginalMetLocation && slot.LevelMin >= pkm.Met_Level && pkm.Met_Level <= slot.LevelMax
|
|
? pkm.Met_Level // Crystal
|
|
: slot.LevelMin;
|
|
Type = GBEncounterType.WildEncounter;
|
|
}
|
|
MoveLevel = Level;
|
|
}
|
|
}
|
|
}
|