mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Switch item banlist to allowed list
Precompute bool[] to quickly access the allowed status instead of looping for contains.
This commit is contained in:
parent
062e571b3f
commit
f68a3b4b7d
8 changed files with 52 additions and 12 deletions
|
@ -72,8 +72,7 @@ namespace PKHeX.Core
|
|||
|
||||
private void verifyItem()
|
||||
{
|
||||
var unreleasedItems = Legal.getUnreleasedItems(pkm.Format);
|
||||
if (unreleasedItems.Contains(pkm.HeldItem))
|
||||
if (!Legal.getHeldItemAllowed(pkm.Format, pkm.HeldItem))
|
||||
AddLine(Severity.Invalid, "Held item is unreleased.", CheckIdentifier.Form);
|
||||
}
|
||||
|
||||
|
|
|
@ -656,6 +656,30 @@ namespace PKHeX.Core
|
|||
}
|
||||
}
|
||||
|
||||
internal static bool[] getReleasedHeldItems(int generation)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
case 2: return ReleasedHeldItems_2;
|
||||
case 3: return ReleasedHeldItems_3;
|
||||
case 4: return ReleasedHeldItems_4;
|
||||
case 5: return ReleasedHeldItems_5;
|
||||
case 6: return ReleasedHeldItems_6;
|
||||
case 7: return ReleasedHeldItems_7;
|
||||
default: return new bool[0];
|
||||
}
|
||||
}
|
||||
internal static bool getHeldItemAllowed(int generation, int item)
|
||||
{
|
||||
if (item < 0)
|
||||
return false;
|
||||
if (item == 0)
|
||||
return true;
|
||||
|
||||
var items = getReleasedHeldItems(generation);
|
||||
return items.Length > item && items[item];
|
||||
}
|
||||
|
||||
internal static bool getDexNavValid(PKM pkm)
|
||||
{
|
||||
if (!pkm.AO || !pkm.InhabitedGeneration(6))
|
||||
|
@ -1493,14 +1517,5 @@ namespace PKHeX.Core
|
|||
// No tutors in G7
|
||||
return moves.Distinct();
|
||||
}
|
||||
|
||||
public static int[] getUnreleasedItems(int generation)
|
||||
{
|
||||
switch (generation)
|
||||
{
|
||||
case 7: return UnreleasedItems_7;
|
||||
default: return new int[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,5 +59,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly int[] UnreleasedItems_2 =
|
||||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly bool[] ReleasedHeldItems_2 = Enumerable.Range(1, MaxItemID_2).Select(i => HeldItems_GSC.Contains((ushort)i) && !UnreleasedItems_2.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,5 +94,10 @@ namespace PKHeX.Core
|
|||
};
|
||||
// Ambipom Weavile Magnezone Lickilicky Tangrowth
|
||||
// Yanmega Leafeon Glaceon Mamoswine Gliscor Probopass
|
||||
internal static readonly int[] UnreleasedItems_3 =
|
||||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly bool[] ReleasedHeldItems_3 = Enumerable.Range(1, MaxItemID_3).Select(i => HeldItems_RS.Contains((ushort)i) && !UnreleasedItems_3.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,5 +135,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
700
|
||||
};
|
||||
internal static readonly int[] UnreleasedItems_4 =
|
||||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly bool[] ReleasedHeldItems_4 = Enumerable.Range(1, MaxItemID_4_HGSS).Select(i => HeldItems_HGSS.Contains((ushort)i) && !UnreleasedItems_4.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,5 +94,10 @@ namespace PKHeX.Core
|
|||
{
|
||||
700
|
||||
};
|
||||
internal static readonly int[] UnreleasedItems_5 =
|
||||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly bool[] ReleasedHeldItems_5 = Enumerable.Range(1, MaxItemID_5_B2W2).Select(i => HeldItems_BW.Contains((ushort)i) && !UnreleasedItems_5.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -762,5 +762,10 @@ namespace PKHeX.Core
|
|||
05, 10, 05, 05, 15, 10, 05, 05, 05, 10, 10, 10, 10, 20, 25, 10, 20, 30, 25, 20, 20, 15, 20, 15, 20, 20, 10, 10, 10, 10, 10, 20, 10, 30, 15, 10, 10, 10, 20, 20, 05, 05, 05, 20, 10, 10, 20, 15, 20, 20,
|
||||
10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05, 05,
|
||||
};
|
||||
internal static readonly int[] UnreleasedItems_6 =
|
||||
{
|
||||
// todo
|
||||
};
|
||||
internal static readonly bool[] ReleasedHeldItems_6 = Enumerable.Range(0, MaxItemID_6_AO).Select(i => HeldItem_AO.Contains((ushort)i) && !UnreleasedItems_6.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1252,7 +1252,7 @@ namespace PKHeX.Core
|
|||
#endregion
|
||||
|
||||
#region Unreleased Items
|
||||
internal static readonly int[] UnreleasedItems_7 =
|
||||
internal static readonly int[] UnreleasedHeldItems_7 =
|
||||
{
|
||||
016, // Cherish Ball
|
||||
064, // Fluffy Tail
|
||||
|
@ -1342,5 +1342,6 @@ namespace PKHeX.Core
|
|||
836, // Pikashunium Z
|
||||
};
|
||||
#endregion
|
||||
internal static readonly bool[] ReleasedHeldItems_7 = Enumerable.Range(1, MaxItemID_7).Select(i => HeldItems_SM.Contains((ushort)i) && !UnreleasedHeldItems_7.Contains(i)).ToArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue