diff options
author | IgrisBRC <[email protected]> | 2024-07-13 11:38:32 +0530 |
---|---|---|
committer | IgrisBRC <[email protected]> | 2024-07-13 11:38:32 +0530 |
commit | 5edc39fcc24d95a7c52e69da49b3853c6d969f4a (patch) | |
tree | 6d18901d28e7fd36206c33cc72e6fb4d13862ebe | |
parent | 6355b9725ac4e18f8001ff7c9be73e8f78fd1d31 (diff) |
refactored the project
-rw-r--r-- | game.js | 38 | ||||
-rw-r--r-- | package.json | 7 | ||||
-rw-r--r-- | public/app.js (renamed from app.js) | 7 | ||||
-rw-r--r-- | public/game.js | 13 | ||||
-rw-r--r-- | public/index.css (renamed from index.css) | 0 | ||||
-rw-r--r-- | public/index.html (renamed from index.html) | 3 | ||||
-rw-r--r-- | server.js | 17 |
7 files changed, 40 insertions, 45 deletions
diff --git a/game.js b/game.js deleted file mode 100644 index 73519bc..0000000 --- a/game.js +++ /dev/null @@ -1,38 +0,0 @@ -import { move } from "./app.js" - -//const alphabet = 'abcdefgh' -//let squares = document.getElementsByClassName("square") - -let board = [ - [0, 0, 0, 0, 0, 0, 0, 0], - [-6, -6, -6, -6, -6, -6, -6, -6], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [6, 6, 6, 6, 6, 6, 6, 6], - [0, 0, 0, 0, 0, 0, 0, 0], -] - -console.log(move(board, 1, 0)) - -//for (let i = 0; i < 8; i++) { -// for (let j = 0; j < 8; j++) { -// let square = document.getElementById(`${alphabet.charAt(j)}${i + 1}`) -// let piece = document.createElement("p") -// -// switch (board[i][j]) { -// case 1: -// piece.classList.add("wp") -// square.append(piece) -// piece.append("p") -// break -// case -1: -// piece.classList.add("bp") -// square.append(piece) -// piece.append("p") -// break -// } -// } -//} - diff --git a/package.json b/package.json index 15058b1..e2871a9 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,15 @@ "name": "chess", "version": "1.0.0", "main": "index.js", - "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", - "description": "" + "description": "", + "dependencies": { + "dotenv": "^16.4.5", + "express": "^4.19.2" + } } @@ -1,16 +1,16 @@ let board = [ - [0, 0, 0, 0, 0, 0, 0, 0], + [-3, -5, -4, -2, -1, -4, -5, -3], [-6, -6, -6, -6, -6, -6, -6, -6], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [6, 6, 6, 6, 6, 6, 6, 6], - [0, 0, 0, 0, 0, 0, 0, 0], + [3, 5, 4, 2, 1, 4, 5, 3], ] -console.log(move(board, 1, 0)) +//console.log(move(board, 1, 0)) //move(board, 3, 3) function move(board, y, x) { @@ -363,4 +363,3 @@ function amelia_move(board, y, x) { return moves } -export { move } diff --git a/public/game.js b/public/game.js new file mode 100644 index 0000000..e720df9 --- /dev/null +++ b/public/game.js @@ -0,0 +1,13 @@ +const alphabet = 'abcdefgh' +//let squares = document.getElementsByClassName("square") + + +for (let i = 0; i < 8; i++) { + for (let j = 0; j < 8; j++) { + let square = document.getElementById(`${alphabet.charAt(j)}${i + 1}`) + //console.log(square) + + square.append("p") + } +} + diff --git a/index.css b/public/index.css index 08324aa..08324aa 100644 --- a/index.css +++ b/public/index.css diff --git a/index.html b/public/index.html index 0e30833..4f20d70 100644 --- a/index.html +++ b/public/index.html @@ -121,6 +121,7 @@ </div> </div> </div> - <script src="./game.js"></script> + <script rel="preconnect" src="app.js" crossorigin></script> + <script rel="preconnect" src="game.js" crossorigin></script> </body> </html> diff --git a/server.js b/server.js new file mode 100644 index 0000000..7edf325 --- /dev/null +++ b/server.js @@ -0,0 +1,17 @@ +require('dotenv').config() + +const PORT = process.env.PORT + +const express = require('express') +const app = express() + +app.use(express.static('public')) + +app.get('/', (req, res) => { + res.sendFile('index.html', { 'root': './' }) +}) + +app.listen(PORT, () => { + console.log(`listen at port ${PORT}`) +}) + |