def check_sked(self, player, world): maprefs = world.mapref() with open("sked.txt", "r") as f: master = f.read() f.close() when, where, who = master.split() who = who.split(",") hour = int(when[0:2]) minute= int(when[2:4]) t = datetime.datetime(2015, 6, 1, hour, minute, 0) skedtime = t.time() playertime = player.time.time() phour, pminute = playertime.hour, playertime.minute maprefs = world.mapref() for w in who: if w in self.shortnames: if phour == hour: x, y = maprefs[where] self.dest = True self.dest_x, self.dest_y = x, y else: #check if we need to go home home_x, home_y = maprefs[self.home] if (home_x, home_y) != (self.x, self.y): #go home self.dest = True self.dest_x = home_x self.dest_y = home_y
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
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()