Fix : opti : use equals instead of toHexString comparisons
This commit is contained in:
+3
-7
@@ -16,9 +16,7 @@ export function shuffle(a) {
|
||||
}
|
||||
|
||||
export function getCurrentTeam(game: Document<Game> & Game) {
|
||||
return game.teams.find(
|
||||
(t) => t._id.toHexString() == game.currentTurn.currentTeam,
|
||||
);
|
||||
return game.teams.find((t) => t._id.equals(game.currentTurn.currentTeam));
|
||||
}
|
||||
|
||||
export function getPlayer(session: Record<string, any>, game: Game) {
|
||||
@@ -28,7 +26,7 @@ export function getPlayer(session: Record<string, any>, game: Game) {
|
||||
}
|
||||
for (const team of game.teams) {
|
||||
for (const player of team.players) {
|
||||
if (player.user._id.toHexString() == user._id) {
|
||||
if (player.user._id.equals(user._id)) {
|
||||
return player as Document<Player> & Player;
|
||||
}
|
||||
}
|
||||
@@ -40,9 +38,7 @@ export function getPlayer(session: Record<string, any>, game: Game) {
|
||||
}
|
||||
|
||||
export function isInTeam(team: Team, player: Player) {
|
||||
if (
|
||||
team.players.some((p) => p._id.toHexString() == player._id.toHexString())
|
||||
) {
|
||||
if (team.players.some((p) => p._id.equals(player._id))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user