1# vi: set ts=2 shiftwidth=2 expandtab:
2#
3# System and user variable tests.
4#
5# Covers user and system variables, integers as words, and some left-over
6# operator precedence for expressions.
7#
8# Unless otherwise noted, the input and responses in this script were created
9# from a transcript of the Adrift Runner, release 4.0.45 or 46.
10#
11
12~ game
13*Valueless* Compiled "08 Nov 2006"* Version 4.00*
14
15
16#
17# Check some expression operator precedences.
18#
19
20# Note -- Adrift's operator precedence seems to be somewhat wacky.  The
21# expressions calculated here are:
22#   a := -7+6+5^4-3*2
23#   b := -7+(6*5)^(4-3)*2
24#   c := (1--1)+(1+-1)+-1
25#   d := 10+10/2-(10+10)/2
26#   e := 10+15mod7-(10+15)mod7
27# For normal precedence, the results should be:
28#   a = "618" b = "53" c = "1" d = "5" e = "7"
29# However, Adrift appears to lump exponentiation and modulus in with addition
30# and subtraction, giving a completely different set of results.  As a result,
31# SCARE's expression parser tries to replicate this, even though it's arguably
32# rather broken.
33> expressions
34a = "250" b = "529" c = "1" d = "5" e = "0"
35
36
37#
38# Verify general system constants and variables.
39#
40
41> statics
42author = "A.N. Onymous"
43maxscore = 15
44modified = "08 Nov 2006"
45player = "Ted Swippett"
46title = "Valueless"
47
48# We can't verify playing time accurately.
49# TODO SCARE's idea of turns doesn't accurately track Adrifts; in particular,
50# "administrative" tasks don't count as turns in SCARE.
51> dynamics
52score = 0
53time = *
54turns = [0-9]
55
56
57#
58# Test score manipulations.
59#
60# Note -- this section has been altered slightly to match the way SCARE works.
61# SCARE prints "...has decreased by N" rather than the tautological "...has
62# decreased by -N".
63#
64
65> score 5
66(Your score has increased by 5)
67score = "5"
68
69> dynamics
70score = 5 time = * turns = *
71
72> score 5
73score = "5"
74
75> score 10
76(Your score has increased by 10)
77score = "15"
78
79> score 10
80score = "15"
81
82> score -1
83(Your score has decreased by 1)
84score = "14"
85
86> score -1
87(Your score has decreased by 1)
88score = "13"
89
90> score -1, score -1, score -1, score -1, score -1, score -1, score -1, score -1
91(Your score has decreased by 1)
92score = "12"
93(Your score has decreased by 1)
94score = "11"
95(Your score has decreased by 1)
96score = "10"
97(Your score has decreased by 1)
98score = "9"
99(Your score has decreased by 1)
100score = "8"
101(Your score has decreased by 1)
102score = "7"
103(Your score has decreased by 1)
104score = "6"
105(Your score has decreased by 1)
106score = "5"
107
108> score -1, score -1, score -1, score -1, score -1, score -1, score -1, score -1
109(Your score has decreased by 1)
110score = "4"
111(Your score has decreased by 1)
112score = "3"
113(Your score has decreased by 1)
114score = "2"
115(Your score has decreased by 1)
116score = "1"
117(Your score has decreased by 1)
118score = "0"
119(Your score has decreased by 1)
120score = "-1"
121(Your score has decreased by 1)
122score = "-2"
123(Your score has decreased by 1)
124score = "-3"
125
126
127#
128# Check variables that reference an NPC.
129#
130
131> character janitor
132character = "the janitor"
133heshe = "he"
134himher = "him"
135
136
137#
138# Check variables that reference an object.
139#
140
141# Obstate_ has to be handled carefully here, as it causes Adrift error 9 in
142# the Runner if used on a non-stateful object.  For that reason, we handle it
143# separately later on.
144> object cupboard
145object = "a cupboard"
146obstate = "[[]obstate breaks Adrift[]]"
147obstatus = "closed"
148theobject = "the cupboard"
149
150> object table
151object = "a table"
152obstate = "[[]obstate breaks Adrift[]]"
153obstatus = "unopenable"
154theobject = "the table"
155
156> object switch
157object = "a switch"
158obstate = "[[]obstate breaks Adrift[]]"
159obstatus = "unopenable"
160theobject = "the switch"
161
162> open cupboard
163
164> object cupboard
165object = "a cupboard"
166obstate = "[[]obstate breaks Adrift[]]"
167obstatus = "open"
168theobject = "the cupboard"
169
170> object book
171object = "a book"
172obstate = "[[]obstate breaks Adrift[]]"
173obstatus = "unopenable"
174theobject = "the book"
175
176> object tray
177object = "a tray"
178obstate = "[[]obstate breaks Adrift[]]"
179obstatus = "unopenable"
180theobject = "the tray"
181
182> object bag
183object = "a bag"
184obstate = "[[]obstate breaks Adrift[]]"
185obstatus = "closed"
186theobject = "the bag"
187
188> object hat
189object = "a hat"
190obstate = "[[]obstate breaks Adrift[]]"
191obstatus = "unopenable"
192theobject = "the hat"
193
194> take bag, open bag
195
196> object bag
197object = "a bag"
198obstate = "[[]obstate breaks Adrift[]]"
199obstatus = "open"
200theobject = "the bag"
201
202# Separate tests for obstate_, invoked only on a stateful object.
203> object_breaks_adrift switch
204obstate = "On"
205
206> switch off
207Flipped off.
208
209> object_breaks_adrift switch
210obstate = "Off"
211
212> switch between
213Flipped between.
214
215> object_breaks_adrift switch
216obstate = "In between"
217
218> switch on
219Flipped on.
220
221> object_breaks_adrift switch
222obstate = "On"
223
224
225#
226# Check variables that reference a number or text.
227#
228
229> number -1
230number = -1 t_number = "-1"
231
232> number 0
233number = 0 t_number = "zero"
234
235> number 1
236number = 1 t_number = "one"
237
238> number 2
239number = 2 t_number = "two"
240
241> number 3
242number = 3 t_number = "three"
243
244> number 4
245number = 4 t_number = "four"
246
247> number 5
248number = 5 t_number = "five"
249
250> number 6
251number = 6 t_number = "six"
252
253> number 7
254number = 7 t_number = "seven"
255
256> number 8
257number = 8 t_number = "eight"
258
259> number 9
260number = 9 t_number = "nine"
261
262> number 10
263number = 10 t_number = "ten"
264
265> number 11
266number = 11 t_number = "eleven"
267
268> number 12
269number = 12 t_number = "twelve"
270
271> number 13
272number = 13 t_number = "thirteen"
273
274> number 14
275number = 14 t_number = "fourteen"
276
277> number 15
278number = 15 t_number = "fifteen"
279
280> number 16
281number = 16 t_number = "sixteen"
282
283> number 17
284number = 17 t_number = "seventeen"
285
286> number 18
287number = 18 t_number = "eighteen"
288
289> number 19
290number = 19 t_number = "nineteen"
291
292> number 20
293number = 20 t_number = "twenty"
294
295> number 21
296number = 21 t_number = "21"
297
298> number 123
299number = 123 t_number = "123"
300
301> number -123
302number = -123 t_number = "-123"
303
304> text hello world
305text = "hello world"
306
307> text the quick brown fox jumped over the lazy dog
308text = "the quick brown fox jumped over the lazy dog"
309
310
311#
312# Check variables that name a user variable.
313#
314
315> expressions
316a = "250" b = "529" c = "1" d = "5" e = "0"
317
318> variables
319t_a = "250" t_b = "529" t_c = "one" t_d = "five" t_e = "zero"
320
321
322#
323# Check variables that name an object.
324#
325# TODO Adrift somehow fiddles with the casing of object states so that in
326# some contexts they're "On", in others "on".  It's not clear how, and maybe
327# it's a bug; for now this test permits both below for state_switch.
328#
329# TODO In a couple of cases, SCARE prints "<objects> are in <container>"
330# where Adrift uses "Inside <container> are <objects>".  Adrift has two
331# possible formats it could use here, and the selection criteria it uses for
332# this (if any) isn't yet known.  For now, these test expectations have been
333# altered to allow the test to pass.
334#
335
336> close bag, put bag in cupboard
337
338> named objects
339#in_cupboard = "Inside the cupboard is a book, a tray, a bag and a hat."
340in_cupboard = "A book, a tray, a bag and a hat are inside the cupboard."
341on_cupboard = ""
342#onin_cupboard = "Inside the cupboard is a book, a tray, a bag and a hat."
343onin_cupboard = "A book, a tray, a bag and a hat are inside the cupboard."
344in_bag = ""
345on_bag = ""
346onin_bag = ""
347in_tray = ""
348on_tray = ""
349onin_tray = ""
350state_switch = "[Oo]n"
351status_cupboard = "open"
352
353> take bag, take hat, open bag, put hat in bag
354
355> named objects
356in_cupboard = "A book and a tray are inside the cupboard."
357on_cupboard = ""
358onin_cupboard = "A book and a tray are inside the cupboard."
359in_bag = "A hat is inside the bag."
360on_bag = ""
361onin_bag = "A hat is inside the bag."
362in_tray = ""
363on_tray = ""
364onin_tray = ""
365state_switch = "[Oo]n"
366status_cupboard = "open"
367
368> take book, put book in bag
369
370> named objects
371in_cupboard = "A tray is inside the cupboard."
372on_cupboard = ""
373onin_cupboard = "A tray is inside the cupboard."
374in_bag = "A book and a hat are inside the bag."
375on_bag = ""
376onin_bag = "A book and a hat are inside the bag."
377in_tray = ""
378on_tray = ""
379onin_tray = ""
380state_switch = "[Oo]n"
381status_cupboard = "open"
382
383> take tray, take all from bag
384
385> named objects
386in_cupboard = ""
387on_cupboard = ""
388onin_cupboard = ""
389in_bag = ""
390on_bag = ""
391onin_bag = ""
392in_tray = ""
393on_tray = ""
394onin_tray = ""
395state_switch = "[Oo]n"
396status_cupboard = "open"
397
398> put hat on tray, put bag on tray
399
400> named objects
401in_cupboard = ""
402on_cupboard = ""
403onin_cupboard = ""
404in_bag = ""
405on_bag = ""
406onin_bag = ""
407in_tray = ""
408on_tray = "A bag and a hat are on the tray."
409onin_tray = "A bag and a hat are on the tray."
410state_switch = "[Oo]n"
411status_cupboard = "open"
412
413> restart
414> open cupboard, take tray from cupboard, take book from cupboard
415> put book on tray, put tray on cupboard
416
417> named objects
418in_cupboard = "A bag and a hat are inside the cupboard."
419on_cupboard = "A tray is on the cupboard."
420#onin_cupboard = "A tray is on the cupboard, and inside is a bag and a hat."
421onin_cupboard = "A tray is on the cupboard, and a bag and a hat are inside."
422in_bag = ""
423on_bag = ""
424onin_bag = ""
425in_tray = ""
426on_tray = "A book is on the tray."
427onin_tray = "A book is on the tray."
428state_switch = "[Oo]n"
429status_cupboard = "open"
430
431> take bag, open it, take hat, put hat in bag, put bag on cupboard
432
433> named objects
434in_cupboard = ""
435on_cupboard = "A tray and a bag are on the cupboard."
436onin_cupboard = "A tray and a bag are on the cupboard."
437in_bag = "A hat is inside the bag."
438on_bag = ""
439onin_bag = "A hat is inside the bag."
440in_tray = ""
441on_tray = "A book is on the tray."
442onin_tray = "A book is on the tray."
443state_switch = "[Oo]n"
444status_cupboard = "open"
445
446
447#
448# Check %version%, for some reason, not directly printable in Adrift.
449#
450
451# Note -- for flexibility, allow any of 4044-4046.
452> version
453version = "404[4-6]"
454
455> variables
456t_a = "404[4-6]" t_b = "404[4-6]"
457t_c = "404[4-6]" t_d = "404[4-6]" t_e = "404[4-6]"
458