RanvierMUD / ranviermud

A node.js based MUD game engine
https://ranviermud.com
MIT License
798 stars 247 forks source link

Have a way to pause/exit and resume the command loop while in game #261

Open marcelomoreli opened 7 years ago

marcelomoreli commented 7 years ago

Having a way to pause/exit the command loop would have utility on some situations, like:

1 - logout command - Send the player back to character selection screen 2 - write command - Write big messages (multi-line) into boards, mail, player description, etc 3 - ability to create OLC or compound commands (where you would have to input more than one line of command)

marcelomoreli commented 7 years ago

As per Shawn's suggestion: For the logout/quit command, have now with state.PlayerManager.removePlayer(player) and player.socket.emit('choose-character', player.socket, { account: player.account });. Create a new Error class (essentially copy/paste the RestrictedCommandError and rename it something like EndCommandLoopError. At the end of your command when you're all done throw that error. Update the commands.js file to specifically catch that error just like it catches RestrictedCommandError but instead of doing break; do return; that will prevent the command event from looping then when you want to resume the command input event you can do it manually with player.socket.emit('commands', player);