erynwells.me/layouts/partials/nethack/logentry.html
Eryn Wells d5296995de Get the nethack page looking good again
Update all the CSS classes and fix the layout so it looks good in the new theme.
Convert a bunch of CSS classes to BEM style.
2024-10-27 09:56:46 -06:00

72 lines
3 KiB
HTML

{{- $cause := .death.cause -}}
{{- $didAscend := eq $cause "ascended" -}}
{{- $level := (cond (gt .dungeon.level.n 0) (.dungeon.level.descriptive | lower) .dungeon.level.descriptive) -}}
<div class="nethack-logentry__marker">{{- if $didAscend -}}✨{{- else -}}🪦{{- end -}}</div>
<h4 class="nethack-logentry__date">{{ time.Format "January 2, 2006" .end_date }}</h4>
{{ with .character.descriptor -}}
<p class="nethack-logentry__character-descriptor">{{ . }}</p>
{{ end }}
<p class="nethack-logentry__description">
{{- $name := .character.name -}}
{{- $descriptiveAlignment := .character.alignment.descriptive | lower -}}
{{- $descriptiveRace := .character.race.descriptive | lower -}}
{{- $descriptiveRole := .character.role.descriptive -}}
{{- if $didAscend -}}
{{ $name }}, a {{ $descriptiveAlignment }} {{ $descriptiveRace }} {{ $descriptiveRole }}, ascended.
{{- else -}}
{{ $name }}, a {{ $descriptiveAlignment }} {{ $descriptiveRace }} {{ $descriptiveRole }}, died
{{ if gt .death.count 1 -}}for the last time{{- end }} in
<span class="nobreak">{{ .dungeon.name }}</span>
on <span class="nobreak">{{ $level }}</span>.
She was {{ .death.cause }}.
{{- end -}}
</p>
<table class="nethack-logentry__stats">
<thead>
<tr>
<td class="nethack-logentry__began">{{ i18n "nethackBegan" }}</td>
<td class="nethack-logentry__score">{{ i18n "nethackScore" }}</td>
<td class="nethack-logentry__level">
{{ if .dungeon.max_level }}
{{ i18n "nethackDungeonLevel" }}
{{ else }}
{{ i18n "nethackCharacterLevel" }}
{{ end }}
</td>
<td class="nethack-logentry__hp">{{ i18n "nethackHP" }}</td>
</tr>
</thead>
<tbody>
<tr>
<td class="nethack-logentry__began">
{{- $startDate := time.Format "2006-01-02" .start_date -}}
{{- $startDatetime := time.Format "2006-01-02" .start_date -}}
<time class="nobreak" datetime="{{ $startDatetime }}">{{ $startDate }}</time>
</td>
<td class="nethack-logentry__score">
{{- .score | lang.FormatNumber 0 -}}
</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="nethack-logentry__level">{{ .n }}</td>
{{ else -}}
{{ with .character.max_level -}}
<td class="nethack-logentry__level">{{ . }}</td>
{{ end }}
{{ end }}
<td class="nethack-logentry__hp">
{{- $hp := float .character.hp.n -}}
{{- $hpMax := .character.hp.max -}}
{{- if gt $hp 0 }}{{ $hp }} / {{ $hpMax }}{{ else }}{{ $hp }}{{ end }}
</td>
</tr>
</tbody>
</table>