def add_new_item(): print_skulls() filename = input("Give your file a name: ") player_data = player.save_character() with open("savedgames/" + filename + ".json", "w") as outfile: json.dump(player_data, outfile) outfile.close()
def request_username(): print_skulls() username = input("ENTER YOUR NAME, MORTAL: ") print_skulls() print(" WELCOME " + username.upper() + "!") player.set_name(username) return run_new_game_submenu()
def load_game(): print_skulls() directory = "/Users/dani/Desktop/GREENFOX/bodonyidani/week-6/2-project_version_2/project/savedgames" for file in os.listdir(directory): if file.endswith(".json"): print(file) print_skulls() infile = input("Enter the name of the file you'd like to load: ") with open("savedgames/" + infile + ".json", "r") as infile: playerdata = json.load(infile) player.name = playerdata["NAME"] player.dexterity = playerdata["DEXTERITY"] player.maxhealth = playerdata["STARTING (MAX) HEALTH"] player.currhealth = playerdata["CURRENT HEALTH"] player.maxluck = playerdata["STARTING (MAX) LUCK"] player.currluck = playerdata["LUCK"] player.inventory = playerdata["INVENTORY"] infile.close() if player.name == None: return request_username() elif player.currhealth == None: return run_new_game_submenu() elif len(player.inventory) < 3: return run_select_potion_submenu() else: return run_reselect_potion_submenu()
def print_monster_in_fight(self): print(" VS. ") print_skulls() self.display_name() self.display_starting_health() self.display_current_health() self.display_dexterity() print_skulls()
def print_character_in_fight(self): print_skulls() self.display_name() self.display_starting_health() self.display_current_health() self.display_dexterity() self.display_starting_luck() self.display_current_luck() print_skulls()
def roll_stats(): roll_dice = randint(1, 6) dexterity_value = roll_dice + 6 roll_two_dices = randint(2, 12) health_value = roll_two_dices + 12 roll_dice = randint(1, 6) luck_value = roll_dice + 6 print_skulls() print(" Welcome to the Labyrinth of Death! Fate has decided that you shall have:") print_skulls() player.set_initial_dexterity_health_luck(dexterity_value, health_value, luck_value) player.display_starting_stats() return run_roll_stats_submenu()
def run_select_potion_submenu(): select_potion_submenu.print_menu() userinput = select_potion_submenu.store_selection() if userinput not in select_potion_submenu.valid_inputs(): print_error_message() return run_select_potion_submenu() else: if userinput == "D": player.set_potion("POTION OF DEXTERITY") elif userinput == "H": player.set_potion("POTION OF HEALTH") elif userinput == "L": player.set_potion("POTION OF LUCK") print_skulls() print(" Are you sure you don't want to change your mind?") print_skulls() return select_potion_submenu.choose(userinput)
def print_character(self): print_skulls() self.display_name() self.display_current_stats() self.display_inventory() print_skulls()
def display_result(self): print_skulls() self.player.display_name() self.player.display_current_health() self.monster.display_name() self.monster.display_current_health()
def newround(self): roll_dice_for_player = randint(2, 12) roll_dice_for_monster = randint(2, 12) player_dexterity = self.player.dexterity + roll_dice_for_player monster_dexterity = self.monster.dexterity + roll_dice_for_monster if player_dexterity > monster_dexterity: self.loser = self.monster print_skulls() print("You hit " + self.monster.name.upper() + "!") print_skulls() elif player_dexterity < monster_dexterity: self.loser = self.player print_skulls() print(self.monster.name.upper() + " hit you!") print_skulls() else: self.loser = None print_skulls() print("It's a draw!") print_skulls()
def print_menu(self): print_skulls() print(" " + self.name + " ") print_skulls() for item in self.items: print(" " + item.firstletter + ": " + item.name + "\n")