Skip to content

Commit

Permalink
Add cool names
Browse files Browse the repository at this point in the history
  • Loading branch information
HubertJan committed Jul 17, 2024
1 parent 763a257 commit edc1032
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions services/game_server/backend/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from .player import Player
from backend.constants import STATE_UPDATE_INTERVAL, BROADCAST_INTERVAL, DATA_DIR


class Game:
def __init__(self, server) -> None:
self.server = server
Expand Down Expand Up @@ -123,7 +122,7 @@ async def update_players(self) -> None:

async def broadcast_leaderboard(self) -> None:
connections = list(self.socket_connections.items())
leaderboard = {player_id: player.kills for player_id, player in connections}
leaderboard = {player.name: player.kills for player_id, player in connections}
sorted_leaderboard = sorted(leaderboard.items(), key=lambda item: item[1], reverse=True)
for player_id, player in connections:
await self.server.app.sio.emit("current_leaderboard", {
Expand Down
3 changes: 2 additions & 1 deletion services/game_server/backend/game/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import random
import math
from backend.constants import X_MAX, Y_MAX
import names

class Player (Entity):
def __init__(self, game, pos: Pos, sid, hp: int = 100) -> None:
super().__init__(pos)
self.game = game
self.hp = hp
self.name = "Player #" + str(random.randint(0, 1000))
self.name = names.get_full_name()
self.kills = 0
self.last_respawned_at = datetime.datetime.now()
self.equipped_weapon = "Pistol"
Expand Down
Binary file modified services/game_server/backend/requirements.txt
Binary file not shown.

0 comments on commit edc1032

Please sign in to comment.