Max level in the Nethack logfile is actually the max dungeon level, not the max character level

This commit is contained in:
Eryn Wells 2022-12-05 08:14:39 -08:00
parent d88d34a00a
commit 2a4838e8a3
2 changed files with 22 additions and 3 deletions

View file

@ -13,7 +13,20 @@
{{- $startDatetime := time.Format "2006-01-02" .start_date -}} {{- $startDatetime := time.Format "2006-01-02" .start_date -}}
<td class="began">Began <time class="nobreak" datetime="{{ $startDatetime }}">{{ $startDate }}</time></td> <td class="began">Began <time class="nobreak" datetime="{{ $startDatetime }}">{{ $startDate }}</time></td>
<td class="score">{{ .score | lang.FormatNumber 0 }} points</td> <td class="score">{{ .score | lang.FormatNumber 0 }} points</td>
<td class="level">Level {{ .character.max_level }}</td> {{/*
When I first wrote the importer script, I read about the log file
format on the Nethackwiki. It labeled a field as "maximum level",
which I interpreted as maximum character level. Turns out it's
actually maximum *dungeon* level. The script has been updated, but I
won't be able to update all the imported logfiles.
https://nethackwiki.com/wiki/Logfile
*/}}
{{ with .dungeon.max_level }}
<td class="level">{{ .descriptive }}</td>
{{ else }}
{{ with .character.max_level }}<td class="level">Level {{ . }}</td>{{ end }}
{{ end }}
<td class="hp">{{ cond (gt .character.hp.n 0) (printf "%s / %s" .character.hp.n .character.hp.max) <td class="hp">{{ cond (gt .character.hp.n 0) (printf "%s / %s" .character.hp.n .character.hp.max)
.character.hp.max }} hp</td> .character.hp.max }} hp</td>
</tr> </tr>

View file

@ -24,7 +24,7 @@ DUNGEONS = {
3: 'The Quest', 3: 'The Quest',
4: 'Sokoban', 4: 'Sokoban',
5: 'Fort Ludios', 5: 'Fort Ludios',
6: "Vlad's Tower", 6: 'Vlads Tower',
7: 'The Elemental Planes', 7: 'The Elemental Planes',
} }
@ -97,6 +97,12 @@ def main(argv):
else: else:
dungeon_level_descriptive = SPECIAL_DUNGEON_LEVELS[dungeon_level] dungeon_level_descriptive = SPECIAL_DUNGEON_LEVELS[dungeon_level]
max_dungeon_level = int(fields[4])
if max_dungeon_level > 0:
max_dungeon_level_descriptive = f"Level {max_dungeon_level}"
else:
max_dungeon_level_descriptive = SPECIAL_DUNGEON_LEVELS[max_dungeon_level]
start_date = datetime.datetime.strptime(fields[9], '%Y%m%d').strftime('%Y-%m-%d') start_date = datetime.datetime.strptime(fields[9], '%Y%m%d').strftime('%Y-%m-%d')
end_date = datetime.datetime.strptime(fields[8], '%Y%m%d').strftime('%Y-%m-%d') end_date = datetime.datetime.strptime(fields[8], '%Y%m%d').strftime('%Y-%m-%d')
@ -112,13 +118,13 @@ def main(argv):
'n': int(fields[2]), 'n': int(fields[2]),
'name': dungeon_name, 'name': dungeon_name,
'level': {'n': dungeon_level, 'descriptive': dungeon_level_descriptive}, 'level': {'n': dungeon_level, 'descriptive': dungeon_level_descriptive},
'max_level': {'n': max_dungeon_level, 'descriptive': max_dungeon_level_descriptive},
}, },
'end_date': end_date, 'end_date': end_date,
'start_date': start_date, 'start_date': start_date,
'character': { 'character': {
'name': name, 'name': name,
'descriptor': f'{name}-{role}-{race}-{gender}-{alignment}', 'descriptor': f'{name}-{role}-{race}-{gender}-{alignment}',
'max_level': int(fields[4]),
'hp': {'n': int(fields[5]), 'max': int(fields[6])}, 'hp': {'n': int(fields[5]), 'max': int(fields[6])},
'role': {'short': role, 'descriptive': ROLES[role]}, 'role': {'short': role, 'descriptive': ROLES[role]},
'race': {'short': race, 'descriptive': RACES[race]}, 'race': {'short': race, 'descriptive': RACES[race]},