Checks player name in listen()
Adds length limit Fix TODO17: verify if user name is already used
This commit is contained in:
parent
c075c17172
commit
7708781e29
|
@ -51,6 +51,9 @@ class ConnectSocket:
|
|||
_MSG_WELCOME = "Welcome. First do something usefull and type your name: "
|
||||
_SERVER_LOG = "{}:{}|{name}|{msg}"
|
||||
|
||||
# Others const
|
||||
_MAX_CLIENT_NAME_LEN = 8
|
||||
|
||||
def __init__(self, host=_HOST, port=_PORT):
|
||||
"""
|
||||
Set up the server connection using a socket object
|
||||
|
@ -198,7 +201,11 @@ class ConnectSocket:
|
|||
|
||||
if self._user_name[s_idx] is False: # setting username
|
||||
# insert username naming rule here
|
||||
# verify if name is already used TODO17
|
||||
data = data[0:self._MAX_CLIENT_NAME_LEN]
|
||||
# name is already used
|
||||
if data in self._user_name:
|
||||
data += str(s_idx)
|
||||
|
||||
self._user_name[s_idx] = data
|
||||
sckt.send(self._MSG_SALUTE.format(
|
||||
self._user_name[s_idx]).encode()
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
- [x] ~~remove the backup feature TODO01~~
|
||||
- [x] ~~conversion to client/server mode: server creation TODO02~~
|
||||
- [x] ~~conversion to client/server mode: client creation TODO03~~
|
||||
- [x] ~~verify if user name is already used TODO17~~
|
||||
- [ ] multiplayer turn-by-turn TODO04
|
||||
- [ ] each player has a differant robot TODO05
|
||||
- [ ] starting position has to be random TODO06
|
||||
|
@ -18,7 +19,6 @@
|
|||
- [ ] unit tests: game functions (client-side) TODO14
|
||||
- [ ] chat commands: listing players TODO15
|
||||
- [ ] chat commands: chating with other players TODO16
|
||||
- [ ] verify if user name is already used TODO17
|
||||
- [ ] rename ConnectSocket._user_name to ConnectSocket._user_name TODO18
|
||||
- [ ] add max player number TODO19
|
||||
- [ ] … TODO
|
||||
|
|
Loading…
Reference in New Issue
Block a user