Add pelago status value check + etc

0, [9,19] are set (didn't see 15), but there's also a switch case which
references all values 0-19.

these values are used by a 80 sbyte array (4*20) in the Resort.cro

remove usages of "goto case"
This commit is contained in:
Kurt 2018-08-27 20:44:26 -07:00
parent 102430ebf5
commit 4dc04cb4b9
7 changed files with 38 additions and 44 deletions

View file

@ -160,23 +160,21 @@ namespace PKHeX.Core
{
case RB:
return g2 == RD || g2 == BU || g2 == GN;
case Stadium:
case EventsGBGen1:
case VCEvents:
case RBY:
return RB.Contains(g2) || g2 == YW;
case Gen1:
return RBY.Contains(g2) || g2 == Stadium || g2 == EventsGBGen1 || g2 == VCEvents;
case Stadium:
case EventsGBGen1:
case VCEvents:
goto case RBY;
case GS: return g2 == GD || g2 == SV;
case Stadium2:
case EventsGBGen2:
case GSC:
return GS.Contains(g2) || g2 == C;
case Gen2:
return GSC.Contains(g2) || g2 == Stadium2 || g2 == EventsGBGen2;
case Stadium2:
case EventsGBGen2:
goto case GSC;
case GBCartEraOnly:
return g2 == Stadium || g2 == Stadium2 || g2 == EventsGBGen1 || g2 == EventsGBGen2;

View file

@ -178,7 +178,7 @@ namespace PKHeX.Core
return r.Distinct();
}
internal static IList<int> GetShedinjaEvolveMoves(PKM pkm, int lvl = -1, int generation = 0)
internal static IList<int> GetShedinjaEvolveMoves(PKM pkm, int generation, int lvl = -1)
{
if (lvl == -1)
lvl = pkm.CurrentLevel;
@ -189,13 +189,9 @@ namespace PKHeX.Core
// Shedinja would appear with that move learned. Only one move above level 20 allowed, only in generations 3 and 4
switch (generation)
{
case 0: // Default (both)
case 3: // Ninjask have the same learnset in every gen 3 games
if (pkm.InhabitedGeneration(3))
return LevelUpE[291].GetMoves(lvl, 20).ToList();
if (generation == 0)
goto case 4;
break;
case 4: // Ninjask have the same learnset in every gen 4 games
if (pkm.InhabitedGeneration(4))

View file

@ -592,7 +592,7 @@ namespace PKHeX.Core
var ShedinjaEvoMovesLearned = new List<int>();
for (int gen = Math.Min(pkm.Format, 4); gen >= 3; gen--)
{
var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, generation: gen);
var ninjaskMoves = Legal.GetShedinjaEvolveMoves(pkm, gen);
bool native = gen == pkm.Format;
for (int m = 0; m < 4; m++)
{

View file

@ -423,6 +423,7 @@ namespace PKHeX.Core
public static string V611 { get; set; } = "Korean"; // Invalid
public static string V612 { get; set; } = "Non-Korean"; // Invalid
public static string V613 { get; set; } = "Eggs cannot receive experience.";
public static string V614 { get; set; } = "Incorrectly transferred from previous generation.";
#endregion
}

View file

@ -34,6 +34,9 @@ namespace PKHeX.Core
}
}
if (pkm is PK7 pk7 && pk7.ResortEventStatus >= 20)
data.AddLine(GetInvalid(V614));
VerifyMiscFatefulEncounter(data);
}
@ -92,37 +95,30 @@ namespace PKHeX.Core
{
var e = data.EncounterMatch;
var catch_rate = pk1.Catch_Rate;
switch (pk1.TradebackStatus)
{
case TradebackType.Any:
case TradebackType.WasTradeback:
if (catch_rate == 0 || Legal.HeldItems_GSC.Contains((ushort)catch_rate))
data.AddLine(GetValid(V394));
else if (pk1.TradebackStatus == TradebackType.WasTradeback)
data.AddLine(GetInvalid(V395));
else
goto case TradebackType.Gen1_NotTradeback;
break;
case TradebackType.Gen1_NotTradeback:
if ((e as EncounterStatic)?.Version == GameVersion.Stadium || e is EncounterTradeCatchRate)
{
// Encounters detected by the catch rate, cant be invalid if match this encounters
data.AddLine(GetValid(V398));
}
else if ((pk1.Species == 149 && catch_rate == PersonalTable.Y[149].CatchRate) || (Legal.Species_NotAvailable_CatchRate.Contains(pk1.Species) && catch_rate == PersonalTable.RB[pk1.Species].CatchRate))
{
data.AddLine(GetInvalid(V396));
}
else if (!data.Info.EvoChainsAllGens[1].Any(c => RateMatchesEncounter(c.Species)))
{
data.AddLine(GetInvalid(pk1.Gen1_NotTradeback ? V397 : V399));
}
else
{
data.AddLine(GetValid(V398));
}
var result = pk1.TradebackStatus == TradebackType.Gen1_NotTradeback
? GetWasNotTradeback()
: GetWasTradeback();
data.AddLine(result);
break;
CheckResult GetWasTradeback()
{
if (catch_rate == 0 || Legal.HeldItems_GSC.Contains((ushort)catch_rate))
return GetValid(V394);
if (pk1.TradebackStatus == TradebackType.WasTradeback)
return GetInvalid(V395);
return GetWasNotTradeback();
}
CheckResult GetWasNotTradeback()
{
if ((e as EncounterStatic)?.Version == GameVersion.Stadium || e is EncounterTradeCatchRate)
return GetValid(V398); // Encounters detected by the catch rate, cant be invalid if match this encounters
if ((pk1.Species == 149 && catch_rate == PersonalTable.Y[149].CatchRate) || (Legal.Species_NotAvailable_CatchRate.Contains(pk1.Species) && catch_rate == PersonalTable.RB[pk1.Species].CatchRate))
return GetInvalid(V396);
if (!data.Info.EvoChainsAllGens[1].Any(c => RateMatchesEncounter(c.Species)))
return GetInvalid(pk1.Gen1_NotTradeback ? V397 : V399);
return GetValid(V398);
}
bool RateMatchesEncounter(int species)

View file

@ -101,7 +101,7 @@ namespace PKHeX.Core
public int CNT_Smart { get => Data[0x27]; set => Data[0x27] = (byte)value; }
public int CNT_Tough { get => Data[0x28]; set => Data[0x28] = (byte)value; }
public int CNT_Sheen { get => Data[0x29]; set => Data[0x29] = (byte)value; }
public byte PelagoEventStatus { get => Data[0x2A]; set => Data[0x2A] = value; }
public byte ResortEventStatus { get => Data[0x2A]; set => Data[0x2A] = value; }
private byte PKRS { get => Data[0x2B]; set => Data[0x2B] = value; }
public override int PKRS_Days { get => PKRS & 0xF; set => PKRS = (byte)(PKRS & ~0xF | value); }
public override int PKRS_Strain { get => PKRS >> 4; set => PKRS = (byte)(PKRS & 0xF | value << 4); }

View file

@ -172,6 +172,9 @@ namespace PKHeX.Core
return false;
}
if (pk.Data[0x2A] > 20) // ResortEventStatus is always < 20
return false;
return preferredFormat > 6;
}