-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multiplayer #15
base: master
Are you sure you want to change the base?
Add multiplayer #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight changes
""" | ||
Only available in multiplayer. | ||
:return: | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
""" | |
Only available in multiplayer. | |
:return: | |
""" | |
"""Draw score table. | |
Only available in multiplayer. | |
""" |
daemon=True | ||
).start() | ||
while not self.client_running: | ||
... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... | |
pass |
if event["event_type"] == Events.update_score.value: | ||
self.score_table = event["value"] | ||
|
||
elif event["event_type"] == Events.id_message.value: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enums can be checked for equality by is
:
if event["event_type"] == Events.update_score.value: | |
self.score_table = event["value"] | |
elif event["event_type"] == Events.id_message.value: | |
event_variant = Events(event["event_type"]) | |
if event_variant is Events.update_score: | |
self.score_table = event["value"] | |
elif event_variant is Events.id_message: |
self.id = event["value"] | ||
|
||
def on_open(self, ws: WebSocketApp): | ||
self.logger.info("open connection with host: {}".format(ws.url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging
library does formatting for us:
See: https://docs.python.org/3/howto/logging.html#logging-variable-data
self.logger.info("open connection with host: {}".format(ws.url)) | |
self.logger.info("open connection with host: %s", ws.url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places too
No description provided.