-
Notifications
You must be signed in to change notification settings - Fork 0
/
wizmode.scm
121 lines (106 loc) · 3.22 KB
/
wizmode.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
(define locations #f)
(define location-names
'(("Stair to The Gnomish Mines" . mines)
("oracle" . oracle)
("Stair to Sokoban" . soko)
("bigrm" . bigroom)
("Portal to The Quest" . quest)
("rogue" . rogue)
("medusa" . medusa)
("castle" . castle)
("valley" . votd)
("asmodeus" . asmodeus)
("baalz" . baalzebub)
("juiblex" . juiblex)
("Stair to Vlad's Tower" . vlad)
("orcus" . orcus)
("wizard3" . wizard-bottom)
("fakewiz1" . fake-wizard-1)
("fakewiz2" . fake-wizard-2)))
(define (wizmode-get-locations)
(send-expect (char->control-string #\O) expect-more)
(let loop ((i 2)
(ls '()))
(if (= i 24) ; all on first page
(begin
(send-expect "\e" expect-generic)
(set! locations ls))
(let* ((str (get-row-plaintext i))
(colon (string-index str #\:))
(name (string-trim-both (substring str 0 colon)))
(level (string->number
(string-trim-right (string-drop str (+ colon 2))))))
(loop (+ i 1)
(if (assoc name location-names)
(cons (cons (cdr (assoc name location-names)) level)
ls)
ls))))))
(define (wizmode-location loc)
(if (not locations)
(wizmode-get-locations))
(cdr (assq loc locations)))
(define (wizmode-map)
(send-expect (char->control-string #\F) expect-dunno)
(mark-all-corridors-seen))
(define (wizmode-levelport level)
(send-expect (char->control-string #\V)
(lambda (res tries)
(match-before-cur? "To what level do you want to teleport? ")))
(send-expect (string-append (number->string level) "\n")
expect-dunno))
(define (wizmode-wish str)
(send-expect (char->control-string #\W)
(lambda (res tries)
(match-before-cur? "For what do you wish? ")))
(send-expect (string-append str "\n")
expect-generic))
(define (wizmode-create-monster str)
(send-expect (char->control-string #\G)
(lambda (res tries)
(match-before-cur? "[type the name or symbol] ")))
(send-expect (string-append str "\n")
expect-generic))
(define (wizmode-identify-inventory)
(send-expect (char->control-string #\I)
expect-generic)
(let loop ()
(if (at-more?)
(begin (send-expect " " expect-generic)
(loop)))))
(define last-checked -1)
(define align #f)
(define hunger #f)
(define (update-align-hunger)
(if (not (= last-checked (turns)))
(begin
(send-expect (char->control-string #\X) expect-menu)
(send-expect " " expect-more)
(let* ((x (car (get-coord)))
(y (cadr (get-coord)))
(hun-str "Your hunger is ")
(aln-str "Your alignment is ")
(start-col (- x 8)))
(let loop ((row 3))
(let ((str (get-row-plaintext row start-col)))
(if (string-prefix? hun-str str)
(set! hunger
(string->number
(substring str
(string-length hun-str)
(string-index str #\.)))))
(if (string-prefix? aln-str str)
(set! align
(string->number
(substring str
(string-length aln-str)
(string-index str #\.))))))
(if (< row y)
(loop (+ row 1)))))
(send-expect " " expect-generic)
(set! last-checked (turns)))))
(define (wizmode-get-hunger)
(begin (update-align-hunger)
hunger))
(define (wizmode-get-align)
(begin (update-align-hunger)
align))