def manageCharacter(character: "Character"): options = ["Quit", character] screen = Screen() screen.setTitle(f'Manage {character.name}') if True: # needs to check it items available options.append("Equipped items") for item in character.equippedItems: screen.addBodyRow(str(item)) options.append(item) # todo: add option to change passives # todo: add option to change actives options.reverse() for option in options: screen.addOption(option) customize = screen.displayAndChoose("What do you want to customize?") if customize != "Quit": if customize == "Equipped items": raise Exception( "todo move item choosing to user instead of character") else: customize.customizeMenu()
def loginMenu(self): screen = Screen() screen.setTitle("Login") users = self.userLoader.getOptions() userName = None options = ["Create game"] if len(users) > 0: options.append("Load game") options.reverse() for option in options: screen.addOption(option) action = screen.displayAndChoose( "Do you wish to load a game or start a new one?") if action == "Load game": screen.clearOptions() users.append("None of these") for user in users: screen.addOption(user) userName = screen.displayAndChoose("Which user are you?") if userName == "None of these": self.newUserMenu() self.loginMenu() else: self.loginUser(userName) else: self.newUserMenu() #logs in if successful
def chooseAction(self): screen = Screen() options = [ "explore", "view character info", "customize character", "list passives", "list items", "exit" ] for option in options: screen.addOption(option) choice = screen.displayAndChoose("What do you wish to do?") if choice == "explore": chooseUserAreaAction(self.user, self.currentArea) elif choice == "view character info": screen = Screen() screen.setTitle(self.user.name) screen.addBodyRows(self.user.getDisplayData()) screen.display() elif choice == "customize character": self.user.manage() elif choice == "list passives": screen = Screen() for passive in getPassiveAbilityList(): screen.addBodyRow(passive.description) screen.display() elif choice == "list items": screen = Screen() for item in getItemList(): screen.addBodyRow(str(item)) screen.display() elif choice == "exit": self.exit = True else: raise Exception( "Unsupported choice in game.py Game.chooseAction: '{0}''". format(choice))
def mainMenu(self): screen = Screen() screen.setTitle("MAELSTROM") for option in ["Play", "About", "Quit"]: screen.addOption(option) action = screen.displayAndChoose("Choose an option: ") if action == "Play": self.loginMenu() elif action == "About": pass else: self.exit = True
def customizeMenu(self): done = False screen = Screen() screen.setTitle(f'Cusomizing {self.name}') while not done and self.customizationPoints > 0: screen.addBodyRows(self.getStatDisplayList()) exit = "Save changes and exit" options = [exit] canIncrease = [] canDecrease = [] for statName, stat in self.stats.items(): if not stat.is_max(): canIncrease.append(statName) if not stat.is_min(): canDecrease.append(statName) options.extend(canIncrease) # choose stat to increase first options.reverse() for option in options: screen.addOption(option) increaseMe = screen.displayAndChoose( "Which stat do you want to increase?") if increaseMe == exit: done = True else: screen.clearOptions() options = [exit] for statName in canDecrease: if statName != increaseMe: options.append(statName) options.reverse() for option in options: screen.addOption(option) decreaseMe = screen.displayAndChoose( "Which stat do you want to decrease?") if decreaseMe == exit: done = True else: self.setStatBase(increaseMe, self.stats[increaseMe].get_base() + 1) self.setStatBase(decreaseMe, self.stats[decreaseMe].get_base() - 1) self.calcStats() self.customizationPoints -= 1 screen.clearBody()
def newUserMenu(self): name = input("What do you want your character\'s name to be? ") screen = Screen() screen.setTitle("New User") screen.addBodyRow( "Each character has elemental powers, what element do you want yours to control?" ) for element in ELEMENTS: screen.addOption(element) element = screen.displayAndChoose("Choose an element: ") result = self.createUser(name, element) if result == 'User added successfully!': self.loginUser(name) else: self.newUserMenu()
def chooseUserAreaAction(user: "******", area: "Area"): screen = Screen() screen.setTitle(area.name) screen.addBodyRow(area.getDisplayData()) options = [] for level in area.levels: options.append(level) options.append("quit") for option in options: screen.addOption(option) choice = screen.displayAndChoose("Choose a level to play:") if choice is not "quit": playLevel(choice, user)
def manage(self): """ Displays the team management menu """ screen = Screen() screen.setTitle(f'Manage {self.name}') options = ["Exit"] for member in self.team.members: screen.addBodyRow(member.getDisplayData()) options.insert(0, member) for option in options: screen.addOption(option) managing = screen.displayAndChoose("Who do you wish to manage?") if managing is not "Exit": manageCharacter(managing)