def lock_switch(verb: Verb, results: list): given_obj = _get_obj_str(results) target, obj = be.guess_object(given_obj) if target is Object.UNSPECIFIED: print("What do you want to do that to?") elif target is Object.NONEXISTENT: print(f"This isn't available -> '{given_obj}'") elif target is Object.FOUND or target is Object.POSSESSED: be.lock_switch_output(verb, obj)
def examine(results: list) -> None: given_obj = _get_obj_str(results) target, obj = be.guess_object(given_obj) if target is Object.UNSPECIFIED: print("Please specify what you want to examine, i.e. \"examine dog\"") elif target is Object.NONEXISTENT: print(f"This isn't available -> '{given_obj}'") elif target is Object.FOUND or target is Object.POSSESSED: description: str = obj.when_examined if obj.__class__.__name__ == "Container": description += be.describe_contents(obj) print(description)
def drop(results: list): given_obj = _get_obj_str(results) target, obj = be.guess_object(given_obj) if target is Object.UNSPECIFIED: print("Please specify what you want to drop, i.e. \"drop the mic\"") elif target is Object.NONEXISTENT: print(f"This isn't available -> '{given_obj}'") elif target is Object.FOUND: print(f"You are not carrying this -> '{given_obj}'") elif target is Object.POSSESSED: be.drop_on_floor(obj) print(f"You drop {obj.name.lower()}.")
def open_or_close(verb: Verb, results: list): given_obj = _get_obj_str(results) target, obj = be.guess_object(given_obj) if target is Object.UNSPECIFIED: print("Please specify, i.e. \"open red door\"") if target is Object.NONEXISTENT: print(f"This isn't available -> '{given_obj}'") if target is Object.FOUND: if obj.is_openable: print(be.open_or_close_output(verb, obj)) else: print(f"That isn't something you can do that to -> '{given_obj}'")
def put(results: list): obj_list, preposition = _extend_with_prep(results) if not obj_list or not preposition: print("Please specify what you want to do, i.e. \"put coin in box\"") return if len(obj_list) == 1: print(f"{obj_list[0][1].capitalize()} {preposition[0][1]} what?") return target_one, obj_one = be.guess_object(obj_list[0][1]) target_two, obj_two = be.guess_object(obj_list[1][1]) if obj_one is Object.NONEXISTENT or obj_two is Object.NONEXISTENT: print("There is no such thing.") return if preposition[0][0] is Prep.WITHIN: if obj_one.is_gettable: be.add_item_to(obj_two, obj_one) print(f"You put {obj_one.name} in {obj_two.name}.") else: print("That can't be stored.")
def take(results: list) -> None: # we only want to identify one object and ignore everything else. from that identification # derive a target of type Object, and an obj of type Item. given_obj = _get_obj_str(results) target, obj = be.guess_object(given_obj) if target is Object.POSSESSED: print(f"You're carrying that -> '{obj.name}'") elif target is Object.UNSPECIFIED: print("Please specify what you want to take, i.e. \"take the crown\"") elif target is Object.NONEXISTENT: print(f"This isn't available -> '{given_obj}'") elif target is Object.FOUND: if obj.is_gettable: be.add_to_inventory(obj) print(f"You take {obj.name.lower()}.") else: print(f"That can't be taken. -> {obj.name}")