Skip to content

Add multiplayer#15

Open
varfigstar wants to merge 1 commit into
UpGado:masterfrom
varfigstar:MULTIPLAYER
Open

Add multiplayer#15
varfigstar wants to merge 1 commit into
UpGado:masterfrom
varfigstar:MULTIPLAYER

Conversation

@varfigstar
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@zotho zotho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight changes

Comment thread asciiracer/hud.py
Comment on lines +33 to +36
"""
Only available in multiplayer.
:return:
"""
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""
Only available in multiplayer.
:return:
"""
"""Draw score table.
Only available in multiplayer.
"""

daemon=True
).start()
while not self.client_running:
...
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
...
pass

Comment on lines +36 to +39
if event["event_type"] == Events.update_score.value:
self.score_table = event["value"]

elif event["event_type"] == Events.id_message.value:
Copy link
Copy Markdown

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:

Suggested change
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))
Copy link
Copy Markdown

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

Suggested change
self.logger.info("open connection with host: {}".format(ws.url))
self.logger.info("open connection with host: %s", ws.url)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other places too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants