Skip to content

Review 1 #1

@tshemsedinov

Description

@tshemsedinov
  • Decompose and optimize long functions like this:
    processCellClick = (x, y) => {
  • Use intermediate variables instead of multi-line expressions in if-statements:
    processCellClick = (x, y) => {
  • Try to combine duplicate code:

    Sea-Battle/scripts/game.js

    Lines 203 to 228 in 474e802

    processCellMouseEnter = (event) => {
    const position = parsePositionFromCell(event.target);
    if (
    (this.player.game.state === gameState.POSITIONING_PLAYER1 &&
    this.player.isFirst) ||
    (this.player.game.state === gameState.POSITIONING_PLAYER2 &&
    !this.player.isFirst)
    ) {
    this.renderShip(position.x, position.y, cellState.SHIP);
    }
    };
    processCellMouseLeave = (event) => {
    const position = parsePositionFromCell(event.target);
    if (
    (this.player.game.state === gameState.POSITIONING_PLAYER1 &&
    this.player.isFirst) ||
    (this.player.game.state === gameState.POSITIONING_PLAYER2 &&
    !this.player.isFirst)
    ) {
    this.renderShip(position.x, position.y, cellState.EMPTY);
    }
    };
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions