Minor tweaks

Remove gen3 egg location hashset; only paths that reach it are for hatched eggs or current breed-eggs. Check breed eggs with the singular met location.
Simplify some logic flow
This commit is contained in:
Kurt 2021-01-20 12:37:51 -08:00
parent 9964c91dc6
commit fbc089e7eb
2 changed files with 43 additions and 42 deletions

View File

@ -89,7 +89,7 @@ private static CheckResult VerifyWildEncounterCrystalHeadbutt(ITrainerID tr, Enc
private static CheckResult VerifyEncounterEgg(PKM pkm, int gen) => gen switch
{
2 => new CheckResult(CheckIdentifier.Encounter), // valid -- no met location info
3 => pkm.Format != 3 ? VerifyEncounterEgg3Transfer(pkm) : VerifyEncounterEgg3(pkm),
3 => pkm.IsEgg ? VerifyUnhatchedEgg3(pkm) : VerifyEncounterEgg3(pkm),
4 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade4) : VerifyEncounterEgg4(pkm),
5 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade5) : VerifyEncounterEgg5(pkm),
6 => pkm.IsEgg ? VerifyUnhatchedEgg(pkm, Locations.LinkTrade6) : VerifyEncounterEgg6(pkm),
@ -98,33 +98,39 @@ private static CheckResult VerifyWildEncounterCrystalHeadbutt(ITrainerID tr, Enc
_ => new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter)
};
private static CheckResult VerifyEncounterEgg3(PKM pkm)
{
return pkm.Format == 3 ? VerifyEncounterEgg3Native(pkm) : VerifyEncounterEgg3Transfer(pkm);
}
private static CheckResult VerifyEncounterEgg3Native(PKM pkm)
private static CheckResult VerifyUnhatchedEgg3(PKM pkm)
{
if (pkm.Met_Level != 0)
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, 0), CheckIdentifier.Encounter);
if (pkm.IsEgg)
{
var loc = pkm.FRLG ? Legal.ValidEggMet_FRLG : Legal.ValidEggMet_RSE;
if (!loc.Contains(pkm.Met_Location))
return new CheckResult(Severity.Invalid, LEggMetLocationFail, CheckIdentifier.Encounter);
}
else
{
var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS;
if (locs.Contains(pkm.Met_Location))
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
if (Legal.ValidMet_FRLG.Contains(pkm.Met_Location) || Legal.ValidMet_E.Contains(pkm.Met_Location) || Legal.ValidMet_RS.Contains(pkm.Met_Location))
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
}
// Only EncounterEgg should reach here.
var loc = pkm.FRLG ? Locations.HatchLocationFRLG : Locations.HatchLocationRSE;
if (pkm.Met_Location != loc)
return new CheckResult(Severity.Invalid, LEggMetLocationFail, CheckIdentifier.Encounter);
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
}
private static CheckResult VerifyEncounterEgg3(PKM pkm)
{
if (pkm.Format != 3)
return VerifyEncounterEgg3Transfer(pkm);
if (pkm.Met_Level != 0)
return new CheckResult(Severity.Invalid, string.Format(LEggFMetLevel_0, 0), CheckIdentifier.Encounter);
// Check the origin game list.
var met = pkm.Met_Location;
var locs = pkm.FRLG ? Legal.ValidMet_FRLG : pkm.E ? Legal.ValidMet_E : Legal.ValidMet_RS;
if (locs.Contains(met))
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
// Version isn't updated when hatching on a different game. Check any game.
if (Legal.ValidMet_FRLG.Contains(met) || Legal.ValidMet_E.Contains(met) || Legal.ValidMet_RS.Contains(met))
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
return new CheckResult(Severity.Invalid, LEggLocationInvalid, CheckIdentifier.Encounter);
}
private static CheckResult VerifyEncounterEgg3Transfer(PKM pkm)
{
if (pkm.IsEgg)
@ -133,10 +139,17 @@ private static CheckResult VerifyEncounterEgg3Transfer(PKM pkm)
return new CheckResult(Severity.Invalid, LTransferEggMetLevel, CheckIdentifier.Encounter);
if (pkm.Egg_Location != 0)
return new CheckResult(Severity.Invalid, LEggLocationNone, CheckIdentifier.Encounter);
if (pkm.Format == 4 && pkm.Met_Location != Locations.Transfer3)
return new CheckResult(Severity.Invalid, LEggLocationPalPark, CheckIdentifier.Encounter);
if (pkm.Format != 4 && pkm.Met_Location != Locations.Transfer4)
return new CheckResult(Severity.Invalid, LTransferEggLocationTransporter, CheckIdentifier.Encounter);
if (pkm.Format != 4)
{
if (pkm.Met_Location != Locations.Transfer4)
return new CheckResult(Severity.Invalid, LTransferEggLocationTransporter, CheckIdentifier.Encounter);
}
else
{
if (pkm.Met_Location != Locations.Transfer3)
return new CheckResult(Severity.Invalid, LEggLocationPalPark, CheckIdentifier.Encounter);
}
return new CheckResult(Severity.Valid, LEggLocation, CheckIdentifier.Encounter);
}
@ -216,9 +229,10 @@ private static CheckResult VerifyUnhatchedEgg(PKM pkm, int tradeLoc)
if (pkm.Egg_Location == tradeLoc)
return new CheckResult(Severity.Invalid, LEggLocationTradeFail, CheckIdentifier.Encounter);
if (pkm.Met_Location == tradeLoc)
var met = pkm.Met_Location;
if (met == tradeLoc)
return new CheckResult(Severity.Valid, LEggLocationTrade, CheckIdentifier.Encounter);
return pkm.Met_Location == 0
return met == 0
? new CheckResult(Severity.Valid, LEggUnhatched, CheckIdentifier.Encounter)
: new CheckResult(Severity.Invalid, LEggLocationNone, CheckIdentifier.Encounter);
}
@ -271,7 +285,7 @@ private static CheckResult VerifyEncounterStatic(PKM pkm, EncounterStatic s)
return new CheckResult(Severity.Invalid, LG4InvalidTileR45Surf, CheckIdentifier.Encounter);
break;
case 7:
if (s.EggLocation == Locations.Daycare5 && pkm.RelearnMoves.Any(m => m != 0)) // eevee gift egg
if (s.EggLocation == Locations.Daycare5 && pkm.RelearnMoves.Any(m => m != 0)) // Eevee gift egg
return new CheckResult(Severity.Invalid, LEncStaticRelearn, CheckIdentifier.RelearnMove); // not gift egg
break;
}

View File

@ -194,19 +194,6 @@ public static partial class Legal
359, 385, 386 }
};
internal static readonly HashSet<int> ValidEggMet_RSE = new()
{
32, //Route 117
253, //Ingame egg gift
255 // event/pokemon box
};
internal static readonly HashSet<int> ValidEggMet_FRLG = new()
{
146, //Four Island
253, //Ingame egg gift
255 // event/pokemon box
};
// 064 is an unused location for Meteor Falls
// 084 is Inside of a truck, no possible pokemon can be hatched there
// 071 is Mirage island, cannot be obtained as the player is technically still on Route 130's map.