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

Conversation

matheuschen-zz
Copy link

No description provided.

function Board(size) {
const board = {
size,
matrix: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

You could call here directly, there would be no problem at all!

const board = {
  size,
  matrix: BoardConstruct(newSize),
  ...
}

board.matrix[point.y][point.x].setSymbol(symbol);
},
print: () => {
BoardPrinter(board.matrix);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you created an abstraction in your game called Board, this BoardPrinter would make more sense to receive an actual board than the matrix, right?
When you create a function, pay attention to what you are making it depend of. It makes more sense to a BoardPrinter to depend on a Board than on a "matrix

for (let i = 0; i < boardLength; i += 1) {
const rowOfTiles = [];
for (let j = 0; j < boardWidth; j += 1) {
rowOfTiles.push(tileGenerator());
Copy link
Contributor

Choose a reason for hiding this comment

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

Always be consistent! If you name add "generator" to functions that create a new instance of something, you should add "generator" to all functions that do that. For example, why Board and not BoardGenerator? Why this function is not Capitalized? (TitleGenerator())?

const boardWidth = newSize;
const matrixOfTiles = [];

for (let i = 0; i < boardLength; i += 1) {
Copy link
Contributor

@Sauloxd Sauloxd Jun 3, 2020

Choose a reason for hiding this comment

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

hmm If you used "boardWidth" for one axis, why not "boardHeight" for the other? It's an exaggeration but "boardLength" could actually mean the length of an array with boards! not its actual dimension

wd
@@ -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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants