Skip to content

Commit

Permalink
fix: add missing getAllCharacters function
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Apr 1, 2022
1 parent ab2b1b1 commit 7a92330
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/melee/characterUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ export const UnknownCharacter: CharacterInfo = {

type CharacterId = keyof typeof characters;

export function getAllCharacters(): CharacterInfo[] {
return Object.entries(characters)
.map(([id, info]) => ({
id: parseInt(id, 10),
name: info.name,
shortName: info.shortName,
colors: info.colors,
}))
.sort((a, b) => a.id - b.id);
}

export function getCharacterInfo(externalCharacterId: number): CharacterInfo {
const charInfo = characters[externalCharacterId as unknown as CharacterId];
if (charInfo) {
Expand Down

0 comments on commit 7a92330

Please sign in to comment.