private String collectPlayerScoreInfo() { return playerRepository .findAll() .stream() .sorted((p1, p2) -> Integer.valueOf(p2.getScore()).compareTo(p1.getScore())) .map(player -> "Playername: " + player.getPlayerName() + " Score: " + player.getScore()) .collect(Collectors.joining(" | ")); }
private void updatePlayerScore(GameUpdate gameUpdate) { Player playerEntity = playerRepository.findOneByPlayerName(gameUpdate.getPlayerName()); playerEntity.setScore(playerEntity.getScore() + gameUpdate.getScoreDelta()); playerRepository.save(playerEntity); }