snek
snek copied to clipboard
Add ability to send game events to server via chat
If the server gets in a weird state, would be nice to be able to run like a gameReset event on it from the client. Kind of like an admin feature without needing to build it explicitly.
We can use a chat format like server blahCommand
to do that.
Possible commands / actions
- Restart level
- Purge all players
- Blow up all players
- Kick player by name
- Kick "undefined" players
- (phantom players are often named UNDEFINED, so could just kick all players without names)
- Change player name (if offensive)
But - mostly just geared towards recoving from weird states like phantom players without needing to restart server.
Okay, I've added this and it works like so...
in chat, type admin resetGame
to fire game.resetGame on the server. We just need to add support for all the other things we want to do at this point. Any chat prefixed with admin
will send a adminCommand
event, which is listened for by server.js
, there we can put in whatever conditions / logic we want.
Now we've got
- admin resetGame - resets the game and respawns snakes
- admin cleanupGame - kills all snakes that don't have an associated player
do we want that on lockdown though? (IP, password, etc?)
Yeah, probably - we can set a secret phrase or number or something that needs to be a part of the command. We can hide it in an env variable maybe? Let's not worry until we go primetime though.
yeah, an env var is easy to read into the server-side code (client never needs to get it, human user just needs to know it) and easy to set on heroku