commit 81d83fd7bb46de5f36c9db0f95d8d2574ac49760
parent e4f3732dc5244c0eecbe181b3d41df196042ac77
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Sat, 17 Jun 2023 16:31:06 -0700
cleanup code
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pkg/web/handlers/interceptors/chess.go b/pkg/web/handlers/interceptors/chess.go
@@ -709,13 +709,16 @@ func (b *Chess) SendMove(gameKey string, userID database.UserID, g *ChessGame, c
promo = chess.Bishop
}
+ fst := selectedSquares[0]
+ scd := selectedSquares[1]
+
var moveStr string
validMoves := game.Position().ValidMoves()
var found bool
var mov chess.Move
for _, move := range validMoves {
- if (move.S1() == selectedSquares[0] && move.S2() == selectedSquares[1] && (move.Promo() == chess.NoPieceType || move.Promo() == promo)) ||
- (move.S1() == selectedSquares[1] && move.S2() == selectedSquares[0] && (move.Promo() == chess.NoPieceType || move.Promo() == promo)) {
+ if (move.S1() == fst && move.S2() == scd && (move.Promo() == chess.NoPieceType || move.Promo() == promo)) ||
+ (move.S1() == scd && move.S2() == fst && (move.Promo() == chess.NoPieceType || move.Promo() == promo)) {
moveStr = chess.AlgebraicNotation{}.Encode(game.Position(), move)
found = true
mov = *move
@@ -724,7 +727,7 @@ func (b *Chess) SendMove(gameKey string, userID database.UserID, g *ChessGame, c
}
if !found {
- return fmt.Errorf("invalid move %s %s", selectedSquares[0], selectedSquares[1])
+ return fmt.Errorf("invalid move %s %s", fst, scd)
}
//fmt.Println(moveStr)