#include #include "adventure.h" static void swap_locations(struct object *a, struct object *b) { struct object *t; assert(a != NULL); assert(b != NULL); t = a->location; a->location = b->location; b->location = t; } const char * cannot_be_opened(struct object *o) { return "That cannot be opened."; } const char * cannot_be_closed(struct object *o) { return "That cannot be closed."; } const char * cannot_be_locked(struct object *o) { return "That cannot be locked."; } const char * cannot_be_unlocked(struct object *o) { return "That cannot be unlocked."; } const char * is_already_open(struct object *o) { return "That is already open."; } const char * is_already_closed(struct object *o) { return "That is already closed."; } const char * is_already_locked(struct object *o) { return "That is already locked."; } const char * is_already_unlocked(struct object *o) { return "That is already unlocked."; } const char * is_still_open(struct object *o) { return "That is still open."; } const char * is_still_locked(struct object *o) { return "That is still locked."; } const char * toggle_backdoor(struct object *o) { swap_locations(open_door_to_backroom, closed_door_to_backroom); swap_locations(open_door_to_cave, closed_door_to_cave); return "OK."; } const char * toggle_box(struct object *o) { swap_locations(open_box, closed_box); return "OK."; } const char * toggle_box_lock(struct object *o) { if (key_for_box->location == player) { swap_locations(closed_box, locked_box); return "OK."; } else { return "You try really hard, but the closed box won't open " "without a key."; } }