1 /* #define MUST_STAY_WITH_DRINKS */
2 object top_list;
3 object player;
4 int current_problem, starts_thinking;
5 object solved_by, wrong_by;
6 int problem_value;
7
8 object rules;
9
reset(arg)10 reset(arg) {
11 start_player();
12 if (!top_list || !present(top_list, this_object())) {
13 top_list = clone_object("obj/level_list");
14 move_object(top_list, this_object());
15 }
16 if (!rules || !present(rules, this_object())) {
17 rules = clone_object("obj/Go/rules");
18 move_object(rules, this_object());
19 }
20 if (arg) return;
21 set_light( 1);
22 }
23
24 short() {
25 return "The local pub";
26 }
27
init()28 init() {
29 add_action("move", "west");
30 add_action("order", "order");
31 add_action("order", "buy");
32 add_action("look", "look");
33 }
34
move()35 move() {
36 #ifdef MUST_STAY_WITH_DRINKS
37 if (has_drink(this_player())) {
38 tell_object(this_player(),
39 "You are not allowed to leave with drinks!\n");
40 return 1;
41 }
42 #endif
43 call_other(this_player(), "move_player", "west" + "#" +"room/yard");
44 return 1;
45 }
46
47 long() {
48 write("You are in the local pub.\n");
49 write("You can order drinks here.\n\n");
50 write(" First class beer : 12 coins\n");
51 write(" Special of the house: 50 coins\n");
52 write(" Firebreather : 150 coins\n\n");
53 /* write(" Potion of healing : 200 coins\n\n"); */
54 write("The only obvious exit is to " + "west" + ".\n");
55 }
56
order(str)57 order(str)
58 {
59 object drink;
60 string name, short_desc, mess;
61 int value, cost, strength, heal;
62
63 if (!str) {
64 write("Order what ?\n");
65 return 1;
66 }
67 if (str == "beer") {
68 name = str;
69 short_desc = "A bottle of beer";
70 mess = "That feels good";
71 heal = 0;
72 value = 12;
73 strength = 2;
74 }
75 else if (str == "special" || str == "special of the house") {
76 name = "special";
77 short_desc = "A special of the house";
78 mess = "A tingling feeling goes through your body";
79 heal = 10;
80 value = 50;
81 strength = 8;
82 } else if (str == "firebreather" || str == "fire") {
83 name = "firebreather";
84 short_desc = "A firebreather";
85 mess = "A shock wave runs through your body";
86 heal = 25;
87 value = 150;
88 strength = 12;
89 #if 0
90 } else if (str == "potion" || str == "potion of healing") {
91 name = "potion";
92 short_desc = "A potion of healing";
93 mess = "You are totally healed";
94 heal = 1000;
95 value = 200;
96 strength = 0;
97 #endif
98 } else {
99 write("What ?\n");
100 return 1;
101 }
102 if (call_other(this_player(), "query_money", 0) < value) {
103 write("That costs " + value + " gold coins, which you don't have.\n");
104 return 1;
105 }
106 drink = clone_object("obj/drink");
107 if (!call_other(this_player(), "add_weight",
108 call_other(drink, "query_weight"))) {
109 write("You can't carry more.\n");
110 destruct(drink);
111 return 1;
112 }
113 if (!call_other(drink, "set_value", name + "#" + short_desc + "#" + mess +
114 "#" + heal + "#" + value + "#" + strength)) {
115 write("Error in creating drink.\n");
116 destruct(drink);
117 return 1;
118 }
119 call_other(drink, "set_pub");
120 move_object(drink, this_player());
121 call_other(this_player(), "add_money", - value);
122 write("You pay " + value + " for a " + name + ".\n");
123 say(call_other(this_player(), "query_name", 0) + " orders a " +
124 name + ".\n");
125 return 1;
126 }
127
128 /*
129 * Make this global, and only initialized once.
130 */
131 string chat_str, funcname, type, match;
132
start_player()133 start_player() {
134 if(!player) {
135 player = clone_object("obj/monster");
136 call_other(player, "set_name", "player");
137 call_other(player, "set_alias", "go player");
138 call_other(player, "set_short", "Go player");
139 call_other(player, "set_long",
140 "A man sitting beside a go board, concentrating on a problem.\n" +
141 "He looks as if he wants help. Why not look at his problem,\n" +
142 "and tell him where to play ?\n");
143 call_other(player, "set_level",10);
144 call_other(player, "set_al",200);
145 call_other(player, "set_ep",39000);
146 call_other(player, "set_hp",100);
147 call_other(player, "set_wc",12);
148 move_object(player, "room/pub2");
149 if (!funcname) {
150 funcname = allocate(2);
151 type = allocate(2);
152 match = allocate(2);
153 funcname[0] = "got_play";
154 type[0] = "says:";
155 match[0] = " play";
156 funcname[1] = "make_move";
157 type[1] = "PISS";
158 match[1] = " OFF";
159 }
160 call_other(player, "set_match", this_object(), funcname, type, match);
161 if (!chat_str) {
162 chat_str = allocate(5);
163 chat_str[0] = "Go player says: Hm. This is tricky!\n";
164 chat_str[1] = "Go player says: The moron who wrote this book didn't deal with this problem.\n";
165 chat_str[2] = "Go player says: A throw in here should just be wasted.\n";
166 chat_str[3] = "Go player says: This group is more alive than I am.\n";
167 chat_str[4] = "Go player says: This is simple using oi-otoshi.\n";
168 }
169 call_other(player, "load_chat", 1, chat_str);
170 }
171 current_problem = 0;
172 }
173
got_play(str)174 got_play(str) {
175 string who, what;
176 if (sscanf(str, "%s tells you: play %s\n", who , what) == 2 ||
177 sscanf(str, "%s says: play %s\n", who , what) == 2) {
178 if (current_problem == 0) {
179 if (what == "b1" || what == "b 1" || what == "1b" || what == "1 b")
180 solved_by = find_living(lower_case(who));
181 else
182 wrong_by = find_living(lower_case(who));
183 problem_value = 50;
184 }
185 if (current_problem == 1) {
186 if (what == "b2" || what == "b 2" || what == "2b" || what == "2 b")
187 solved_by = find_living(lower_case(who));
188 else
189 wrong_by = find_living(lower_case(who));
190 problem_value = 100;
191 }
192 if (current_problem == 2) {
193 if (what == "d3" || what == "d 3" || what == "3d" || what == "3 d")
194 solved_by = find_living(lower_case(who));
195 else
196 wrong_by = find_living(lower_case(who));
197 problem_value = 200;
198 }
199 notify("The go player contemplates a proposed play.\n");
200 tell_object(player, "Arne PISS OFF\n");
201 } else if (sscanf(str, "%s tells you: %s", who, what) == 2) {
202 say("The go player says: what ?\n");
203 }
204 }
205
show_problem()206 show_problem() {
207 if(current_problem > 2) {
208 write("The player looks tired.\n");
209 return;
210 }
211 if(!player || !living(player))
212 return;
213 write("The board looks like this:\n\n");
214 say(call_other(this_player(), "query_name", 0) +
215 " examines the go problem.\n");
216 if (current_problem == 0) {
217 write("5|.......\n" +
218 "4|.......\n" +
219 "3|@@@@@..\n" +
220 "2|OOOO@..\n" +
221 "1|...O@..\n" +
222 " --------\n" +
223 " abcdefg\n" +
224 "\nIt is black ('@') to play.\n");
225 return;
226 } else if (current_problem == 1) {
227 write("7|.......\n" +
228 "6|.......\n" +
229 "5|@@@....\n" +
230 "4|OOO@@..\n" +
231 "3|O.OO@..\n" +
232 "2|...O@..\n" +
233 "1|..OO@..\n" +
234 " --------\n" +
235 " abcdefg\n" +
236 "\nIt is black ('@') to play.\n");
237 return;
238 } else if (current_problem == 2) {
239 write("5|..........\n" +
240 "4|...@@@@@..\n" +
241 "3|@@@.O...@.\n" +
242 "2|@OO@OOOO@.\n" +
243 "1|@OO.O...@.\n" +
244 " -----------\n" +
245 " abcdefg\n" +
246 "\nIt is white ('O') to play.\n");
247 return;
248 } else {
249 write("The go player does not want to be disturbed any more.\n");
250 }
251 }
252
make_move(str)253 make_move(str) {
254 if (solved_by) {
255 int i;
256 i = current_problem + 1;
257 say("The go player says: Right ! That works !\n" +
258 "He immediately plays out a new problem.\n");
259 tell_object(solved_by,
260 "You feel that you have gained some experience.\n");
261 call_other(solved_by, "add_exp", problem_value);
262 solved_by = 0;
263 current_problem += 1;
264 }
265 if (wrong_by) {
266 say("The go player says: No, that doesn't work.\n");
267 say("He sinks back into his deep thought.\n");
268 wrong_by = 0;
269 }
270 }
271
notify(str)272 notify(str) {
273 say(str);
274 write(str);
275 }
276
look(str)277 look(str) {
278 string what, rest;
279 if(str) {
280 if(!player || !living(player))
281 return 0;
282 if(sscanf(str, "at %s", what) == 1 || sscanf(str, "%s", what) == 1) {
283 if(what == "game" || what == "problem" || what == "board") {
284 show_problem();
285 return 1;
286 }
287 }
288 }
289 return 0;
290 }
291
292 #ifdef MUST_STAY_WITH_DRINKS
has_drink(obj)293 has_drink(obj) {
294 status drink;
295 object ob;
296 ob = first_inventory(obj);
297 while(ob) {
298 if (call_other(ob, "id", "drk2"))
299 drink = 1;
300 if (call_other(ob,"can_put_and_get")) {
301 if (has_drink(ob))
302 drink = 1;
303 }
304 ob = next_inventory(ob);
305 }
306 return drink;
307 }
308 #endif
309
query_drop_castle()310 query_drop_castle() {
311 return 1;
312 }
313