* Copyright (c) 1988 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)score.c 5.5 (Berkeley) 6/1/90";
* This source herein may be modified and/or distributed by anybody who
* so desires, with the following restrictions:
* 1.) No portion of this notice shall be removed.
* 2.) Credit shall not be taken for the creation of this source.
* 3.) This code is not to be traded, sold, or used for personal
extern char login_name
[];
extern boolean score_only
, no_skull
, msg_cleared
;
extern char *byebye_string
, *nick_name
;
killed_by(monster
, other
)
rogue
.gold
= ((rogue
.gold
* 9) / 10);
(void) strcpy(buf
, "died of hypothermia");
(void) strcpy(buf
, "died of starvation");
(void) strcpy(buf
, "killed by a dart");
(void) strcpy(buf
, "quit");
(void) strcpy(buf
, "killed by fire");
(void) strcpy(buf
, "Killed by ");
if (is_vowel(m_names
[monster
->m_char
- 'A'][0])) {
(void) strcat(buf
, "an ");
(void) strcat(buf
, "a ");
(void) strcat(buf
, m_names
[monster
->m_char
- 'A']);
(void) strcat(buf
, " with ");
sprintf(buf
+strlen(buf
), "%ld gold", rogue
.gold
);
if ((!other
) && (!no_skull
)) {
mvaddstr(4, 32, "__---------__");
mvaddstr(5, 30, "_~ ~_");
mvaddstr(9, 27, "| XXXX XXXX |");
mvaddstr(10, 27, "| XXXX XXXX |");
mvaddstr(11, 27, "| XXX XXX |");
mvaddstr(12, 28, "\\ @ /");
mvaddstr(13, 29, "--\\ @@@ /--");
mvaddstr(14, 30, "| | @@@ | |");
mvaddstr(15, 30, "| | | |");
mvaddstr(16, 30, "| vvVvvvvvvvVvv |");
mvaddstr(17, 30, "| ^^^^^^^^^^^ |");
mvaddstr(18, 31, "\\_ _/");
mvaddstr(19, 33, "~---------~");
put_scores(monster
, other
);
unwield(rogue
.weapon
); /* disarm and relax */
un_put_on(rogue
.left_ring
);
un_put_on(rogue
.right_ring
);
mvaddstr(10, 11, "@ @ @@@ @ @ @ @ @ @@@ @ @ @");
mvaddstr(11, 11, " @ @ @ @ @ @ @ @ @ @ @ @@ @ @");
mvaddstr(12, 11, " @ @ @ @ @ @ @ @ @ @ @ @ @ @");
mvaddstr(13, 11, " @ @ @ @ @ @ @ @ @ @ @ @@");
mvaddstr(14, 11, " @ @@@ @@@ @@ @@ @@@ @ @ @");
mvaddstr(17, 11, "Congratulations, you have been admitted to the");
mvaddstr(18, 11, "Fighters' Guild. You return home, sell all your");
mvaddstr(19, 11, "treasures at great profit and retire into comfort.");
put_scores((object
*) 0, WIN
);
for (i
= 0; i
< DCOLS
; i
++) {
message("really quit?", 1);
for (i
= 0; i
< DCOLS
; i
++) {
killed_by((object
*) 0, QUIT
);
put_scores(monster
, other
)
short i
, n
, rank
= 10, x
, ne
= 0, found_player
= -1;
boolean pause
= score_only
;
if ( (fp
= fopen(_PATH_SCOREFILE
, "r+")) == NULL
&& (fp
= fopen(_PATH_SCOREFILE
, "w+")) == NULL
) {
message("cannot read/write/create score file", 0);
for (i
= 0; i
< 10; i
++) {
if (((n
= fread(scores
[i
], sizeof(char), 80, fp
)) < 80) && (n
!= 0)) {
if ((n
= fread(n_names
[i
], sizeof(char), 30, fp
)) < 30) {
if ((!score_only
) && (found_player
== -1)) {
if (!name_cmp(scores
[i
]+15, login_name
)) {
while (scores
[i
][x
] == ' ') {
s
= lget_number(scores
[i
] + x
);
if (found_player
!= -1) {
for (i
= found_player
; i
< ne
; i
++) {
(void) strcpy(scores
[i
], scores
[i
+1]);
(void) strcpy(n_names
[i
], n_names
[i
+1]);
for (i
= 0; i
< ne
; i
++) {
while (scores
[i
][x
] == ' ') {
s
= lget_number(scores
[i
] + x
);
} else if ((ne
< 10) && (rank
== 10)) {
insert_score(scores
, n_names
, nick_name
, rank
, ne
, monster
,
mvaddstr(3, 30, "Top Ten Rogueists");
mvaddstr(8, 0, "Rank Score Name");
for (i
= 0; i
< ne
; i
++) {
nickize(buf
, scores
[i
], n_names
[i
]);
fwrite(scores
[i
], sizeof(char), 80, fp
);
fwrite(n_names
[i
], sizeof(char), 30, fp
);
insert_score(scores
, n_names
, n_name
, rank
, n
, monster
, other
)
for (i
= n
; i
> rank
; i
--) {
if ((i
< 10) && (i
> 0)) {
(void) strcpy(scores
[i
], scores
[i
-1]);
(void) strcpy(n_names
[i
], n_names
[i
-1]);
sprintf(buf
, "%2d %6d %s: ", rank
+1, rogue
.gold
, login_name
);
(void) strcat(buf
, "died of hypothermia");
(void) strcat(buf
, "died of starvation");
(void) strcat(buf
, "killed by a dart");
(void) strcat(buf
, "quit");
(void) strcat(buf
, "a total winner");
(void) strcpy(buf
, "killed by fire");
(void) strcat(buf
, "killed by ");
if (is_vowel(m_names
[monster
->m_char
- 'A'][0])) {
(void) strcat(buf
, "an ");
(void) strcat(buf
, "a ");
(void) strcat(buf
, m_names
[monster
->m_char
- 'A']);
sprintf(buf
+strlen(buf
), " on level %d ", max_level
);
if ((other
!= WIN
) && has_amulet()) {
(void) strcat(buf
, "with amulet");
for (i
= strlen(buf
); i
< 79; i
++) {
(void) strcpy(scores
[rank
], buf
);
(void) strcpy(n_names
[rank
], n_name
);
obj
= rogue
.pack
.next_object
;
mvaddstr(1, 0, "Value Item");
if (obj
->what_is
!= FOOD
) {
sprintf(buf
, "%5d ", val
);
if (rogue
.gold
> MAX_GOLD
) {
val
= id_weapons
[wc
].value
;
if ((wc
== ARROW
) || (wc
== DAGGER
) || (wc
== SHURIKEN
) ||
val
+= (obj
->d_enchant
* 85);
val
+= (obj
->hit_enchant
* 85);
val
= id_armors
[wc
].value
;
val
+= (obj
->d_enchant
* 75);
val
= id_wands
[wc
].value
* (obj
->class + 1);
val
= id_scrolls
[wc
].value
* obj
->quantity
;
val
= id_potions
[wc
].value
* obj
->quantity
;
val
= id_rings
[wc
].value
* (obj
->class + 1);
for (i
= 0; i
< SCROLS
; i
++) {
id_scrolls
[i
].id_status
= IDENTIFIED
;
for (i
= 0; i
< WEAPONS
; i
++) {
id_weapons
[i
].id_status
= IDENTIFIED
;
for (i
= 0; i
< ARMORS
; i
++) {
id_armors
[i
].id_status
= IDENTIFIED
;
for (i
= 0; i
< WANDS
; i
++) {
id_wands
[i
].id_status
= IDENTIFIED
;
for (i
= 0; i
< POTIONS
; i
++) {
id_potions
[i
].id_status
= IDENTIFIED
;
for (i
= 0; i
< n
; i
++) {
/* It does not matter if accuracy is lost during this assignment */
c
= (unsigned char) xxx(0);
r
= ((f
* s
) + 9337) % 8887;
nickize(buf
, score
, n_name
)
char *buf
, *score
, *n_name
;
(void) strcpy(buf
, score
);
(void) strncpy(buf
, score
, 16);
while (score
[i
] != ':') {
(void) strcpy(buf
+15, n_name
);
margin
= ((DCOLS
- strlen(buf
)) / 2);
mvaddstr(row
, margin
, buf
);
clean_up("sorry, score file is out of order");