def action_eat(): options = list(player.inventory) if len(options) < 1: return new_line('You have nothing to eat.') options_string = f'{", ".join(options)}, or nothing' food = new_line_input(f'What would you like to eat: {options_string}?') if food == 'nothing': return new_line('Best to save your food for later.') item = get_item(food) if not item: return new_line(res('fail.unknown')) energy = item['energy'] if not energy: return new_line(res('fail.eat')) if energy >= 20: new_line('Mmmm; looks good!') elif energy > 0: new_line('Something is better than nothing.') elif energy < 0: new_line('You may regret this.') else: return print(res('fail.unknown')) player.lose(food) player.heal(energy)
def action_feed(): global mode options = list(player.inventory) animal = animals[location[0]] if len(options) < 1: return new_line('You have nothing to feed animal.') options_string = ', '.join(options) + ', or nothing' selection = new_line_input( f'What would you like to feed the animal: {options_string}?') if selection in options: player.lose(selection) new_line(f'You try feeding it one {selection}.') animal_leaves = animal.feed(selection) if animal_leaves: if not animal.is_alive: player.collect(animal.resource) mode = 'explore' animals[location[0]] = None elif selection == 'nothing': return new_line('Best to save your food for later.') else: return new_line(res('fail.unknown'))
def action_navigate(direction): options = ('north', 'n', 'east', 'e', 'south', 's', 'west', 'w', 'back', 'b') if not direction: direction = new_line_input( 'Which direction: north, east, south, west, or back?').lower() if direction not in options: print(res('fail.unknown')) else: navigate(direction)
def action_inspect(): options = list(player.inventory) if len(options) < 1: return new_line('You have nothing to inspect.') options_string = ', '.join(options) + ', or nothing' selection = new_line_input( f'What would you like to inspect: {options_string}?') if selection in options: return new_line(get_item(selection)['description']) elif selection == 'nothing': return new_line('Best to keep moving.') else: return new_line(res('fail.unknown'))
def action_check(check): if not check: check = new_line_input( 'What do you want to check: location, map, inventory, or status?' ).lower() if check == 'inventory': return new_line(f'Inventory: {player.inventory}' if len( player.inventory) > 0 else 'You have nothing in your inventory.') elif check == 'location': return new_line( f'You are standing in a {world_map[location[0]].type} at {location[0]}.' ) elif check == 'status': return player.checkup() elif check == 'map': return print_map(location[0], world_map, animals) else: print(res('fail.unknown'))
def encounter(): action_input = new_line_input( 'What do you want to do: look, run, feed, or attack?').lower() action_list = action_input.split(' ') action = action_list[0] # extra = action_list[1] if len(action_list) > 1 else None if action == 'run': action_run() elif action == 'look': animal = animals[location[0]] new_line( f'{animal.description} It looks {"angry!" if animal.is_angry else "calm."}' ) elif action == 'feed': action_feed() elif action == 'attack': action_attack() else: new_line(res('fail.unknown'))
def explore(): action_input = new_line_input( 'What do you want to do: look, navigate, forage, check, eat, inspect, or assemble?' ).lower() action_list = action_input.split(' ') action = action_list[0] extra = action_list[1] if len(action_list) > 1 else None if action in ['navigate', 'go']: action_navigate(extra) elif action == 'forage': action_forage(player) elif action == 'look': action_look() elif action == 'check': action_check(extra) elif action == 'eat': action_eat() elif action == 'inspect': action_inspect() elif action == 'assemble': action_assemble() else: new_line(res('fail.unknown'))
requirement = square.requirement if requirement and requirement not in player.inventory: return new_line(f'You need one {requirement} to forage here.') product = square.produce() if product is not None: if requirement: player.lose(requirement) player.collect(product, square.difficulty) else: new_line('You find nothing.') player.tire(square.difficulty) player_name = new_line_input('What is your name, explorer?') player = Explorer(player_name) new_line(f'Welcome, {player.name}, to the land of Rimoria!') def status_check(): global player while player.status != 'dead': options = {'encounter': encounter, 'explore': explore} options[mode]() gameover_results(player, world_map) def encounter(): action_input = new_line_input( 'What do you want to do: look, run, feed, or attack?').lower()