示例#1
0
import json
import textwrap

from advengine.adventure import Adventure


if __name__ == '__main__':
    with open('./games/starflight.json', 'rb') as gfile:
        jstr = gfile.read()
        data = json.loads(jstr)
        adv = Adventure(data)

        messages = adv.start_game()

    while True:
        for message in messages:
            if message == 'PAUSE':
                raw_input('Press any key...')
                print
            else:
                for line in message.splitlines():
                    for wrapline in textwrap.wrap(line):
                        print wrapline
                print

        messages = adv.do_command(raw_input('> '))
示例#2
0
 def __init__(self, controls):
     Adventure.__init__(self, {'rooms': {'start': {'start': True}},
                               'vars': {'one': 1, 'two': 2},
                               'controls': controls},
                        BaseTests, MockActions)