Commit Graph

272 Commits

Author SHA1 Message Date
Freezed 2f9a4b8aaa Reorganise repo 2019-09-06 15:46:11 +02:00
Freezed 2b3b0f93ad Update README 2019-09-06 15:45:43 +02:00
Fred Z dfeff7a50c Replaces doctests test by pytest tests 2018-08-14 23:58:02 +02:00
Fred Z 85eb74ba5f Adds some code to play with pytest 2018-08-14 23:57:34 +02:00
Fred Z 2818543f83 Tests simple implementation of PyMySQLb 2018-08-04 08:16:20 +02:00
Fred Z d7fd69619f Tests kwargs in a function 2018-08-04 08:13:36 +02:00
Fred Z 5db5dcaae4 Update README.md 2018-03-15 10:36:50 +01:00
Fred Z 7c4d429613
Updade roadmap & pause announce 2018-03-14 10:52:56 +01:00
Fred Z 30de5f8096 Starts modif gameplay to multiplayer/network mode
I am pausing the devel here, I have to prioritise another project.
Doctests seems to be obsolete for testing network scripts.
I'll be back with Pytest!
2018-03-14 10:40:44 +01:00
Fred Z 579bf24c17 Updates maps for multiplayer (remove robot letter) 2018-03-14 10:40:44 +01:00
Fred Z 367750b9c4 Adds `data_filter()` to sanitize username 2018-03-14 10:40:19 +01:00
Fred Z 851b618ff7 Pylint check and clean 2018-03-14 10:40:19 +01:00
Fred Z a14ef683cb Export template's message from `server_log()`
In order to use this method in the whole class.
Update `__init__()` & `close()` to use `server_log()`. NO MORE `print()`
in this class ;-)
2018-03-14 10:40:19 +01:00
Fred Z 703380ded6 Refactors `listen()` about log, broadcast & send
Adds `server_log()` method in order to export the `print()` calls.
Centralize _log_, _broadcast_ & _send_ operations in the bottom of the
loop  (except when sockets needs to be close).
I think it is improves readability and will facilitate code evolution,
for example when writing the servers log in file(s).
2018-03-14 10:40:19 +01:00
Fred Z f90a1a38d5 Refuses client connection beyond a certain number
FIX TODO19: add max player number
2018-03-14 10:40:19 +01:00
Fred Z 44514971ef Ajusts messages to clients in waiing-room 2018-03-14 10:40:19 +01:00
Fred Z 7708781e29 Checks player name in `listen()`
Adds length limit
Fix TODO17: verify if user name is already used
2018-03-14 10:40:19 +01:00
Fred Z c075c17172 Improves `broadcast()`: linked to `list_sockets()`
Now sends messages only to named-client, and for that uses
`list_sockets()`

Takes sender name from `_user_name` attribute and delete the name
argument from the method
2018-03-14 10:40:19 +01:00
Fred Z 1c5366beb5 Refactors `count_clients()` & `list_sockets()`
`list_sockets()` uses only clients with a name already typed in
(filled in `_user_name` attribute), to avoid starting a game with not
named player

