Skip to content

Commit

Permalink
fix: properly fix missing item 255
Browse files Browse the repository at this point in the history
  • Loading branch information
Arley Pádua authored and Arley Pádua committed Dec 5, 2024
1 parent bd9dd54 commit 887a865
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/PKHeX.Facade/Repositories/ItemRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ public ItemRepository(SaveFile saveFile)
_gameItems = GameInfo.Strings.GetItemStrings(saveFile.Context, saveFile.Version)
.Select((itemName, id) => (id: Convert.ToUInt16(id), itemName))
.ToDictionary(x => Convert.ToUInt16(x.id), x => new ItemDefinition(Convert.ToUInt16(x.id), x.itemName));

if (saveFile.Version == GameVersion.C)
{
// for whatever reason, Pokemon Crystal has this last item
_gameItems[255] = new ItemDefinition(255, "Collapsible bike");
}
}

public ISet<ItemDefinition> GameItems => _gameItems.Values.ToHashSet();
public ItemDefinition GetGameItem(ushort id) => _gameItems.GetValueOrDefault(id)
// for whatever reason, some items are not in the game's item list
// and that ends up failing
// falling back to the all items list (is this even correct?)
?? GetItem(id);
public ItemDefinition GetGameItem(ushort id) => _gameItems[id];
public ItemDefinition? GetGameItemByName(string name) => _gameItems.Values
.FirstOrDefault(i => i.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));

Expand Down

0 comments on commit 887a865

Please sign in to comment.