Minor tweaks

Enc static 4 should check met location, since locations are flexible for roamers
Simplify expressions
Disallow 0 moves in "needed moves" list.
This commit is contained in:
Kurt 2020-11-19 15:34:06 -08:00
parent 9d8b528437
commit ce17fd4050
8 changed files with 42 additions and 24 deletions

View file

@ -129,6 +129,7 @@ namespace PKHeX.Core
if (Gen5.Contains(game)) return 5; if (Gen5.Contains(game)) return 5;
if (Gen6.Contains(game)) return 6; if (Gen6.Contains(game)) return 6;
if (Gen7.Contains(game)) return 7; if (Gen7.Contains(game)) return 7;
if (Gen7b.Contains(game)) return 7;
if (Gen8.Contains(game)) return 8; if (Gen8.Contains(game)) return 8;
return -1; return -1;
} }

View file

@ -91,7 +91,8 @@ namespace PKHeX.Core
if (pkm.TSV == 0) // HOME doesn't assign TSV=0 to accounts. if (pkm.TSV == 0) // HOME doesn't assign TSV=0 to accounts.
yield break; yield break;
var sf = chain.FirstOrDefault(z => z.Species == Species && z.Form == Form); var sf = chain.FirstOrDefault(z => z.Species == Species
&& (z.Form == Form || AltFormInfo.IsFormChangeable(Species, Form, z.Form, pkm.Format)));
if (sf == null) if (sf == null)
yield break; yield break;

View file

@ -22,5 +22,12 @@ namespace PKHeX.Core
pb.HeightScalar = PokeSizeUtil.GetRandomScalar(); pb.HeightScalar = PokeSizeUtil.GetRandomScalar();
pb.WeightScalar = PokeSizeUtil.GetRandomScalar(); pb.WeightScalar = PokeSizeUtil.GetRandomScalar();
} }
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{
var moves = MoveLevelUp.GetEncounterMoves(pk, level, GameVersion.GG);
pk.SetMoves(moves);
pk.SetMaximumPPCurrent(moves);
}
} }
} }

View file

@ -35,5 +35,12 @@ namespace PKHeX.Core
pk8.HeightScalar = PokeSizeUtil.GetRandomScalar(); pk8.HeightScalar = PokeSizeUtil.GetRandomScalar();
pk8.WeightScalar = PokeSizeUtil.GetRandomScalar(); pk8.WeightScalar = PokeSizeUtil.GetRandomScalar();
} }
protected override void SetEncounterMoves(PKM pk, GameVersion version, int level)
{
var moves = MoveLevelUp.GetEncounterMoves(pk, level, OriginGroup);
pk.SetMoves(moves);
pk.SetMaximumPPCurrent(moves);
}
} }
} }

View file

@ -79,9 +79,12 @@ namespace PKHeX.Core
if (Start == 0) if (Start == 0)
return End == 0 ? DateTime.Now : GetDate(End); return End == 0 ? DateTime.Now : GetDate(End);
var end = Math.Max(Start, End); var start = GetDate(Start);
var delta = end - Start; if (End == 0)
var bias = Util.Rand.Next(0, delta + 1); return start;
var end = GetDate(End);
var delta = end - start;
var bias = Util.Rand.Next(0, delta.Days + 1);
return GetDate(Start).AddDays(bias); return GetDate(Start).AddDays(bias);
} }

View file

