def runProgram(self): """ This method runs the command-based part of the game Receive commands from UI and execute them :return: nothing Catches any exceptions raised during the execution, mostly from UI """ UI.printMenu([]) while True: try: cmd, args = UI.getCommand() self.__cmdDict[cmd](args) except Exception as ex: UI.printException(ex)
def worldLoop(window): logger = Logger() # Add room, player, and npc to world level = Level() level.generateLevel() player = Player('TerminusSTC', 100, 100, 'Slytherin', logger) level.addEntityToRoom(player, 'great_hall', [12, 9]) h_student = NPC('student') level.addEntityToRoom(h_student, 'great_hall', [12, 12]) ui = UI(window, player, level, logger) cmd_parser = CmdParser(ui, player, level) while True: ui.render() cmd = ui.getCommand() cmd_parser.parseCmd(cmd)