Beispiel #1
0
def sched(commands, available_actions, player, room):
    print type(commands)
    mapref = world.mapref()
    for k in mapref:
        print k
    print mapref[commands[2]]
    if commands[2] not in mapref:
        print "\t{} is not the name of a room.".format(commands[2])
        return
    destx, desty = mapref[commands[2]]
    
    temp = world.allrooms()
    npclist =[]
    for x, y in temp:
        tmproom= world.tile_exists(x, y)
        if tmproom and tmproom.npcs:
            for npc in tmproom.npcs:
#                if npc.shortnames[0] == commands[1]:
                if commands[1] in npc.shortnames:
                    npc.dest = True
                    # npc.destx = mapref[commands[2][0]]
                    # npc.desty = mapref[commands[2][1]]
                    npc.destx = destx
                    npc.desty = desty
                    print "destination {}, {}".format(npc.destx, npc.desty)
                    return
Beispiel #2
0
def play():
    world.load_tiles()
    global player
    player = Player()
    global room
    room = world.tile_exists(player.location_x, player.location_y)
    mapref = world.mapref()
    for k in mapref:
        print k
        print mapref[k]
    print type(mapref)

    describe_room(room)

    while player.is_alive() and not player.victory:
        room = world.tile_exists(player.location_x, player.location_y)
        loc = [player.location_x, player.location_y]
#        room.modify_player(player)
        if player.is_alive() and not player.victory:
            global available_actions
            available_actions = room.available_actions()
        
            if player.moves > 0:
#                print "Running all rooms NPC default"
                room.default(player)
                temp = world.allrooms()
                npclist =[]
                for x, y in temp:
                    
                    tmproom= world.tile_exists(x, y)
                    if tmproom and tmproom.npcs:
                        for npc in tmproom.npcs:
                            if npc.name not in npclist: #we haven't called default on npc yet for this move
                                npc.default(player, world)
                                npclist.append(npc.name)
                                #print "called default on {}".format(npc.name)
        Prompt().cmdloop()