]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - rogue/message.c
1 /* $NetBSD: message.c,v 1.5 1995/04/22 10:27:43 cgd Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 static char sccsid
[] = "@(#)message.c 8.1 (Berkeley) 5/31/93";
43 static char rcsid
[] = "$NetBSD: message.c,v 1.5 1995/04/22 10:27:43 cgd Exp $";
50 * This source herein may be modified and/or distributed by anybody who
51 * so desires, with the following restrictions:
52 * 1.) No portion of this notice shall be removed.
53 * 2.) Credit shall not be taken for the creation of this source.
54 * 3.) This code is not to be traded, sold, or used for personal
64 char msgs
[NMESSAGES
][DCOLS
] = {"", "", "", "", ""};
65 short msg_col
= 0, imsg
= -1;
66 boolean msg_cleared
= 1, rmsg
= 0;
67 char hunger_str
[8] = "";
68 char *more
= "-more-";
70 extern boolean cant_int
, did_int
, interrupted
, save_is_interactive
;
71 extern short add_strength
;
72 extern short cur_level
;
80 if (!save_is_interactive
) {
89 mvaddstr(MIN_ROW
-1, msg_col
, more
);
95 imsg
= (imsg
+ 1) % NMESSAGES
;
96 (void) strcpy(msgs
[imsg
], msg
);
98 mvaddstr(MIN_ROW
-1, 0, msg
);
102 msg_col
= strlen(msg
);
121 message(msgs
[((imsg
- c
) % NMESSAGES
)], 0);
123 move(rogue
.row
, rogue
.col
);
139 get_input_line(prompt
, insert
, buf
, if_cancelled
, add_blank
, do_echo
)
140 char *prompt
, *buf
, *insert
;
152 mvaddstr(0, n
+ 1, insert
);
153 (void) strcpy(buf
, insert
);
155 move(0, (n
+ i
+ 1));
159 while (((ch
= rgetchar()) != '\r') && (ch
!= '\n') && (ch
!= CANCEL
)) {
160 if ((ch
>= ' ') && (ch
<= '~') && (i
< MAX_TITLE_LENGTH
-2)) {
161 if ((ch
!= ' ') || (i
> 0)) {
168 if ((ch
== '\b') && (i
> 0)) {
170 mvaddch(0, i
+ n
, ' ');
171 move(MIN_ROW
-1, i
+n
);
181 while ((i
> 0) && (buf
[i
-1] == ' ')) {
188 if ((ch
== CANCEL
) || (i
== 0) || ((i
== 1) && add_blank
)) {
190 message(if_cancelled
, 0);
224 Level: 99 Gold: 999999 Hp: 999(999) Str: 99(99) Arm: 99 Exp: 21/10000000 Hungry
225 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5
228 print_stats(stat_mask
)
235 label
= (stat_mask
& STAT_LABEL
) ? 1 : 0;
237 if (stat_mask
& STAT_LEVEL
) {
239 mvaddstr(row
, 0, "Level: ");
241 /* max level taken care of in make_level() */
242 sprintf(buf
, "%d", cur_level
);
243 mvaddstr(row
, 7, buf
);
246 if (stat_mask
& STAT_GOLD
) {
248 mvaddstr(row
, 10, "Gold: ");
250 if (rogue
.gold
> MAX_GOLD
) {
251 rogue
.gold
= MAX_GOLD
;
253 sprintf(buf
, "%ld", rogue
.gold
);
254 mvaddstr(row
, 16, buf
);
257 if (stat_mask
& STAT_HP
) {
259 mvaddstr(row
, 23, "Hp: ");
261 if (rogue
.hp_max
> MAX_HP
) {
262 rogue
.hp_current
-= (rogue
.hp_max
- MAX_HP
);
263 rogue
.hp_max
= MAX_HP
;
265 sprintf(buf
, "%d(%d)", rogue
.hp_current
, rogue
.hp_max
);
266 mvaddstr(row
, 27, buf
);
269 if (stat_mask
& STAT_STRENGTH
) {
271 mvaddstr(row
, 36, "Str: ");
273 if (rogue
.str_max
> MAX_STRENGTH
) {
274 rogue
.str_current
-= (rogue
.str_max
- MAX_STRENGTH
);
275 rogue
.str_max
= MAX_STRENGTH
;
277 sprintf(buf
, "%d(%d)", (rogue
.str_current
+ add_strength
),
279 mvaddstr(row
, 41, buf
);
282 if (stat_mask
& STAT_ARMOR
) {
284 mvaddstr(row
, 48, "Arm: ");
286 if (rogue
.armor
&& (rogue
.armor
->d_enchant
> MAX_ARMOR
)) {
287 rogue
.armor
->d_enchant
= MAX_ARMOR
;
289 sprintf(buf
, "%d", get_armor_class(rogue
.armor
));
290 mvaddstr(row
, 53, buf
);
293 if (stat_mask
& STAT_EXP
) {
295 mvaddstr(row
, 56, "Exp: ");
297 if (rogue
.exp_points
> MAX_EXP
) {
298 rogue
.exp_points
= MAX_EXP
;
300 if (rogue
.exp
> MAX_EXP_LEVEL
) {
301 rogue
.exp
= MAX_EXP_LEVEL
;
303 sprintf(buf
, "%d/%ld", rogue
.exp
, rogue
.exp_points
);
304 mvaddstr(row
, 61, buf
);
307 if (stat_mask
& STAT_HUNGER
) {
308 mvaddstr(row
, 73, hunger_str
);
320 for (i
= strlen(s
); i
< n
; i
++) {
330 boolean found_non_blank
;
332 if ((fp
= fopen("rogue.screen", "w")) != NULL
) {
333 for (i
= 0; i
< DROWS
; i
++) {
335 for (j
= (DCOLS
- 1); j
>= 0; j
--) {
336 buf
[j
] = mvinch(i
, j
);
337 if (!found_non_blank
) {
338 if ((buf
[j
] != ' ') || (j
== 0)) {
339 buf
[j
+ ((j
== 0) ? 0 : 1)] = 0;
363 return((ch
>= '0') && (ch
<= '9'));
366 r_index(str
, ch
, last
)
374 for (i
= strlen(str
) - 1; i
>= 0; i
--) {
380 for (i
= 0; str
[i
]; i
++) {