Пример #1
0
    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))
Пример #2
0
    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()