Find the replicants, get the reward, do not die.
This is a really simple console game written in python, as defined in Learn Python the Hard Way exercise 45.
- Python 2.7.3+
Download the latest release
at GitHub, extract and execute the play.py
script:
mkdir /tmp/games
cd /tmp/games
wget http://github.com/brunitto/python-runner/archive/stable.zip
unzip stable.zip
cd python-runner-stable
python play.py
The game will describe a stage and wait for a valid command. The valid commands are:
desc
: describe the stagelook
: look aroundtalk:
talk to someonejoke
: drop an epic jokefight
: start a fight
Within battles:
attack
: attack with the shotgunroll
: avoid the enemy attack
If you fell lost, the help
command will help you. If you want to quit, use
the quit
command.
- Replicants does not like jokes
- Replicants are aggressive
- If you fell lost, use the
help
command
This game uses the Finite-state Machine model to define the stages and the
transitions between these stages (or states). The game map is defined as a
dict within Engine
class within lib/engine.py
module. New stages can be
created by adding more transitions to this dict and creating new stage
classes, extending the Stage
base class within the lib/stage.py
module.
This game use Python object-oriented features like inheritance and composition.
Each stage inherits functions from the Stage
base class, which import
functions from the Console
class within lib/console.py
module.