commit 5e61521c6ef4598be2e2495a4177875e4fdbab0f
parent 21c8b9a724a0de6a79e821ffb4c19555290bfbd5
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 15 Jun 2023 00:24:56 -0700
cleanup
Diffstat:
2 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -688,7 +688,7 @@ Loop:
p := boardMap[sq]
styles.Appendf("#%s { display: block !important; "+
"left: calc(%d*12.5%%) !important; top: calc(%d*12.5%%) !important; "+
- "background-image: url(/public/img/chess/"+p.Color().String()+pieceTypeMap[p.Type()]+".png) !important; }",
+ "background-image: url(/public/img/chess/"+p.Color().String()+strings.ToUpper(p.Type().String())+".png) !important; }",
sqID, x1, y1)
}
}
@@ -792,12 +792,3 @@ Loop:
}
return nil
}
-
-var pieceTypeMap = map[chess.PieceType]string{
- chess.King: "K",
- chess.Queen: "Q",
- chess.Rook: "R",
- chess.Bishop: "B",
- chess.Knight: "N",
- chess.Pawn: "P",
-}
diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go
@@ -193,7 +193,7 @@ func (g *ChessGame) renderBoardHTML1(moveIdx int, position *chess.Position, isFl
return last != nil && (last.S1() == sq || last.S2() == sq)
}
getPieceFileName := func(p chess.Piece) string {
- return p.Color().String() + pieceTypeMap[p.Type()]
+ return p.Color().String() + strings.ToUpper(p.Type().String())
}
htmlTmpl := ChessCSS + `
@@ -324,15 +324,6 @@ func renderSquare(ctx *gg.Context, sq chess.Square, isFlipped bool) {
ctx.Pop()
}
-var pieceTypeMap = map[chess.PieceType]string{
- chess.King: "K",
- chess.Queen: "Q",
- chess.Rook: "R",
- chess.Bishop: "B",
- chess.Knight: "N",
- chess.Pawn: "P",
-}
-
func (g *ChessGame) renderBoardHTML(moveIdx int, isFlipped bool, imgB64 string, bestMove *chess.Move) string {
position := g.Game.Position()
if moveIdx != 0 && moveIdx < len(g.Game.Positions()) {