Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ver tabuleiro #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
extends: '@qulture/eslint-config-base',
};

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"javascript.format.enable": false,
"typescript.format.enable": false,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.codeActionsOnSave": {
"source.fixAll": true
},

"typescript.tsdk": "node_modules/typescript/lib",
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
},
"homepage": "https://github.com/QultureRocks/FE-trail-template#readme",
"devDependencies": {
"@qulture/eslint-config-base": "^0.0.2"
"@qulture/eslint-config-base": "^0.0.4"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^3.1.0",
"eslint": "^7.1.0",
"eslint-config-airbnb": "^18.1.0"
}
}
28 changes: 28 additions & 0 deletions src/node/board.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const BoardConstruct = require('./boardConstructor');
const BoardPrinter = require('./boardPrinter.js');
const Point = require('./point.js');

function Board(size) {
const board = {
size,
matrix: BoardConstruct(size),
placePiece(point, symbol) {
board.matrix[point.y][point.x].setSymbol(symbol);
},
print: () => {
BoardPrinter(board);
},
};

return board;
}

//TEST
const board = Board(3);
let a = Point(1, 2);
board.placePiece(a, 'X');
a = Point(0, 0);
board.placePiece(a, 'O');
board.print();

module.exports = Board;
16 changes: 16 additions & 0 deletions src/node/boardConstructor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const Tile = require('./tile.js');

function BoardConstruct(boardDimension) {
const matrixOfTiles = [];

for (let i = 0; i < boardDimension; i += 1) {
const rowOfTiles = [];
for (let j = 0; j < boardDimension; j += 1) {
rowOfTiles.push(Tile());
}
matrixOfTiles.push(rowOfTiles);
}
return matrixOfTiles;
}

module.exports = BoardConstruct;
15 changes: 15 additions & 0 deletions src/node/boardPrinter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function BoardPrinter(board) {
let boardString = ' _ _ _\n\n';

board.matrix.forEach(row => {
boardString += '| ';
row.forEach(tile => {
boardString += `${tile.symbol} | `;
});
boardString += '\n _ _ _\n\n';
});

console.log(boardString);
}

module.exports = BoardPrinter;
1 change: 1 addition & 0 deletions src/node/game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function Game() {}
5 changes: 0 additions & 5 deletions src/node/index.js

This file was deleted.

8 changes: 8 additions & 0 deletions src/node/point.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Point(x, y) {
return {
x,
y,
};
}

module.exports = Point;
11 changes: 11 additions & 0 deletions src/node/tile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function Tile() {
const tile = {
symbol: ' ',
setSymbol(newSymbol) {
tile.symbol = newSymbol;
},
};
return tile;
}

module.exports = Tile;
2 changes: 2 additions & 0 deletions wd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can delete this file!

* verTabuleiro
Loading