1 cc9bbf61 2020-04-01 op #include <assert.h>
3 cc9bbf61 2020-04-01 op #include "adventure.h"
6 cc9bbf61 2020-04-01 op swap_locations(struct object *a, struct object *b)
8 cc9bbf61 2020-04-01 op struct object *t;
10 cc9bbf61 2020-04-01 op assert(a != NULL);
11 cc9bbf61 2020-04-01 op assert(b != NULL);
13 cc9bbf61 2020-04-01 op t = a->location;
14 cc9bbf61 2020-04-01 op a->location = b->location;
15 cc9bbf61 2020-04-01 op b->location = t;
19 cc9bbf61 2020-04-01 op cannot_be_opened(struct object *o)
21 cc9bbf61 2020-04-01 op return "That cannot be opened.";
25 cc9bbf61 2020-04-01 op cannot_be_closed(struct object *o)
27 cc9bbf61 2020-04-01 op return "That cannot be closed.";
31 cc9bbf61 2020-04-01 op cannot_be_locked(struct object *o)
33 cc9bbf61 2020-04-01 op return "That cannot be locked.";
37 cc9bbf61 2020-04-01 op cannot_be_unlocked(struct object *o)
39 cc9bbf61 2020-04-01 op return "That cannot be unlocked.";
43 cc9bbf61 2020-04-01 op is_already_open(struct object *o)
45 cc9bbf61 2020-04-01 op return "That is already open.";
49 cc9bbf61 2020-04-01 op is_already_closed(struct object *o)
51 cc9bbf61 2020-04-01 op return "That is already closed.";
55 cc9bbf61 2020-04-01 op is_already_locked(struct object *o)
57 cc9bbf61 2020-04-01 op return "That is already locked.";
61 cc9bbf61 2020-04-01 op is_already_unlocked(struct object *o)
63 cc9bbf61 2020-04-01 op return "That is already unlocked.";
67 cc9bbf61 2020-04-01 op is_still_open(struct object *o)
69 cc9bbf61 2020-04-01 op return "That is still open.";
73 cc9bbf61 2020-04-01 op is_still_locked(struct object *o)
75 cc9bbf61 2020-04-01 op return "That is still locked.";
79 cc9bbf61 2020-04-01 op toggle_backdoor(struct object *o)
81 cc9bbf61 2020-04-01 op swap_locations(open_door_to_backroom, closed_door_to_backroom);
82 cc9bbf61 2020-04-01 op swap_locations(open_door_to_cave, closed_door_to_cave);
87 cc9bbf61 2020-04-01 op toggle_box(struct object *o)
89 cc9bbf61 2020-04-01 op swap_locations(open_box, closed_box);
94 cc9bbf61 2020-04-01 op toggle_box_lock(struct object *o)
96 cc9bbf61 2020-04-01 op if (key_for_box->location == player) {
97 cc9bbf61 2020-04-01 op swap_locations(closed_box, locked_box);
100 7f40f3f5 2020-04-03 op return "You try really hard, but the closed box won't open "
101 7f40f3f5 2020-04-03 op "without a key.";