Skip to content

Commit

Permalink
A game should not allow 2 players with the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
Solirs committed Jul 3, 2023
1 parent a5c8fa6 commit 7f0ed82
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions freefang/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def game_creation_loop(args):
net.send_packet(utils.obj_to_json(packets.Action_failure(error="game_not_found")), i)
else:
game = games[packet.headers.gameid]

if packet.headers.name in [s.name for s in game.players]:
net.send_failure(i, "name_already_taken")
continue

p = models.Player()
p.name = packet.headers.name
Expand Down

0 comments on commit 7f0ed82

Please sign in to comment.