mirror of
https://github.com/kwsch/PKHeX
synced 2025-02-17 05:48:44 +00:00
Add Form (AltForm) to IEncounterable interface
All of the encounterable templates have Form anyway; funny that I was consistent naming them all differently than pkm.AltForm :) Closes #2452
This commit is contained in:
parent
09e9409df2
commit
f88388cb70
12 changed files with 30 additions and 26 deletions
|
@ -86,7 +86,8 @@ namespace PKHeX.Core
|
|||
return _allSuggestedRelearnMoves;
|
||||
if (Error || Info == null)
|
||||
return new int[4];
|
||||
return _allSuggestedRelearnMoves = Legal.GetValidRelearn(pkm, Info.EncounterMatch.Species, (GameVersion)pkm.Version).ToArray();
|
||||
var enc = Info.EncounterMatch;
|
||||
return _allSuggestedRelearnMoves = Legal.GetValidRelearn(pkm, enc.Species, enc.Form, (GameVersion)pkm.Version).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -456,7 +457,7 @@ namespace PKHeX.Core
|
|||
if (!Parsed)
|
||||
return new int[4];
|
||||
if (pkm.IsEgg && pkm.Format <= 5) // pre relearn
|
||||
return Legal.GetBaseEggMoves(pkm, pkm.Species, (GameVersion)pkm.Version, pkm.CurrentLevel);
|
||||
return Legal.GetBaseEggMoves(pkm, pkm.Species, 0, (GameVersion)pkm.Version, pkm.CurrentLevel);
|
||||
|
||||
if (!tm && !tutor && !reminder)
|
||||
{
|
||||
|
|
|
@ -106,26 +106,25 @@ namespace PKHeX.Core
|
|||
return GetValidMoves(pkm, version, evoChain, generation, minLvLG1: minLvLG1, minLvLG2: minLvLG2, LVL: LVL, Relearn: false, Tutor: Tutor, Machine: Machine, MoveReminder: MoveReminder, RemoveTransferHM: RemoveTransferHM);
|
||||
}
|
||||
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, GameVersion version = GameVersion.Any)
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, int form, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
return GetValidRelearn(pkm, species, GetCanInheritMoves(species), version);
|
||||
return GetValidRelearn(pkm, species, form, GetCanInheritMoves(species), version);
|
||||
}
|
||||
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, bool inheritlvlmoves, GameVersion version = GameVersion.Any)
|
||||
internal static IEnumerable<int> GetValidRelearn(PKM pkm, int species, int form, bool inheritlvlmoves, GameVersion version = GameVersion.Any)
|
||||
{
|
||||
var r = new List<int> { 0 };
|
||||
if (pkm.GenNumber < 6)
|
||||
return r;
|
||||
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 1, pkm.AltForm, version));
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 1, form, version));
|
||||
|
||||
int form = pkm.AltForm;
|
||||
if (pkm.Format == 6 && pkm.Species != 678)
|
||||
form = 0;
|
||||
|
||||
r.AddRange(MoveEgg.GetEggMoves(pkm, species, form, version));
|
||||
if (inheritlvlmoves)
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 100, pkm.AltForm, version));
|
||||
r.AddRange(MoveEgg.GetRelearnLVLMoves(pkm, species, 100, form, version));
|
||||
return r.Distinct();
|
||||
}
|
||||
|
||||
|
@ -159,7 +158,7 @@ namespace PKHeX.Core
|
|||
return moves.GetLevelLearnMove(move);
|
||||
}
|
||||
|
||||
internal static int[] GetBaseEggMoves(PKM pkm, int species, GameVersion gameSource, int lvl)
|
||||
internal static int[] GetBaseEggMoves(PKM pkm, int species, int form, GameVersion gameSource, int lvl)
|
||||
{
|
||||
if (gameSource == GameVersion.Any)
|
||||
gameSource = (GameVersion)pkm.Version;
|
||||
|
@ -248,7 +247,7 @@ namespace PKHeX.Core
|
|||
break;
|
||||
if (pkm.InhabitedGeneration(7))
|
||||
{
|
||||
int index = PersonalTable.SM.GetFormeIndex(species, pkm.AltForm);
|
||||
int index = PersonalTable.SM.GetFormeIndex(species, form);
|
||||
return LevelUpSM[index].GetMoves(lvl);
|
||||
}
|
||||
break;
|
||||
|
@ -258,7 +257,7 @@ namespace PKHeX.Core
|
|||
case GameVersion.USUM:
|
||||
if (pkm.InhabitedGeneration(7))
|
||||
{
|
||||
int index = PersonalTable.USUM.GetFormeIndex(species, pkm.AltForm);
|
||||
int index = PersonalTable.USUM.GetFormeIndex(species, form);
|
||||
return LevelUpUSUM[index].GetMoves(lvl);
|
||||
}
|
||||
break;
|
||||
|
@ -268,7 +267,7 @@ namespace PKHeX.Core
|
|||
case GameVersion.SWSH:
|
||||
if (pkm.InhabitedGeneration(8))
|
||||
{
|
||||
int index = PersonalTable.SWSH.GetFormeIndex(species, pkm.AltForm);
|
||||
int index = PersonalTable.SWSH.GetFormeIndex(species, form);
|
||||
return LevelUpSWSH[index].GetMoves(lvl);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -132,14 +132,14 @@ namespace PKHeX.Core
|
|||
|
||||
private int[] GetCurrentEggMoves(PKM pk, GameVersion version)
|
||||
{
|
||||
var moves = MoveEgg.GetEggMoves(pk, Species, pk.AltForm, version);
|
||||
var moves = MoveEgg.GetEggMoves(pk, Species, Form, version);
|
||||
if (moves.Length == 0)
|
||||
return MoveLevelUp.GetEncounterMoves(pk, Level, version);
|
||||
if (moves.Length >= 4 || pk.Format < 6)
|
||||
return moves;
|
||||
|
||||
// Sprinkle in some default level up moves
|
||||
var lvl = Legal.GetBaseEggMoves(pk, Species, version, Level);
|
||||
var lvl = Legal.GetBaseEggMoves(pk, Species, Form, version, Level);
|
||||
return lvl.Concat(moves).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace PKHeX.Core
|
|||
public static readonly EncounterInvalid Default = new EncounterInvalid();
|
||||
|
||||
public int Species { get; }
|
||||
public int Form { get; }
|
||||
public int LevelMin { get; }
|
||||
public int LevelMax { get; }
|
||||
public bool EggEncounter { get; }
|
||||
|
@ -22,6 +23,7 @@ namespace PKHeX.Core
|
|||
public EncounterInvalid(PKM pkm)
|
||||
{
|
||||
Species = pkm.Species;
|
||||
Form = pkm.AltForm;
|
||||
LevelMin = pkm.Met_Level;
|
||||
LevelMax = pkm.CurrentLevel;
|
||||
EggEncounter = pkm.WasEgg;
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace PKHeX.Core
|
|||
public string Reason => Check.Comment;
|
||||
|
||||
public int Species => Encounter.Species;
|
||||
public int Form => Encounter.Form;
|
||||
public string Name => Encounter.Name;
|
||||
public string LongName => Encounter.LongName;
|
||||
public bool EggEncounter => Encounter.EggEncounter;
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace PKHeX.Core
|
|||
{
|
||||
if (Permissions.IsDexNav)
|
||||
{
|
||||
var eggMoves = MoveEgg.GetEggMoves(pk, Species, pk.AltForm, Version);
|
||||
var eggMoves = MoveEgg.GetEggMoves(pk, Species, Form, Version);
|
||||
if (eggMoves.Length > 0)
|
||||
pk6.RelearnMove1 = eggMoves[Util.Rand.Next(eggMoves.Length)];
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace PKHeX.Core
|
|||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<int> em = MoveEgg.GetEggMoves(pk, egg.Species, pk.AltForm, version);
|
||||
IEnumerable<int> em = MoveEgg.GetEggMoves(pk, egg.Species, egg.Form, version);
|
||||
if (Legal.LightBall.Contains(egg.Species) && needs.Contains(344))
|
||||
em = em.Concat(new[] {344}); // Volt Tackle
|
||||
if (!needs.Except(em).Any())
|
||||
|
|
|
@ -108,14 +108,14 @@ namespace PKHeX.Core
|
|||
var pi = pkm.PersonalInfo;
|
||||
var AllowLevelUp = notEvent && !pi.Genderless && !(pi.OnlyMale && Legal.MixedGenderBreeding.Contains(e.Species));
|
||||
int BaseLevel = AllowLevelUp ? 100 : e.LevelMin;
|
||||
var LevelUp = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, BaseLevel);
|
||||
var LevelUp = Legal.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, BaseLevel);
|
||||
|
||||
var TradebackPreevo = pkm.Format == 2 && info.EncounterMatch.Species > 151;
|
||||
var NonTradebackLvlMoves = TradebackPreevo
|
||||
? Legal.GetExclusivePreEvolutionMoves(pkm, info.EncounterMatch.Species, info.EvoChainsAllGens[2], 2, e.Version).Where(m => m > Legal.MaxMoveID_1).ToArray()
|
||||
: Array.Empty<int>();
|
||||
|
||||
var Egg = MoveEgg.GetEggMoves(pkm, e.Species, pkm.AltForm, e.Version);
|
||||
var Egg = MoveEgg.GetEggMoves(pkm, e.Species, e.Form, e.Version);
|
||||
if (info.Generation < 3 && pkm.Format >= 7 && pkm.VC1)
|
||||
Egg = Egg.Where(m => m <= Legal.MaxMoveID_1).ToArray();
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace PKHeX.Core
|
|||
|
||||
// DexNav Pokémon can have 1 random egg move as a relearn move.
|
||||
var enc = info.EncounterMatch;
|
||||
result[0] = !Legal.GetValidRelearn(pkm, enc.Species, true).Contains(RelearnMoves[0])
|
||||
result[0] = !Legal.GetValidRelearn(pkm, enc.Species, enc.Form, true).Contains(RelearnMoves[0])
|
||||
? new CheckResult(Severity.Invalid, LMoveRelearnDexNav, CheckIdentifier.RelearnMove)
|
||||
: new CheckResult(CheckIdentifier.RelearnMove);
|
||||
|
||||
|
@ -97,11 +97,11 @@ namespace PKHeX.Core
|
|||
bool inheritLvlMoves = Legal.GetCanInheritMoves(e.Species);
|
||||
|
||||
// Obtain level1 moves
|
||||
var baseMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, 1);
|
||||
var baseMoves = Legal.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, 1);
|
||||
int baseCt = Math.Min(4, baseMoves.Length);
|
||||
|
||||
// Obtain Inherited moves
|
||||
var inheritMoves = Legal.GetValidRelearn(pkm, e.Species, inheritLvlMoves, e.Version).ToList();
|
||||
var inheritMoves = Legal.GetValidRelearn(pkm, e.Species, e.Form, inheritLvlMoves, e.Version).ToList();
|
||||
int reqBase = GetRequiredBaseMoves(RelearnMoves, baseMoves, baseCt, inheritMoves);
|
||||
|
||||
// Check if the required amount of Base Egg Moves are present.
|
||||
|
@ -113,7 +113,7 @@ namespace PKHeX.Core
|
|||
|
||||
// If any splitbreed moves are invalid, flag accordingly
|
||||
var splitMoves = e is EncounterEggSplit s
|
||||
? Legal.GetValidRelearn(pkm, s.OtherSpecies, inheritLvlMoves, e.Version).ToList()
|
||||
? Legal.GetValidRelearn(pkm, s.OtherSpecies, s.Form, inheritLvlMoves, e.Version).ToList()
|
||||
: (IReadOnlyList<int>)Array.Empty<int>();
|
||||
|
||||
// Inherited moves appear after the required base moves.
|
||||
|
|
|
@ -15,11 +15,11 @@ namespace PKHeX.Core
|
|||
|
||||
// Level up moves can only be inherited if ditto is not the mother.
|
||||
bool AllowLevelUp = Legal.GetCanInheritMoves(e.Species);
|
||||
Base = Legal.GetBaseEggMoves(pkm, e.Species, e.Version, e.Level);
|
||||
Base = Legal.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, e.Level);
|
||||
|
||||
Egg = MoveEgg.GetEggMoves(pkm, e.Species, pkm.AltForm, e.Version);
|
||||
Egg = MoveEgg.GetEggMoves(pkm, e.Species, e.Form, e.Version);
|
||||
LevelUp = AllowLevelUp
|
||||
? Legal.GetBaseEggMoves(pkm, e.Species, e.Version, 100).Except(Base).ToList()
|
||||
? Legal.GetBaseEggMoves(pkm, e.Species, e.Form, e.Version, 100).Except(Base).ToList()
|
||||
: (IReadOnlyList<int>)Array.Empty<int>();
|
||||
Tutor = e.Version == GameVersion.C
|
||||
? MoveTutor.GetTutorMoves(pkm, pkm.Species, pkm.AltForm, false, 2).ToList()
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
public interface IEncounterable
|
||||
{
|
||||
int Species { get; }
|
||||
int Form { get; }
|
||||
string Name { get; }
|
||||
string LongName { get; }
|
||||
bool EggEncounter { get; }
|
||||
|
|
|
@ -148,7 +148,7 @@ namespace PKHeX.Core
|
|||
private void SetMoves(PK3 pk)
|
||||
{
|
||||
if (Moves.Length == 0) // not completely defined
|
||||
Moves = Legal.GetBaseEggMoves(pk, Species, (GameVersion)pk.Version, Level);
|
||||
Moves = Legal.GetBaseEggMoves(pk, Species, Form, (GameVersion)pk.Version, Level);
|
||||
if (Moves.Length != 4)
|
||||
{
|
||||
var moves = Moves;
|
||||
|
|
Loading…
Add table
Reference in a new issue