commit 074be8226b0cc198a623115a51402ee56daad519
parent 5a35ecfd0caacb7c5e191a7e520c052ad983e04f
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Fri, 16 Jun 2023 23:12:42 -0700
cleanup
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/pkg/web/handlers/chess.go b/pkg/web/handlers/chess.go
@@ -738,17 +738,18 @@ Loop:
}
// Animate rook during castle
+ animateRookFn := animate
if payload.Move.HasTag(chess.KingSideCastle) {
if payload.Move.S1() == chess.E1 {
- animate(chess.H1, chess.F1, interceptors.WhiteKingSideRookID, isFlipped, &animationIdx, &styles)
+ animateRookFn(chess.H1, chess.F1, interceptors.WhiteKingSideRookID, isFlipped, &animationIdx, &styles)
} else if payload.Move.S1() == chess.E8 {
- animate(chess.H8, chess.F8, interceptors.BlackKingSideRookID, isFlipped, &animationIdx, &styles)
+ animateRookFn(chess.H8, chess.F8, interceptors.BlackKingSideRookID, isFlipped, &animationIdx, &styles)
}
} else if payload.Move.HasTag(chess.QueenSideCastle) {
if payload.Move.S1() == chess.E1 {
- animate(chess.A1, chess.D1, interceptors.WhiteQueenSideRookID, isFlipped, &animationIdx, &styles)
+ animateRookFn(chess.A1, chess.D1, interceptors.WhiteQueenSideRookID, isFlipped, &animationIdx, &styles)
} else if payload.Move.S1() == chess.E8 {
- animate(chess.A8, chess.D8, interceptors.BlackQueenSideRookID, isFlipped, &animationIdx, &styles)
+ animateRookFn(chess.A8, chess.D8, interceptors.BlackQueenSideRookID, isFlipped, &animationIdx, &styles)
}
}
// En passant
@@ -767,7 +768,8 @@ Loop:
return nil
}
-func renderShowVisiblePieceInPosition(styles *StylesBuilder, animationIdx *int, visiblePieces map[chess.Square]struct{}, squareMap map[chess.Square]chess.Piece, piecesCache map[chess.Square]string, piecesCache1 map[string]chess.Square, isFlipped bool) {
+func renderShowVisiblePieceInPosition(styles *StylesBuilder, animationIdx *int, visiblePieces map[chess.Square]struct{},
+ squareMap map[chess.Square]chess.Piece, piecesCache map[chess.Square]string, piecesCache1 map[string]chess.Square, isFlipped bool) {
for newSq := range visiblePieces {
sqID := piecesCache[newSq] // Get ID of piece on square newSq
currentSq := piecesCache1[sqID] // Get current square location of the piece