From e09ec0ce0fcb800b244c971580a7ca63c2bbda21 Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 27 Oct 2023 11:23:13 +0200 Subject: [PATCH] refactoring --- chess/free_squares.go | 1 - chess/game.go | 4 ++-- chess/rook_test.go | 2 +- main.go | 2 +- utils/passphrase.go | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/chess/free_squares.go b/chess/free_squares.go index 9d2b4b8..c654ce2 100644 --- a/chess/free_squares.go +++ b/chess/free_squares.go @@ -12,7 +12,6 @@ func (b *Board) GetNonBlockedRowAndColumn(fromSquare types.Coordinate) []types.C nonBlocked = append(nonBlocked, b.getNonBlockedConsecutive(squaresRight, fromSquare)...) nonBlocked = append(nonBlocked, b.getNonBlockedConsecutive(squaresAbove, fromSquare)...) nonBlocked = append(nonBlocked, b.getNonBlockedConsecutive(squaresBelow, fromSquare)...) - return nonBlocked } diff --git a/chess/game.go b/chess/game.go index 481c724..f99a8c5 100644 --- a/chess/game.go +++ b/chess/game.go @@ -63,10 +63,10 @@ func (game *Game) prepare() { func (game *Game) Handle() { defer game.killGame() - game.prepare() + game.prepare() var receivedMove types.Move - var err error + var err error for { switch game.gameState { diff --git a/chess/rook_test.go b/chess/rook_test.go index 0cf6766..7189a91 100644 --- a/chess/rook_test.go +++ b/chess/rook_test.go @@ -18,7 +18,7 @@ func Test_Rook_GetNonBlockedSquares(t *testing.T) { assert.Len(t, squares, 14) }) - t.Run("free row and column", func(t *testing.T) { + t.Run("blocked row and column", func(t *testing.T) { board := newBoard() rook := Rook{Color: types.Black} rookCoordinate := types.Coordinate{Col: 5, Row: 5} diff --git a/main.go b/main.go index 43399ce..9ed2096 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func hostPrivateGame(c *gin.Context) { u := usher.GetUsher() mut.Lock() - defer mut.Unlock() + defer mut.Unlock() lobby := u.CreateNewPrivateLobby(player) u.AddPlayerToLobbyAndStartGameIfFull(player, lobby) diff --git a/utils/passphrase.go b/utils/passphrase.go index afb788b..4f54306 100644 --- a/utils/passphrase.go +++ b/utils/passphrase.go @@ -12,7 +12,7 @@ func NewPassphrase() Passphrase { var phrase string var retries int var word string - var words int = 2 + var words = 2 //TODO make sure passphrases are unique for words > 0 { retries = 20