Ejemplo n.º 1
0
import json
import command
import printer
import sys		#For loading command-line parameters

# Load the game data:
for inFile in ["rooms","menus","player","npc"]:
    json_data = open("{}.json".format(inFile))
    vars()[inFile] = json.load(json_data)

#Check for an automation script:
debug = []
if len(sys.argv) > 1:
	print "DEBUG MODE"
	debug = [line.rstrip('\n') for line in open(sys.argv[1])]

print "\n\nBishop's Map v0.1.0\n\n"

first_scene="lobby"
next_move = rooms[first_scene]
last_move = rooms[first_scene]
printer.scene(next_move,rooms,player,menus,npc,last_move)
next_move = command.get(next_move,rooms,menus,player,npc,debug)

while True:
    printer.scene(next_move,rooms,player,menus,npc,last_move)
    last_move = next_move
    next_move = command.get(next_move,rooms,menus,player,npc,debug)
Ejemplo n.º 2
0
                        db.update(user['tweet_id'], user['id'], 'last_tweet_id')
                    reply = True
                else:
                    db.log(rec, 'old tweet')

            # if this mention should be replied to, do so # might want to add double check to make sure tweet sent
            if reply == True:
                db.log(rec, 'tweet: ' + tweet)
                # loop through requests to users table
                user_data = ['position', 'inventory', 'events']
                for r in user_data:
                    user[r] = db.select(r, 'users', 'id', user['id']) if r == 'position' else json.loads(db.select(r, 'users', 'id', user['id'])) # can json.loads get moved into db.select function?
                    db.log(rec, r + ': ' + str(user[r]))
                # handles commands (drop/give/inventory)
                db.log(rec, 'Checking for command...')
                cmdreply, cmd = command.get(tweet, user['inventory'], user['id'], user['position'])
                if not cmdreply:
                    # get data for db response
                    db.log(rec, 'move: ' + move)
                    # get current event (requires items from user_data)
                    user['current_event'] = event.getcurrent(move, user['position'], user['inventory'], user['events'])
                    if user['current_event'] != None:
                        db.log(rec, 'current event: ' + str(user['current_event']))
                    # loop through requests to moves table (requires current_event)
                    move_data = ['response', 'item', 'drop', 'trigger', 'travel']
                    for r in move_data:
                        user[r] = db.select(r, 'moves', 'move', move, user['position'], user['current_event'])
                        if user[r] != None:
                            db.log(rec, r + ': ' + str(user[r]))
                    # add trigger to events if it exists for this move
                    if user['trigger'] != None: