src/chess/pieces/Rook.js   A
last analyzed

Size

Lines of Code 29

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
nc 1
dl 0
loc 29
ccs 8
cts 10
cp 0.8
rs 10
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A Rook.js ➔ ??? 0 8 2
1
/**
2
 * Rook module
3
 * @module
4
 */
5
"use strict";
6
7
/**
8
 * Class with Rook logic
9
 */
10
class Rook {
11
    /**
12
     * init
13
     */
14
    constructor(color) {
15 8
        this.symbol = "R";
16 8
        this.moved = 0;
17 8
        this.active = true;
18 8
        this.color = color;
19 8
        this.rows = [null, "A", "B", "C", "D", "E", "F", "G", "H"];
20 8
        this.img = this.color === "white" ? "w-rook" : "b-rook";
21
    }
22
23
    legalMove(x, y, nx, ny) {
24 6
        if (x == nx && y !== ny || x !== nx && y == ny) {
25
            return true
26
        }
27
28
        return false;
29
    }
30
}
31
32
33
module.exports = Rook;
34