def setScenario(self, s): if self.scenario is None or str(self.scenario) != s: self.scenario = getRoom(s) print self.scenario #after loading a new room, tell the parser to look at the room self.parser.addLetter("look") self.parser.execute() return True return False
def alter(self): engine = Engine.getInstance() # the engine of the game player = engine.getPlayer() # the player # load these up now so there isn't a recursion error earlier on from Item import loadItem from Scenario import getRoom # go through the list of items to remove from the player for item in self.alterPlayer[0]: player.removeItem(loadItem(item)) # go through the list of items to add to the player for item in self.alterPlayer[1]: player.addItem(loadItem(item)) # go through the list of rooms to be altered for room in self.alterRooms.keys(): if room is not None: scene = getRoom(room) else: scene = engine.getScenario() # remove things from the rooms for n in self.alterRooms[room][0][0]: scene.objects.remove(loadItem(n)) for n in self.alterRooms[room][1][0]: scene.commands.remove(loadCommand(n)) for n in self.alterRooms[room][2][0]: scene.paths.remove(getRoom(n)) # add things to the rooms for n in self.alterRooms[room][0][1]: scene.objects.append(loadItem(n)) for n in self.alterRooms[room][1][1]: scene.commands.append(loadCommand(n)) for n in self.alterRooms[room][2][1]: scene.paths.append(getRoom(n)) print scene.objects print scene.commands print scene.paths