@ -152,9 +152,14 @@ namespace PKHeX.Core
if (pk.Species == (int)Species.Smeargle) if (pk.Species == (int)Species.Smeargle)
return moves.Intersect(Legal.InvalidSketch).ToArray(); // Can learn anything return moves.Intersect(Legal.InvalidSketch).ToArray(); // Can learn anything
var gens = VerifyCurrentMoves.GetGenMovesCheckOrder(pk); // Roughly determine the generation the PKM is originating from
int origin = pk.GenNumber;
if (origin < 0)
origin = ((GameVersion)pk.Version).GetGeneration();
var gens = VerifyCurrentMoves.GetGenMovesCheckOrder(pk, origin);
var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z)); var canlearn = gens.SelectMany(z => GetMovesForGeneration(pk, chain, z));
return moves.Except(canlearn).ToArray(); return moves.Except(canlearn).Where(z => z != 0).ToArray();
} }
private static IEnumerable<int> GetMovesForGeneration(PKM pk, IReadOnlyList<EvoCriteria> chain, int generation) private static IEnumerable<int> GetMovesForGeneration(PKM pk, IReadOnlyList<EvoCriteria> chain, int generation)
@ -367,21 +372,16 @@ namespace PKHeX.Core
{ {
switch (enc.Generation) switch (enc.Generation)
{ {
case 4 when enc is EncounterStaticTyped t && enc.Location == 193: case 4 when enc is EncounterStaticTyped t && pk.Met_Location == 193: // Johto Route 45 surfing encounter. Unreachable Water tiles.
if (t.TypeEncounter == EncounterType.Surfing_Fishing) // Johto Route 45 surfing encounter. Unreachable Water tiles. return t.TypeEncounter == EncounterType.Surfing_Fishing; // Roamer Raikou
return true; // only hits for Roamer Raikou
break;
case 4: case 4:
switch (pk.Species) return enc.Species switch
{ {
case (int)Species.Darkrai when enc.Location == 079 && !pk.Pt: // DP Darkrai (int)Species.Darkrai when enc.Location == 079 && enc.Version != GameVersion.Pt => true, // DP Darkrai
return true; (int)Species.Shaymin when enc.Location == 063 && enc.Version != GameVersion.Pt => true, // DP Shaymin
case (int)Species.Shaymin when enc.Location == 063 && !pk.Pt: // DP Shaymin (int)Species.Arceus when enc.Location == 086 => true, // Azure Flute Arceus
return true; _ => false
case (int)Species.Arceus when enc.Location == 086: // Azure Flute Arceus };
return true;
}
break;
} }
return false; return false;

View file

@ -282,7 +282,7 @@ namespace PKHeX.Core
case (int)Species.Arceus when s.Location == 086: // Azure Flute Arceus case (int)Species.Arceus when s.Location == 086: // Azure Flute Arceus
return new CheckResult(Severity.Invalid, LEncUnreleasedHoOArceus, CheckIdentifier.Encounter); return new CheckResult(Severity.Invalid, LEncUnreleasedHoOArceus, CheckIdentifier.Encounter);
} }
if (s.Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfing in Johto Route 45 if (pkm.Met_Location == 193 && s is EncounterStaticTyped t && t.TypeEncounter == EncounterType.Surfing_Fishing) // Roaming pokemon surfing in Johto Route 45
return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter); return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter);
break; break;
case 7: case 7:

View file

@ -268,7 +268,7 @@ namespace PKHeX.Core
// Encapsulate arguments to simplify method calls // Encapsulate arguments to simplify method calls
var moveInfo = new LearnInfo(pkm, source); var moveInfo = new LearnInfo(pkm, source);
// Check moves going backwards, marking the move valid in the most current generation when it can be learned // Check moves going backwards, marking the move valid in the most current generation when it can be learned
int[] generations = GetGenMovesCheckOrder(pkm); int[] generations = GetGenMovesCheckOrder(pkm, info.EncounterOriginal.Generation);
if (pkm.Format <= 2) if (pkm.Format <= 2)
generations = generations.Where(z => z < info.EncounterMoves.LevelUpMoves.Length).ToArray(); generations = generations.Where(z => z < info.EncounterMoves.LevelUpMoves.Length).ToArray();
if (reset != 0) if (reset != 0)
@ -887,14 +887,13 @@ namespace PKHeX.Core
/// <summary> /// <summary>
/// Gets the generation numbers in descending order for iterating over. /// Gets the generation numbers in descending order for iterating over.
/// </summary> /// </summary>
public static int[] GetGenMovesCheckOrder(PKM pkm) public static int[] GetGenMovesCheckOrder(PKM pkm, int origin)
{ {
if (pkm.Format < 3) if (pkm.Format < 3)
return GetGenMovesCheckOrderGB(pkm, pkm.Format); return GetGenMovesCheckOrderGB(pkm, pkm.Format);
if (pkm.VC) if (pkm.VC)
return GetGenMovesOrderVC(pkm); return GetGenMovesOrderVC(pkm);
return GetGenMovesOrder(pkm.Format, origin);
return GetGenMovesOrder(pkm.Format, pkm.GenNumber);
} }
private static int[] GetGenMovesOrderVC(PKM pkm) private static int[] GetGenMovesOrderVC(PKM pkm)