Skip to content

Commit

Permalink
chore: fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-ribeiro committed Aug 1, 2024
1 parent 127181e commit 53be7a6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"tailwind-merge": "^2.4.0"
},
"devDependencies": {
"@types/node": "^22.0.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
Expand Down
26 changes: 21 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions src/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,13 @@ function getRoundById<T extends Game>(
return round;
}

function getPlayerById<T extends Game>(
game: T,
id: string,
): T["players"][number] {
const player = game.players.find((player) => player.id === id);
invariant(player, `Player with id ${id} not found.`);
return player;
}

export function getActiveRound<T extends Game>(game: T): T["rounds"][number] {
function getActiveRound<T extends Game>(game: T): T["rounds"][number] {
const round = game.rounds[game.activeRound];
invariant(round, `Round ${game.activeRound} not found.`);
return round;
}

export function getActivePlayer<T extends Game>(game: T): T["players"][number] {
function getActivePlayer<T extends Game>(game: T): T["players"][number] {
const round = getActiveRound(game);

const playerId = round.order[round.activePlayer];
Expand Down

0 comments on commit 53be7a6

Please sign in to comment.