diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5a1a22b --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +ACTUAL_ENV=dev +DB_USER=root +DB_PASSWORD=password +DB_NAME=battleship +DB_HOST=localhost +COOKIE_SECRET_KEY=secret_key diff --git a/.gitignore b/.gitignore index dc2aa9e..9ab71ae 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ node_modules/ nginx.conf nginx/ secrets/ +.env +.env.* + +!.env.example \ No newline at end of file diff --git a/public/scripts/game.js b/public/scripts/game.js index 1a0db50..9ad7de8 100644 --- a/public/scripts/game.js +++ b/public/scripts/game.js @@ -213,6 +213,18 @@ function validMoove(player, piece, movement) { isValid = false; if (!p.vertical && movement.selectedCase.y + p.size > 10) isValid = false; + + let head = p.startPos + let tail = { x: (p.startPos.x + p.size), y: p.startPos.y} + + for (let x = head.x; x <= tail.x; x++) { + if ( + player.grid.cases[x][tail.y].isShip && + player.grid.cases[x][tail.y].piece.id !== p.id + ) { + isValid = false + } + } } } });