Blob


1 #include <assert.h>
3 #include "adventure.h"
5 static void
6 swap_locations(struct object *a, struct object *b)
7 {
8 struct object *t;
10 assert(a != NULL);
11 assert(b != NULL);
13 t = a->location;
14 a->location = b->location;
15 b->location = t;
16 }
18 const char *
19 cannot_be_opened(struct object *o)
20 {
21 return "That cannot be opened.";
22 }
24 const char *
25 cannot_be_closed(struct object *o)
26 {
27 return "That cannot be closed.";
28 }
30 const char *
31 cannot_be_locked(struct object *o)
32 {
33 return "That cannot be locked.";
34 }
36 const char *
37 cannot_be_unlocked(struct object *o)
38 {
39 return "That cannot be unlocked.";
40 }
42 const char *
43 is_already_open(struct object *o)
44 {
45 return "That is already open.";
46 }
48 const char *
49 is_already_closed(struct object *o)
50 {
51 return "That is already closed.";
52 }
54 const char *
55 is_already_locked(struct object *o)
56 {
57 return "That is already locked.";
58 }
60 const char *
61 is_already_unlocked(struct object *o)
62 {
63 return "That is already unlocked.";
64 }
66 const char *
67 is_still_open(struct object *o)
68 {
69 return "That is still open.";
70 }
72 const char *
73 is_still_locked(struct object *o)
74 {
75 return "That is still locked.";
76 }
78 const char *
79 toggle_backdoor(struct object *o)
80 {
81 swap_locations(open_door_to_backroom, closed_door_to_backroom);
82 swap_locations(open_door_to_cave, closed_door_to_cave);
83 return "OK.";
84 }
86 const char *
87 toggle_box(struct object *o)
88 {
89 swap_locations(open_box, closed_box);
90 return "OK.";
91 }
93 const char *
94 toggle_box_lock(struct object *o)
95 {
96 if (key_for_box->location == player) {
97 swap_locations(closed_box, locked_box);
98 return "OK.";
99 } else {
100 return "You try really hard, but the closed box won't open "
101 "without a key.";