-
Notifications
You must be signed in to change notification settings - Fork 63
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
Refactor game service #743
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.
Reviewed 13 of 19 files at r1.
Reviewable status: 13 of 19 files reviewed, 3 unresolved discussions (waiting on @NiallEgan)
aimmo-game/service.py, line 65 at r1 (raw file):
return world_update_on_connect def make_disconnect_fun(self):
what's this name? :)
aimmo-game/service.py, line 97 at r1 (raw file):
def _send_logs(self): def should_send_logs(logs):
any particular reason for using an inner function here?
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
self.avatar = AvatarState(location=avatar['location'], score=avatar['score'], health=avatar['health'])
if some of the defaults are mutable make sure it does what you expect
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.
Reviewable status: 13 of 19 files reviewed, 3 unresolved discussions (waiting on @NiallEgan)
aimmo-game/service.py, line 65 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
what's this name? :)
I think that it does in some way describe the method, although I guess it doesn't describe the inner method. Do you think that make_remove_session_id_from_mappings
would be better?
aimmo-game/service.py, line 97 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
any particular reason for using an inner function here?
This was at the recommendation of Niket in the last PR I made: we agreed that abstracting the branch condition into a function made for clearer reading, and as it is only used in this method I think an inner function makes sense.
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
if some of the defaults are mutable make sure it does what you expect
I don't think these are defaults, but rather just normal keyword args.
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.
Reviewed 6 of 19 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @CelineBoudier)
aimmo-game/service.py, line 65 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I think that it does in some way describe the method, although I guess it doesn't describe the inner method. Do you think that
make_remove_session_id_from_mappings
would be better?
i just don't think the current name makes sense as the way i read it it's making disconnect fun, fun, fun lol. Anyway it's a function so no need for fun in the name
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I don't think these are defaults, but rather just normal keyword args.
no I mean the defaults of the parameters: for instance if avatar['location'] is mutable (I haven't checked sorry)
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.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @NiallEgan)
aimmo-game/service.py, line 65 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
i just don't think the current name makes sense as the way i read it it's making disconnect fun, fun, fun lol. Anyway it's a function so no need for fun in the name
Oh well the reason that fun is in the name because it returns a function; it literally makes the function for disconnect. But I will change the name.
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
no I mean the defaults of the parameters: for instance if avatar['location'] is mutable (I haven't checked sorry)
I'm not sure what you mean by defaults, I don't think there are any? Anyway all of the parameter values are immutable.
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.
Reviewable status: 17 of 19 files reviewed, 1 unresolved discussion (waiting on @CelineBoudier)
aimmo-game/service.py, line 65 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
Oh well the reason that fun is in the name because it returns a function; it literally makes the function for disconnect. But I will change the name.
Done.
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.
Reviewable status: 17 of 19 files reviewed, 1 unresolved discussion (waiting on @CelineBoudier)
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
I'm not sure what you mean by defaults, I don't think there are any? Anyway all of the parameter values are immutable.
ok :) I mean that here avatar['location'] is the default value of the parameter location
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.
Reviewable status: 17 of 19 files reviewed, all discussions resolved (waiting on @CelineBoudier)
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, CelineBoudier (Celine Boudier) wrote…
ok :) I mean that here avatar['location'] is the default value of the parameter location
Maybe I'm misunderstanding something, but I don't think so? Default parameters are defined in the method definition, this is just a standard keyword argument that is passed in normally?
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.
Reviewable status: 17 of 19 files reviewed, all discussions resolved (waiting on @CelineBoudier)
aimmo-game-worker/simulation/world_map.py, line 16 at r1 (raw file):
Previously, NiallEgan (Niall Egan) wrote…
Maybe I'm misunderstanding something, but I don't think so? Default parameters are defined in the method definition, this is just a standard keyword argument that is passed in normally?
ah yeah no i hadn't read things properly my bad
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.
Reviewed 3 of 3 files at r2.
Reviewable status:complete! all files reviewed, all discussions resolved
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.
Reviewable status: 18 of 19 files reviewed, 1 unresolved discussion (waiting on @CelineBoudier and @NiallEgan)
aimmo-game/service.py, line 134 at r3 (raw file):
flask_app.add_url_rule('/player/<player_id>', 'player_data', game_api.make_player_data_view())
Why? Why not a route decorator?
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.
Reviewable status: 18 of 19 files reviewed, 1 unresolved discussion (waiting on @CelineBoudier and @NiallEgan)
aimmo-game/service.py, line 134 at r3 (raw file):
Previously, OlafSzmidt (Olaf Szmidt) wrote…
flask_app.add_url_rule('/player/<player_id>', 'player_data', game_api.make_player_data_view())
Why? Why not a route decorator?
Well I tried something like:
@app.route('/player/<player_id>')
def player_data_view(self, player_id):
...
The problem is that self
won't be passed in as an argument when the method is called (only player_id
will)
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.
Reviewable status: 16 of 19 files reviewed, 1 unresolved discussion (waiting on @CelineBoudier and @NiallEgan)
aimmo-game/service.py, line 135 at r4 (raw file):
logs = Logs()
Remove irrelevant spacing here pls
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.
Reviewed 1 of 1 files at r3, 2 of 2 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @NiallEgan)
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @OlafSzmidt)
aimmo-game/service.py, line 135 at r4 (raw file):
Previously, OlafSzmidt (Olaf Szmidt) wrote…
Remove irrelevant spacing here pls
Done.
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.
Reviewed 14 of 19 files at r1, 1 of 3 files at r2, 3 of 3 files at r5.
Reviewable status:complete! all files reviewed, all discussions resolved
In order to prepare for #734, I have made the following changes:
service.py
to remove global state and default argumentsThese changes will make it easier to add and test a new socket event, as well as making the code generally clearer.
A disadvantage of this is that we can no longer use decorators to register the flask routes and events for socketio (we instead have to add them manually). While this is not quite as pretty, I think it is a necessary trade off as we add more functionality toservice.py
.This change is![Reviewable](https://camo.githubusercontent.com/23b05f5fb48215c989e92cc44cf6512512d083132bd3daf689867c8d9d386888/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)