commit 235173f59476923e5483c72d4cb9576c48fbbe61
parent 3c4495c0508af9f35c8e8dc9e084318989f10332
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Thu, 15 Jun 2023 19:49:26 -0700
simplify code
Diffstat:
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -861,8 +861,6 @@ func renderShowVisiblePieceInPosition(styles *StylesBuilder, animationIdx *int,
x1, y1 := squareCoord(s1, isFlipped)
x2, y2 := squareCoord(s2, isFlipped)
*animationIdx++
- styles.Appendf("#%s { display: block !important; "+
- "background-image: url(/public/img/chess/"+p.Color().String()+strings.ToUpper(p.Type().String())+".png) !important; }", id)
animationName := fmt.Sprintf("move_anim_%d", *animationIdx)
keyframes := "@keyframes %s {" +
"from { left: calc(%d*12.5%%); top: calc(%d*12.5%%); }" +
@@ -872,9 +870,11 @@ func renderShowVisiblePieceInPosition(styles *StylesBuilder, animationIdx *int,
}
for newSq := range visiblePieces {
- sqID := piecesCache[newSq] // Get ID of piece on square newSq
- currentSq := piecesCache1[sqID] // Get current square location of the piece
- piece := squareMap[newSq] // Get the piece currently on the new square according to game data
+ sqID := piecesCache[newSq] // Get ID of piece on square newSq
+ currentSq := piecesCache1[sqID] // Get current square location of the piece
+ piece := squareMap[newSq] // Get the piece currently on the new square according to game data
+ styles.Appendf("#%s { display: block !important; "+
+ "background-image: url(/public/img/chess/"+piece.Color().String()+strings.ToUpper(piece.Type().String())+".png) !important; }", sqID)
animate(currentSq, newSq, sqID, piece) // Move piece from current square to the new square where we want it to be
piecesCache1[sqID] = newSq // Update cache of location of the piece
}