dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit c2ea4d9c12e9143152b4605a6d98a0b7058d77c4
parent 1b75ddb4a0f09d5cf3a9b1a34105658719c186d0
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Wed, 14 Jun 2023 11:40:59 -0700

fix move

Diffstat:
Mpkg/web/handlers/interceptors/chess.go | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go @@ -425,7 +425,7 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, <table class="graph"> <tr class="first-row"> {{ range $idx, $el := .Stats.Scores }} - <td title="Move: {{ $idx }} | Advantage: {{ if not $el.Mate }}{{ $el.CP | cp }}{{ else }}#{{ $el.Mate }}{{ end }}"> + <td title="{{ $idx | fmtMove }} | Advantage: {{ if not $el.Mate }}{{ $el.CP | cp }}{{ else }}#{{ $el.Mate }}{{ end }}"> {{ if ge .CP 0 }} <div class="column" style="height: {{ $el | renderCP "white" }}px; background-color: #eee;"></div> {{ end }} @@ -434,7 +434,7 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, </tr> <tr class="second-row"> {{ range $idx, $el := .Stats.Scores }} - <td title="Move: {{ $idx }} | Advantage: {{ if not $el.Mate }}{{ $el.CP | cp }}{{ else }}#{{ $el.Mate }}{{ end }}"> + <td title="{{ $idx | fmtMove }} | Advantage: {{ if not $el.Mate }}{{ $el.CP | cp }}{{ else }}#{{ $el.Mate }}{{ end }}"> {{ if le .CP 0 }} <div class="column" style="height: {{ $el | renderCP "black" }}px; background-color: #111;"></div> {{ end }} @@ -497,6 +497,13 @@ func (g *ChessGame) drawPlayerCard(key string, isBlack, isSpectator, isYourTurn, "cp": func(v int) string { return fmt.Sprintf("%.2f", float64(v)/100) }, + "fmtMove": func(idx int) string { + idx += 2 + if idx%2 == 0 { + return fmt.Sprintf("%d.", idx/2) + } + return fmt.Sprintf("%d...", idx/2) + }, "renderCP": func(color string, v Score) int { const maxH = 120 // Max graph height const maxV = 1200 // Max cp value. Anything bigger should take 100% of graph height space.