lordmauve / adventurelib

A minimal library for writing text adventure games in Python 3
https://adventurelib.readthedocs.io/
MIT License
153 stars 42 forks source link

Brought code in line with PEP8, added (optional) Game World interface #8

Open ghost opened 6 years ago

ghost commented 6 years ago

The "Game World interface" is basically just a way to not keep facts about the world in the global scope, instead using an optional game argument to functions that (in theory) includes data about the player and world state and stuff. Also, say is now game.say, and different input/output interfaces can be used (terminal by default, but any object that inherits from adventurelib.Interface and defines obj.say(string) and obj.get_command(prompt) -> str can be used for input/output.

I also updated the demo to match, deleted unused imports, and fixed an apparent error with the fallback for getting terminal size (it was try-except-else, but that would mean that the fallback is used if shutil is present iirc; it should've been try-except(try-except)).

ghost commented 6 years ago

What's your opinion of changing Room.<direction> to Room.exits.<direction>?

lordmauve commented 6 years ago

Sorry for slow responses, @hppavilion1, I've been planning a wedding and haven't had time to go through Github PRs.