-
Notifications
You must be signed in to change notification settings - Fork 0
/
monrooms.pas
306 lines (275 loc) · 7.77 KB
/
monrooms.pas
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
[INHERIT ('MONCONST','MONTYPE','MONGLOBL')]
MODULE MonRooms(OUTPUT);
%include 'headers.txt'
(* ------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION LookupRoomName(S : String; VAR N : INTEGER;
Exact : BYTE_BOOL; Silent : Byte_Bool) : BYTE_BOOL;
VAR
nam : longnamerec;
good : byte_bool;
Ind : IndexRec;
found : byte_bool;
loop, maybe, poss : integer;
BEGIN
found := false;
loop := 0;
maybe := 0;
good := getlongname(l_na_roomnam, nam) and getindex(i_room, ind);
if (good) then
found := lookupnameraw(nam.idents, ind, n, s, exact);
if not(found) and not(silent) then
writeln('I could not find room ', S, '.');
lookuproomname := found;
END;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
FUNCTION OwnTrans(S : String) : String;
BEGIN
IF S = '' THEN
OwnTrans := '<public>'
ELSE
IF S = '*' THEN
OwnTrans := '<disowned>'
ELSE
OwnTrans := S;
END;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE PrintParticle(NamePrint : INTEGER; S : String ;
AllStats : AllMyStats;
Hiding : BYTE_BOOL := FALSE);
BEGIN
CASE NamePrint OF
0: ;
1: Write('You''re in ');
2: Write('You''re at ');
3: Write('You''re in the ');
4: Write('You''re at the ');
5: Write('You''re on ');
6: Write('You''re on the ');
OTHERWISE Writeln('Room name printing is damaged.');
END;
IF NamePrint <> 0 THEN
Write(S);
WITH AllStats.Stats DO
BEGIN
IF (Brief AND NOT Hiding AND NOT Privd) OR (Brief AND Hiding AND Privd)
OR (Brief AND Privd) THEN
PrintBriefExits;
(* ShowExits(AllStats.Exit.FoundExits, AllStats.MyHold, TRUE) *)
END;
WriteLn;
END;
(* ------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE PrintBriefExits;
VAR
i : INTEGER;
found : BYTE_BOOL := FALSE;
BEGIN
Write(' (');
FOR i := 1 to MaxExit DO
IF (HereDesc.Exits[i].ToLoc <> 0) AND (HereDesc.Exits[i].Hidden = 0)
AND (HereDesc.Exits[i].Alias = '') THEN
BEGIN
CASE HereDesc.Exits[i].Kind OF
1,3,4,5,7: BEGIN
Write(DirectShort[i]);
found := TRUE;
END;
END;
END;
IF NOT found THEN Write('none');
WriteLn(')');
END;
[GLOBAL]
PROCEDURE ExitDefault(Dir, Kind, Toloc : INTEGER; VAR Nam : LongNameRec);
VAR
RoomName : ShortString;
BEGIN
IF ((Toloc > 0) AND (ToLoc < MaxRoom)) THEN
RoomName := Nam.Idents[ToLoc]
ELSE
RoomName := 'faulty';
CASE Kind OF
2 : Writeln('There is a locked door leading ',Direct[dir],' to the ',roomname,'.');
5 : CASE Dir OF
north,
south,
east,
west : Writeln('A note on the ',direct[dir],' wall says "Your exit here."');
up : Writeln('A note on the ceiling says "Your exit here."');
down : Writeln('A note on the floor says "Your exit here."');
END;
OTHERWISE IF Dir < 5 THEN
Writeln('To the ',Direct[Dir],' is ',roomname,'.')
ELSE
Writeln('The ',roomname,' is ',direct[dir],' from here.');
END; (* CASE *)
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE ShowExits(VAR FoundExit : FoundExitType; VAR MyHold : HoldObj;
ShortHand : BYTE_BOOL := FALSE);
(* Routine called when a LOOK is done - or someone enters a new room *)
VAR
I : INTEGER;
One, CanSee : BYTE_BOOL;
Nam : LongNameRec;
BEGIN
One := FALSE;
IF ShortHand THEN Write(' [ ');
IF GetLongName(l_NA_RoomNam, Nam) THEN
BEGIN
FOR I := 1 TO MaxExit DO
BEGIN
IF (HereDesc.Exits[I].Toloc <> 0) OR (HereDesc.Exits[I].Kind = EK_ACCEPTOR) THEN
BEGIN
IF (HereDesc.Exits[I].Hidden = 0) OR (FoundExit[I]) THEN
CanSee := TRUE
ELSE
CanSee := FALSE;
IF HereDesc.Exits[I].Kind = EK_NEEDOBJECT THEN
BEGIN
IF ObjHold(HereDesc.Exits[I].ObjReq, MyHold) THEN
CanSee := TRUE
ELSE
CanSee := FALSE;
END;
IF CanSee THEN
BEGIN
IF (HereDesc.Exits[I].ExitDesc = DEFAULT_DESC) AND NOT ShortHand THEN
BEGIN
ExitDefault(I, HereDesc.Exits[I].Kind,
Heredesc.Exits[I].Toloc, Nam);
One := TRUE;
END
ELSE
IF HereDesc.Exits[I].ExitDesc <> 0 THEN
BEGIN
IF NOT ShortHand THEN
PrintDesc(HereDesc.Exits[I].ExitDesc)
ELSE
Write(UpCase(DirectShort[I]),' ');
One := TRUE;
END;
END;
END;
END;
IF ShortHand THEN Write(']');
IF One THEN Writeln;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE ListRooms(S : ShortString; Indx : IndexRec; Own : LongNameRec;
Nam : LongNameRec);
VAR
First : BYTE_BOOL;
I, J, Posit, NumRooms : INTEGER;
BEGIN
NumRooms := 0;
First := TRUE;
Posit := 0;
FOR I := 1 TO Indx.Top DO
BEGIN
IF (NOT Indx.free[I]) AND (Own.Idents[I] = S) THEN
BEGIN
Numrooms := NumRooms + 1;
IF Posit = 3 THEN
BEGIN
Posit := 0;
Writeln;
END
ELSE
Posit := Posit + 1;
IF First THEN
BEGIN
First := FALSE;
Writeln(OwnTrans(s),':');
END;
WriteNice(Nam.idents[i],20);
END;
END;
IF Posit <> 3 THEN
Writeln;
IF First THEN
Writeln('No rooms owned by ',OwnTrans(s))
ELSE
BEGIN
Writeln;
Writeln('Total rooms: ',NumRooms:0);
Writeln;
END;
END;
(* -------------------------------------------------------------------------- *)
PROCEDURE ListAllRooms(Indx : IndexRec; Own, Nam : LongNameRec);
VAR
I, J : INTEGER;
Tmp : PACKED ARRAY [1..MaxRoom] OF BYTE_BOOL;
BEGIN
Tmp := Zero;
ListRooms('', Indx, Own, Nam); { public rooms first }
ListRooms('*', Indx, Own, Nam); { disowned rooms next }
FOR I := 1 TO Indx.Top DO
BEGIN
IF NOT(Indx.Free[I]) AND NOT(Tmp[I]) and
(Own.Idents[I] <> '') AND (Own.Idents[I] <> '*') THEN
BEGIN
ListRooms(Own.Idents[I], Indx, Own, Nam); { player rooms }
FOR J := 1 to Indx.Top DO
IF Own.Idents[J] = Own.Idents[I] THEN
Tmp[J] := TRUE;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
[GLOBAL]
PROCEDURE DoRooms(S : String; VAR AllStats : AllMyStats);
VAR
Cmd : String;
Id : VeryShortString;
ListAll : BYTE_BOOL;
Indx : IndexRec;
Nam, Own : LongNameRec;
BEGIN
IF GetLongName(l_na_roomnam, Nam) THEN
BEGIN
IF GetLongName(l_na_roomown, Own) THEN
BEGIN
IF GetIndex(I_Room, Indx) THEN
BEGIN
ListAll := FALSE;
S := Lowcase(S);
Cmd := Bite(S);
IF Cmd = '' THEN Id := AllStats.Stats.UserId
ELSE
IF Cmd = 'public' THEN id := ''
ELSE
IF Cmd = 'disowned' THEN id := '*'
ELSE
IF Cmd = '<public>' THEN id := ''
ELSE
IF Cmd = '<disowned>' THEN id := '*'
ELSE
IF Cmd = '*' THEN ListAll := TRUE
ELSE
IF Length(Cmd) > VeryShortLen THEN
Id := SubStr(Cmd,1,VeryShortLen)
ELSE Id := Cmd;
IF ListAll THEN
IF AllStats.Stats.Privd THEN
ListAllRooms(Indx, Own, Nam)
ELSE Writeln('You may not obtain a list of all the rooms.')
ELSE
IF AllStats.Stats.Privd OR (AllStats.Stats.Userid = Id) OR
(Id = '') OR (Id = '*') THEN
ListRooms(Id, Indx, Own, Nam)
ELSE
Writeln('You may not list rooms that belong to another player.');
END;
END;
END;
END;
(* -------------------------------------------------------------------------- *)
END.