Hi all,
I recently found myself writing lots of text-based game-type stuff, some of it MUD-like, and some intended to be played with a custom client. Either way, I found myself re-using a lot of the same code, so I made me a package!
The package is creatively called gsb (Game Server Base), and it's reminiscent of Flask or Klein.
There's a more complete example in the repo's examples folder, but here's a basic idea:
from gsb import Server # like flask.Flask.
s = Server() # This holds commands ETC.
@s.command('^quit$')
def do_quit(caller):
"""Disconnect from the game."""
s.disconnect(caller.connection)
s.run()
This will run a very minimalist game on port 4000.
Clearly it's not very interesting having only one command, but you can create as many as you like, making yourself a fully-functioning MUD-type server, or (I used it for) an RTS-type thingy. I was using Telnet to test, so I thought I may as well make it MUD like.
Anyways, there's full documentation (for once). If anyone's got any suggestions or whatever, please let me know either by email or Github or something.
Visit the repo.
To install with pip do:
pip install git+https://github.com/chrisnorman7/game-server-base
Happy hacking.
I have code on GitHub