def drop(element: Union[str, NPC], scenario: Scenario) -> None: ''' Function fired when the Player wants the Hero to drop something. ''' if not element: print('Which item would you like to drop?') Hero.declare_inventory() which_item = input('> ') __element: str = system_name(which_item) else: __element: str = system_name(element) this_element: Item = Hero.get_item_from_inventory(__element) if this_element: if this_element not in scenario.floor: scenario.add_to_floor(this_element) Hero.drop_item(this_element) else: equiped_item: Item = Hero.get_equiped_item(__element) if equiped_item: scenario.add_to_floor(equiped_item) Hero.drop_item(equiped_item) else: print('You can\'t drop items that you don\'t have.')
def basic_actions(scenario: Scenario) -> None: ''' It is called to check Player decisions related to no-combat actions. ''' print_cinematics('What do you do?') while True: action = await_for_action() if action.startswith('look'): what = action.replace('look', '').replace( ' at ', '').replace(' the ', '').lstrip() look(what, scenario) elif action.startswith('search'): if action == 'search': print('You need to tell where would you like to search.') else: place: str = action.replace( 'search', '').replace('the', '').lstrip() search(place, scenario) elif action.startswith('take') or action.startswith('get'): what: str = action.replace('take', '').replace('get', '').lstrip() take(what, scenario) elif 'inventory' in action or 'items' in action: Hero.declare_inventory() elif 'bad inv' in action: print('$$$ Enemy Items', list( __this.name for __this in ugly_monster.inventory)) print('$$$ Enemy Weapons', list([getattr(ugly_monster.weapon, 'name', None), getattr(ugly_monster.armor, 'name', None), getattr(ugly_monster.shield, 'name', None)])) elif 'status' in action in action: print_cinematics(Hero.declare_status) elif action.startswith('draw'): item: str = action.replace( 'draw', '').replace('weapon', '').lstrip() if not Hero.weapon: print('You have no weapons.') else: weapon = Hero.get_equiped_item(item) if not weapon: print(f'{item.title()} is not your main weapon.') else: print(f'{Hero.draw_weapon}.') elif action.startswith('drop'): what: str = action.replace('drop', '').lstrip() drop(what, scenario) elif action.startswith('equip'): what: str = action.replace('equip', '').lstrip() equip(what) elif action.startswith('eat'): what: List = action.split(' ', 1)[1] eat(what, scenario) else: print('You can\'t do that.')