snek icon indicating copy to clipboard operation
snek copied to clipboard

Add ability to send game events to server via chat

Open flukeout opened this issue 8 years ago • 5 comments

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.

flukeout avatar Sep 24 '16 19:09 flukeout

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.

flukeout avatar Sep 24 '16 20:09 flukeout

Now we've got

  • admin resetGame - resets the game and respawns snakes
  • admin cleanupGame - kills all snakes that don't have an associated player

flukeout avatar Sep 24 '16 23:09 flukeout

do we want that on lockdown though? (IP, password, etc?)

Pomax avatar Sep 25 '16 23:09 Pomax

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.

flukeout avatar Sep 26 '16 16:09 flukeout

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

Pomax avatar Sep 26 '16 16:09 Pomax