Mercurial > hg > early-roguelike
comparison arogue7/rip.c @ 130:1a64fd0bfea6
arogue7: record completed games in a logfile.
author | John "Elwin" Edwards |
---|---|
date | Tue, 12 May 2015 09:55:05 -0400 |
parents | b786053d2f37 |
children | 7faf4568c295 |
comparison
equal
deleted
inserted
replaced
129:9c4e50b5825c | 130:1a64fd0bfea6 |
---|---|
14 | 14 |
15 /* Print flags for scoring */ | 15 /* Print flags for scoring */ |
16 #define REALLIFE 1 /* Print out machine and logname */ | 16 #define REALLIFE 1 /* Print out machine and logname */ |
17 #define EDITSCORE 2 /* Edit the current score file */ | 17 #define EDITSCORE 2 /* Edit the current score file */ |
18 #define ADDSCORE 3 /* Add a new score */ | 18 #define ADDSCORE 3 /* Add a new score */ |
19 | |
20 #define LOGFILE "arogue7.log" | |
19 | 21 |
20 #define NAMELEN 80 | 22 #define NAMELEN 80 |
21 | 23 |
22 /* | 24 /* |
23 * File for the fun ends | 25 * File for the fun ends |
136 killer = killname(monst); | 138 killer = killname(monst); |
137 mvaddstr(17, 28-((strlen(killer)+1)/2), killer); | 139 mvaddstr(17, 28-((strlen(killer)+1)/2), killer); |
138 mvaddstr(18, 26, (sprintf(prbuf, "%4d", 1900+lt->tm_year), prbuf)); | 140 mvaddstr(18, 26, (sprintf(prbuf, "%4d", 1900+lt->tm_year), prbuf)); |
139 move(lines-1, 0); | 141 move(lines-1, 0); |
140 refresh(); | 142 refresh(); |
143 writelog(pstats.s_exp, KILLED, monst); | |
141 score(pstats.s_exp, KILLED, monst); | 144 score(pstats.s_exp, KILLED, monst); |
142 endwin(); | 145 endwin(); |
143 #ifdef PC7300 | 146 #ifdef PC7300 |
144 endhardwin(); | 147 endhardwin(); |
145 #endif | 148 #endif |
197 if (i >= DEATHNUM) | 200 if (i >= DEATHNUM) |
198 return ("strange death"); | 201 return ("strange death"); |
199 return (deaths[i].name); | 202 return (deaths[i].name); |
200 } | 203 } |
201 | 204 |
202 | 205 /* Writes an entry in the log file */ |
206 | |
207 void | |
208 writelog(unsigned long amount, int flags, short monst) | |
209 { | |
210 FILE *logwriter; | |
211 char had_quest = '0'; | |
212 char fate[LINELEN]; | |
213 struct linked_list *item; | |
214 struct object *obj; | |
215 #ifdef LOGFILE | |
216 if (waswizard) | |
217 return; | |
218 /* Check for quest item */ | |
219 for (item = pack; item != NULL; item = next(item)) { | |
220 obj = OBJPTR(item); | |
221 if (obj->o_type == RELIC && obj->o_which == quest_item) | |
222 had_quest = '1'; | |
223 } | |
224 /* Describe what happened */ | |
225 if (flags == KILLED) { | |
226 snprintf(fate, LINELEN, "killed by %s", killname(monst)); | |
227 } | |
228 else if (flags == CHICKEN) { | |
229 strcpy(fate, "quit"); | |
230 } | |
231 else if (flags == WINNER) { | |
232 strcpy(fate, "escaped"); | |
233 } | |
234 else | |
235 return; | |
236 /* Open and write */ | |
237 logwriter = fopen(LOGFILE, "a"); | |
238 if (logwriter == NULL) | |
239 return; | |
240 fprintf(logwriter, "%d %d %s %d %s %d %d %d %c %s\n", time(NULL), amount, | |
241 whoami, pstats.s_lvl, char_class[char_type].name, level, max_level, | |
242 quest_item, had_quest, fate); | |
243 fclose(logwriter); | |
244 #endif | |
245 return; | |
246 } | |
247 | |
203 /* | 248 /* |
204 * score -- figure score and post it. | 249 * score -- figure score and post it. |
205 */ | 250 */ |
206 | 251 |
207 /* VARARGS2 */ | 252 /* VARARGS2 */ |
821 mvprintw(c - 'a' + 1, 0, "%c) %6d %s", c, worth, inv_name(obj, FALSE)); | 866 mvprintw(c - 'a' + 1, 0, "%c) %6d %s", c, worth, inv_name(obj, FALSE)); |
822 purse += worth; | 867 purse += worth; |
823 } | 868 } |
824 mvprintw(c - 'a' + 1, 0," %5d Gold Pieces ", oldpurse); | 869 mvprintw(c - 'a' + 1, 0," %5d Gold Pieces ", oldpurse); |
825 refresh(); | 870 refresh(); |
871 writelog(pstats.s_exp + (long) purse, WINNER, '\0'); | |
826 score(pstats.s_exp + (long) purse, WINNER, '\0'); | 872 score(pstats.s_exp + (long) purse, WINNER, '\0'); |
827 endwin(); | 873 endwin(); |
828 #ifdef PC7300 | 874 #ifdef PC7300 |
829 endhardwin(); | 875 endhardwin(); |
830 #endif | 876 #endif |