Update Nethack partials, shortcodes, and page to properly handle ascensions 😁
This commit is contained in:
parent
d1df92aa03
commit
42a71c1ac3
7 changed files with 59 additions and 36 deletions
6
layouts/partials/nethack/log.html
Normal file
6
layouts/partials/nethack/log.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{{ $nethack_data := $.Site.Data.nethack.logfile }}
|
||||
{{ $logfile := slice }}
|
||||
{{ range $nethack_data }}
|
||||
{{ $logfile = $logfile | append .logfile }}
|
||||
{{ end }}
|
||||
{{ return $logfile }}
|
||||
|
|
@ -1,12 +1,24 @@
|
|||
{{ $level := (cond (gt .dungeon.level.n 0) (.dungeon.level.descriptive | lower) .dungeon.level.descriptive) }}
|
||||
<div>{{ if .death.cause }}🪦{{ end }}</div>
|
||||
{{- $cause := .death.cause -}}
|
||||
{{- $didAscend := eq $cause "ascended" -}}
|
||||
{{- $level := (cond (gt .dungeon.level.n 0) (.dungeon.level.descriptive | lower) .dungeon.level.descriptive) -}}
|
||||
<div>{{- if $didAscend -}}✨{{- else -}}🪦{{- end -}}</div>
|
||||
<h4 class="date">{{ time.Format "January 2, 2006" .end_date }}</h4>
|
||||
<div class="character-descriptor">{{ .character.abbreviated }}</div>
|
||||
<p>{{ .character.name }}, a {{ .character.alignment.descriptive | lower }} {{ .character.race.descriptive | lower }}
|
||||
{{ .character.gender.descriptive | lower }} {{ .character.role.descriptive }},
|
||||
died {{ if gt .death.count 1 }}for the last time{{ end }} in <span class="nobreak">{{ .dungeon.name }}</span>
|
||||
<p>
|
||||
{{- $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 }}.</p>
|
||||
She was {{ .death.cause }}.
|
||||
{{- end -}}
|
||||
</p>
|
||||
<table class="stats">
|
||||
<tr>
|
||||
{{- $startDate := time.Format "January, 02 2006" .start_date -}}
|
||||
|
|
@ -27,7 +39,10 @@
|
|||
{{ 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)
|
||||
.character.hp.max }} hp</td>
|
||||
<td class="hp">
|
||||
{{- $hp := float .character.hp.n -}}
|
||||
{{- $hpMax := .character.hp.max -}}
|
||||
{{- if gt $hp 0 }}{{ $hp }} / {{ $hpMax }}{{ else }}{{ $hp }}{{ end }} hp
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
|||
3
layouts/shortcodes/nethack/ascensions.html
Normal file
3
layouts/shortcodes/nethack/ascensions.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{{- $logfile := partial "nethack/log.html" . -}}
|
||||
{{- $numberOfAscensions := where $logfile "death.cause" "ascended" | len -}}
|
||||
{{- $numberOfAscensions | lang.FormatNumber 0 -}}
|
||||
|
|
@ -1,8 +1,4 @@
|
|||
{{ $nethack_data := $.Site.Data.nethack.logfile }}
|
||||
{{ $logfile := slice }}
|
||||
{{ range $nethack_data }}
|
||||
{{ $logfile = $logfile | append .logfile }}
|
||||
{{ end }}
|
||||
{{- $logfile := partial "nethack/log.html" . -}}
|
||||
<ol class="logfile">
|
||||
{{ range sort $logfile "end_date" "desc" }}
|
||||
{{ if ne .death.cause "quit" }}
|
||||
|
|
|
|||
2
layouts/shortcodes/nethack/n.html
Normal file
2
layouts/shortcodes/nethack/n.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{{- $numberOfEntries := (partial "nethack/log.html" .) | len -}}
|
||||
{{- $numberOfEntries | lang.FormatNumber 0 -}}
|
||||
7
layouts/shortcodes/nethack/topn.html
Normal file
7
layouts/shortcodes/nethack/topn.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{{- $n := .Get 0 -}}
|
||||
{{- $logfile := partial "nethack/log.html" . -}}
|
||||
<ol class="logfile topn">
|
||||
{{ range first $n (sort $logfile "score" "desc") -}}
|
||||
<li>{{ partial "nethack/logentry.html" . }}</li>
|
||||
{{- end }}
|
||||
</ol>
|
||||
Loading…
Add table
Add a link
Reference in a new issue