fix around me for top players
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 40s
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 40s
This commit is contained in:
parent
670f2047a0
commit
7465f854e0
@ -257,7 +257,14 @@ export class PlayerService {
|
||||
// Show 3 players above and 1 below the requested player
|
||||
const playerPosition = players.findIndex(p => p.id === player.id);
|
||||
const start = Math.max(0, playerPosition - 3);
|
||||
const end = Math.min(players.length, playerPosition + 2);
|
||||
let end = Math.min(players.length, playerPosition + 2);
|
||||
|
||||
const playersLength = players.slice(start, end).length;
|
||||
|
||||
// If there is less than 5 players to return, add more players to the end
|
||||
if (playersLength < 5) {
|
||||
end = Math.min(end + 5 - playersLength, players.length);
|
||||
}
|
||||
|
||||
return players.slice(start, end);
|
||||
}
|
||||
|
Reference in New Issue
Block a user