Mercurial > skaapsteker
view scripts/npc-test @ 195:445a28f4b38e
Fix npc tester.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 06 Apr 2011 22:04:19 +0200 |
parents | 704d23022f09 |
children | a4c4e2f34162 |
line wrap: on
line source
#!/usr/bin/env python "Skaapsteker npc tester" import os.path import sys import optparse from pprint import pprint sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) from skaapsteker.dialogue import DSM, DsmEvent, DummyWorld from skaapsteker.gamestate import GameState def run(npc_file): game = GameState("game.json") name = os.path.splitext(os.path.basename(npc_file))[0] dsm = DSM(name, game.world, npc_file) print "States:" print "-------" pprint(dsm.states.keys()) print while True: state = dsm.get_state() print "%s:" % dsm.state, state.text print "--" for i, choice in state.choices: print "%d: %s" % (i, choice) print "L: Leave" print "--" key = raw_input("Choice? ") key = key.strip().upper() if key == "L": break elif key.isdigit(): dsm.choice(int(key)) print "--" def main(): p = optparse.OptionParser(usage="%prog [options] <npc json state file>") opts, args = p.parse_args() if len(args) != 1: p.error("Must provide an npc json file") run(args[0]) if __name__ == '__main__': main()