commit a641956e9b11f6d07de0d89b412a35159bfbbd8e
parent ca5fcfa0933be2c480c13eea1643ffd9f6e3992a
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 12 Jun 2023 14:05:25 -0700
cleanup
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/pkg/web/handlers/handlers.go b/pkg/web/handlers/handlers.go
@@ -4998,7 +4998,7 @@ func ChessGameHandler(c echo.Context) error {
user2, _ := db.GetUserByID(30814)
interceptors.ChessInstance.NewGame(key, user1, user2)
g = interceptors.ChessInstance.GetGame(key)
- chessGameKingSideCastle(g)
+ chessGameEnPassant(g)
} else {
return c.Redirect(http.StatusFound, "/")
}
@@ -5111,7 +5111,7 @@ func ChessGameHandler(c echo.Context) error {
}
}(c, key, g.Player1.ID, g.Player2.ID)
- i := 0
+ var animationIdx int
Loop:
for {
select {
@@ -5145,9 +5145,10 @@ Loop:
y1 = 7 - y1
y2 = 7 - y2
}
- i++
- send(fmt.Sprintf(`<style>@keyframes move_anim_%d { from { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } to { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } }</style>`, i, x1, y1, x2, y2))
- send(fmt.Sprintf(`<style>#%s { animation-name: move_anim_%d; animation-duration: %dms; animation-fill-mode: forwards; }</style>`, id, i, animationMs))
+ animationIdx++
+ animationName := fmt.Sprintf("move_anim_%d", animationIdx)
+ send(fmt.Sprintf(`<style>@keyframes %s { from { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } to { left: calc(%d*12.5%%); top: calc(%d*12.5%%); } }</style>`, animationName, x1, y1, x2, y2))
+ send(fmt.Sprintf(`<style>#%s { animation-name: %s; animation-duration: %dms; animation-fill-mode: forwards; }</style>`, id, animationName, animationMs))
}
animate(payload.Move.S1(), payload.Move.S2(), payload.IDStr1)