-
Notifications
You must be signed in to change notification settings - Fork 2
/
moreobj.go
333 lines (302 loc) · 5.05 KB
/
moreobj.go
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
package main
/*
* Routines in this file:
*
* oaltar() othrone() ochest() ofountain()
*/
/*
* subroutine to process an altar object
*/
func oaltar() {
lprcat("\nDo you (p) pray (d) desecrate")
iopts()
for {
switch ttgetch() {
case 'p':
lprcat(" pray\nDo you (m) give money or (j) just pray? ")
for {
switch ttgetch() {
case 'j':
act_just_pray()
return
case 'm':
act_donation_pray()
return
case '\033':
return
}
}
case 'd':
lprcat(" desecrate")
act_desecrate_altar()
return
case 'i', '\033':
ignore()
act_ignore_altar()
return
}
}
}
/*
subroutine to process a throne object
*/
func othrone(arg int) {
lprcat("\nDo you (p) pry off jewels, (s) sit down")
iopts()
for {
switch ttgetch() {
case 'p':
lprcat(" pry off")
act_remove_gems(arg)
return
case 's':
lprcat(" sit down")
act_sit_throne(arg)
return
case 'i', '\033':
ignore()
return
}
}
}
func odeadthrone() {
lprcat("\nDo you (s) sit down")
iopts()
for {
switch ttgetch() {
case 's':
lprcat(" sit down")
k := rnd(101)
if k < 35 {
lprcat("\nZaaaappp! You've been teleported!\n")
beep()
oteleport(0)
} else {
lprcat("\nnothing happens")
}
return
case 'i', '\033':
ignore()
return
}
}
}
/*
subroutine to process a throne object
*/
func ochest() {
lprcat("\nDo you (t) take it, (o) try to open it")
iopts()
for {
switch ttgetch() {
case 'o':
lprcat(" open it")
act_open_chest(playerx, playery)
return
case 't':
lprcat(" take")
if take(OCHEST, iarg[playerx][playery]) == 0 {
item[playerx][playery], know[playerx][playery] = 0, false
}
return
case 'i', '\033':
ignore()
return
}
}
}
/*
process a fountain object
*/
func ofountain() {
cursors()
lprcat("\nDo you (d) drink, (w) wash yourself")
iopts()
for {
switch ttgetch() {
case 'd':
lprcat("drink")
act_drink_fountain()
return
case '\033', 'i':
ignore()
return
case 'w':
lprcat("wash yourself")
act_wash_fountain()
return
}
}
}
/*
***
FCH
***
subroutine to process an up/down of a character attribute for ofountain
*/
func fch(how int, x *int) {
if how < 0 {
lprcat(" went down by one!")
(*x)--
} else {
lprcat(" went up by one!")
(*x)++
}
bottomline()
}
/*
a subroutine to raise or lower character levels
if x > 0 they are raised if x < 0 they are lowered
*/
func fntchange(how int) {
lprc('\n')
switch rnd(9) {
case 1:
lprcat("Your strength")
fch(how, &c[0])
case 2:
lprcat("Your intelligence")
fch(how, &c[1])
case 3:
lprcat("Your wisdom")
fch(how, &c[2])
case 4:
lprcat("Your constitution")
fch(how, &c[3])
case 5:
lprcat("Your dexterity")
fch(how, &c[4])
case 6:
lprcat("Your charm")
fch(how, &c[5])
case 7:
j := rnd(level + 1)
if how < 0 {
lprintf("You lose %d hit point", j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
losemhp(j)
} else {
lprintf("You gain %d hit point", j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
raisemhp(j)
}
bottomline()
case 8:
j := rnd(level + 1)
if how > 0 {
lprintf("You just gained %d spell", j)
raisemspells(j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
} else {
lprintf("You just lost %d spell", j)
losemspells(j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
}
bottomline()
case 9:
j := 5 * rnd((level+1)*(level+1))
if how < 0 {
lprintf("You just lost %d experience point", j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
loseexperience(j)
} else {
lprintf("You just gained %d experience point", j)
if j > 1 {
lprcat("s!")
} else {
lprc('!')
}
raiseexperience(j)
}
}
cursors()
}
func specify_object() {
cursors()
specify_obj_nocurs()
/* TODO
cursors()
lprcat("\n\nIdentify unknown object by cursor [yn]?")
switch ttgetch() {
case 'y', 'Y':
specify_obj_cursor()
case 'n', 'N':
specify_obj_nocurs()
}
*/
}
/* perform the actions of identifying the object/monster associated with a
character typed by the user. assumes cursors().
*/
func specify_obj_nocurs() {
lprcat("\nType object character:")
i := ttgetch()
switch i {
case '\033', '\n':
return
/*
case '@':
lprintf("\n@: %s", logname)
return
*/
case ' ':
lprintf("\n : An as-yet-unseen place in the dungeon, or the floor")
return
}
/*
if i == floorc {
lprc('\n')
lprc(floorc)
lprintf(": the floor of the dungeon")
return
}
*/
flag := false
for j := 0; j < MAXMONST+8; j++ {
if i == int(monstnamelist[j]) {
lprintf("\n%c: %s", i, monster[j].name)
flag = true
}
}
/* check for spurious object character */
if i != '_' {
for j, name := range objnamelist {
if i == int(name) {
lprc('\n')
if boldon {
setbold()
lprc(byte(i))
resetbold()
} else {
lprc(byte(i))
}
lprintf(": %s", objectname[j])
flag = true
}
}
}
if !flag {
lprintf("\n%c: unknown monster/object", i)
}
}
// TODO: port specify_obj_cursor/move_cursor