def choicePhase(self, enemy): from Game.CommandFactory import CommandFactory cf = CommandFactory() if (cf.needsInput()): self.player.analyze() self.enemy.analyze() self.player.selectAction(enemy) action = cf.getNextCommand() out = action.execute() sorted(self.player.eventQueue, key=attrgetter('priority')) return out
read = texty.readOneKeyFromPlayer() if read == "y": cf.load() flagLoadedMidfight = True if not flagLoadedMidfight: texty.showPlayer("Do you want to load a game?") read = texty.readOneKeyFromPlayer() if read == "y": texty.showPlayer("Please write the name of the player") read = texty.readOneKeyFromPlayer() playerchar = savvy.loadPickle(read) else: playerchar = cf.create("newPlayer", ["Player", "Warrior"]) playerchar = cf.getNextCommand().execute() while playGame: if cf.needsInput(): enemy = analysisPhase(playerchar) combat = cf.create("fight", [playerchar, enemy]) wonCombat, playerchar = cf.getNextCommand().execute() if not wonCombat: texty.showPlayer("You lose! Play again?") playerchar = Player.Player("Player", "test") else: texty.showPlayer("You win! Save and quit?") read = texty.readOneKeyFromConsole() if read == "y":