`count_clients()` was too messy and autonomous, now it uses
`list_sockets()` for counting only named players and not depend on
naming player mechanism or main socket.# Veuillez saisir le message de
validation pour vos modifications. Les lignes
2018-03-14 10:40:18 +01:00
Fred Z dfaee27cc4 Fixes 2 syntax errors caused by fatigue
Forget to:
- rename the import instruction after renaming the file
- instance the map object after exporting it from the function
2018-03-14 10:40:18 +01:00
Fred Z 7633dd0f1f Update TODO: add max player number TODO19 2018-03-14 10:40:18 +01:00
Fred Z 1446a49df6 Update README.md 2018-03-14 10:40:18 +01:00
Fred Z 2df0513d89 Rename Map instance according GAME_NETWORK style 2018-03-14 10:40:18 +01:00
Fred Z c7096ee757 Export Map instanciation in parent script
More readable and easier for adding multiplayer feature in the Map object
2018-03-14 10:40:18 +01:00
Fred Z 99ed30197c list_sockets(): return name in place of peername
Previous instructions do not work as expected, and finally I just need
user name to identify the clients connected, not connection parameters
2018-03-14 10:40:18 +01:00
Fred Z a501fd69bb Add the waiting-room-loop before game begining 2018-03-14 10:40:18 +01:00
Fred Z 5047c993a8 listen(): Use attribute, no more tuple return 2018-03-14 10:40:18 +01:00
Fred Z 7722ae368e broadcast(): Export string in a constant 2018-03-14 10:40:18 +01:00
Fred Z 2f024b5d0a count_client(): use client with a filled username 2018-03-14 10:40:18 +01:00
Fred Z ddf9d57d38 Syntax update in TODO 2018-03-14 10:40:18 +01:00
Fred Z b659d0ff7f Using the network to wait & connect client
Crash when MIN_CLIENT_NB is reached
2018-03-14 10:40:18 +01:00
Fred Z 1451c5ff36 Clean up and document __init__ method 2018-03-14 10:40:18 +01:00
Fred Z 91c5bdb761 Clean up the code a little bit 2018-03-14 10:40:18 +01:00
Fred Z ffe3023b4d Adding methods: listen connection & brobdcast msg 2018-03-14 10:40:18 +01:00
Fred Z 7b9128c3b2 Update TODO
- verify if user name is already used TODO17
- ordering a bit
2018-03-14 10:40:18 +01:00
Fred Z a0598d3599 Create client
DONE TODO03
2018-03-14 10:40:18 +01:00
Fred Z 03cbd5474d Add network/connection Class
Create a socket object for opening the server connection with some mehods:
-__init__()
- close()
- list_sockets()
- count_clients()
2018-03-14 10:40:18 +01:00
Fred Z 315e7f9537 Create server, and remove backup feature
DONE TODO01
DONE TODO02
2018-03-14 10:40:17 +01:00
Fred Z f903089686 Roadmap to next exercice: multiplayer & network 2018-03-14 10:40:17 +01:00
Fred Z 7b6953a948 Corrige la syntaxe: audit pyLint 2018-03-14 10:40:17 +01:00
Fred Z 0779b0b5c7 Transforme des TODO en issue 2018-03-14 10:40:17 +01:00
Fred Z 78be5f0877 Clean closing socket with <ctrl+c> 2018-03-05 23:14:40 +01:00
Fred Z 9106fdd490 Ajoute un script d'évaluation de plusieurs syntaxes 2018-03-05 23:14:40 +01:00
Fred Z d9dc6ce96a Edit TODO server crash if a client is killed
Traceback (most recent call last):
  File "server.py", line 78, in <module>
    peername = socket.getpeername()
OSError: [Errno 107] Transport endpoint is not connected
2018-03-05 23:12:50 +01:00
Fred Z 5df5f1ec75 Edit TODO : 3 enhancements & 1 bug
- convert logic to oreiented object
- server crash witn opened connection with <ctrl+Z>
- add some commands: help, list user, disconnect user, etc
- add time logging:
    - a timestamp in log's server
    - brodcast time to client at regular intervals
2018-03-05 23:12:50 +01:00
Fred Z 0074e57612 Improve UX with better prompt & message display
- UPDATE: last condition for messages passing the commands case and
the string.stripping()
 - FIX: clean the prompt and std.out a bit messy since broadcasting
2018-03-05 23:12:50 +01:00
Fred Z e43f19c2ae Revise messages: server's log & broadcasted 2018-03-05 23:12:50 +01:00
Fred Z 870953051d Ask for username and use it
First client's message is used as usernane in server loging and other
clients broadcasting
2018-03-05 23:12:50 +01:00
Fred Z 3c5c169045 Clean the main-loop from useless instructions
Remove:
 - try/catch for received case, seems to be useless
 - useless `continue`
 - **move closing connection at the script's end** from TODO, do not find how to exit while from handler()
2018-03-05 23:12:50 +01:00
Fred Z 86b0b983f7 Add a template message in broadcasting
Move the template outside the for-loop to avoid overide
Separate client and server client-disconnect-message
2018-03-05 23:12:50 +01:00