1 #include "std.h"
2 
3 int lamp_is_lit, reboot_time, time_from_reset, last_reset_cycle;
4 int list_length;
5 
reset(string arg)6 void reset(string arg)
7 {
8     if (time_from_reset)
9 	last_reset_cycle = time() - time_from_reset;
10     time_from_reset = time();
11     if (arg)
12 	return;
13     set_light(1);
14     reboot_time = time();
15 }
16 
init()17 void init()
18 {
19     add_action("west", "west");
20     add_action("open", "open");
21     add_action("push", "push");
22     add_action("push", "press");
23     add_action("close", "close");
24     add_action("pray", "pray");
25     add_action("pray", "regenerate");
26     add_action("south", "south");
27 }
28 
29 string short() {
30     return "Village church";
31 }
32 
33 void long(string str)
34 {
35     if (str == "clock") {
36 	int i, j;
37 	write("The clock shows ");
38 	i = time() - reboot_time;
39 	j = i / 60 / 60 / 24;
40 	if (j == 1)
41 	    write("1 day ");
42 	else if (j > 0)
43 	    write(j + " days ");
44 	i -= j * 60 * 60 * 24;
45 	j = i / 60 / 60;
46 	if (j == 1)
47 	    write("1 hour ");
48 	else if (j > 0)
49 	    write(j + " hours ");
50 	i -= j * 60 * 60;
51 	j = i / 60;
52 	if (j == 1)
53 	    write("1 minute ");
54 	else if (j > 0)
55 	    write(j + " minutes ");
56 	i -= j * 60;
57 	if (i == 1)
58 	    write("1 second");
59 	else if (i > 0)
60 	    write(i + " seconds");
61 	write("\n");
62 	if (this_player()->query_level() < 20)
63 	    return;
64 	write("Time since reset is " + (time() - time_from_reset) +
65 	      " seconds.\n");
66 	if (last_reset_cycle)
67 	    write("Reset cycle: " + last_reset_cycle + "\n");
68 	write("Free block list length: " + list_length + "\n");
69 	return;
70     }
71     if (str == "door") {
72 	if (!"room/elevator"->query_door(0) &&
73 	    "room/elevator"->query_level(0))
74 	    write("The door is open.\n");
75 	else
76 	    write("The door is closed.\n");
77 	return;
78     }
79     if (str == "pit") {
80 	write("In the middle of the church is a deep pit.\n"+
81 	      "It was used for sacrifice in the old times, but nowadays\n" +
82 	      "it is only left for tourists to look at.\n");
83 	return;
84     }
85     write("You are in the local village church.\nThere is a huge pit in the center,\n" +
86 	 "and a door in the west wall. There is a button beside the door.\n");
87     write("This church has the service of reviving ghosts. Dead people come\n");
88     write("to the church and pray.\n");
89     write("There is a clock on the wall.\n");
90     write("There is an exit to south.\n");
91     if (lamp_is_lit)
92         write("The lamp beside the elevator is lit.\n");
93 
94 }
95 
id(string str)96 int id(string str) {
97     return str == "door" || str == "pit" || str == "clock";
98 }
99 
xyzzy()100 int xyzzy() {
101     write("Everything shimmers.\n");
102     write("You wake up elsewhere...\n");
103     this_player()->move_player("elsewhere#room/test");
104     return 1;
105 }
106 
west()107 int west() {
108     if ("room/elevator"->query_door(0) ||
109 	"room/elevator"->query_level(0) != 2) {
110 	write("The door is closed.\n");
111 	return 1;
112     }
113     this_player()->move_player("west#room/elevator");
114     return 1;
115 }
116 
open(string str)117 int open(string str)
118 {
119     if (str != "door")
120 	return 0;
121     if ("room/elevator"->query_level(0) != 2) {
122 	write("You can't when the elevator isn't here.\n");
123 	return 1;
124     }
125     "room/elevator"->open_door("door");
126     return 1;
127 }
128 
close(string str)129 int close(string str)
130 {
131     if (str != "door")
132 	return 0;
133     "room/elevator"->close_door("door");
134     return 1;
135 }
136 
push(string str)137 int push(string str)
138 {
139     if (str && str != "button")
140 	return 0;
141     if ("room/elevator"->call_elevator(2))
142 	lamp_is_lit = 1;
143     return 1;
144 }
145 
elevator_arrives()146 void elevator_arrives()
147 {
148     say("The lamp on the button beside the elevator goes out.\n");
149     lamp_is_lit = 0;
150 }
151 
pray()152 int pray() {
153     return this_player()->remove_ghost();
154 }
155 
prevent_look_at_inv(string str)156 int prevent_look_at_inv(string str)
157 {
158     return str != 0;
159 }
160 
south()161 int south() {
162     this_player()->move_player("south#room/vill_green");
163     return 1;
164 }
165 
query_drop_castle()166 int query_drop_castle() {
167     return 1;
168 }
169