| @@ 1-56 (lines=56) @@ | ||
| 1 | const Pawn = require("./pieces/Pawn"); |
|
| 2 | const Rook = require("./pieces/Rook"); |
|
| 3 | const Bishop = require("./pieces/Bishop"); |
|
| 4 | const King = require("./pieces/King"); |
|
| 5 | const Queen = require("./pieces/Queen"); |
|
| 6 | const Knight = require("./pieces/Knight"); |
|
| 7 | ||
| 8 | /** |
|
| 9 | * The chess player module |
|
| 10 | * @module |
|
| 11 | */ |
|
| 12 | "use strict"; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Player class to controll the players pieces |
|
| 16 | */ |
|
| 17 | class Player { |
|
| 18 | /** |
|
| 19 | * Constructor that that inits a player with name and oclor |
|
| 20 | * @param {String} color |
|
| 21 | * @param {String} name |
|
| 22 | */ |
|
| 23 | constructor(color, name) { |
|
| 24 | this.color = color; |
|
| 25 | this.name = name; |
|
| 26 | this.takesPieces = []; |
|
| 27 | this.pawns = []; |
|
| 28 | this.rooks = []; |
|
| 29 | this.bishops = []; |
|
| 30 | this.knights = []; |
|
| 31 | this.queen = new Queen(color); |
|
| 32 | this.king = new King(color); |
|
| 33 | ||
| 34 | for (let i = 0; i < 8; i++) { |
|
| 35 | this.pawns.push(new Pawn(color)); |
|
| 36 | } |
|
| 37 | ||
| 38 | for (let i = 0; i < 2; i++) { |
|
| 39 | this.rooks.push(new Rook(color)); |
|
| 40 | } |
|
| 41 | ||
| 42 | for (let i = 0; i < 2; i++) { |
|
| 43 | this.bishops.push(new Bishop(color)); |
|
| 44 | } |
|
| 45 | ||
| 46 | for (let i = 0; i < 2; i++) { |
|
| 47 | this.knights.push(new Knight(color)); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| 51 | getActivePieces() { |
|
| 52 | ||
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| 56 | module.exports = Player; |
|
| 57 | ||
| @@ 1-56 (lines=56) @@ | ||
| 1 | const Pawn = require("./pieces/Pawn"); |
|
| 2 | const Rook = require("./pieces/Rook"); |
|
| 3 | const Bishop = require("./pieces/Bishop"); |
|
| 4 | const King = require("./pieces/King"); |
|
| 5 | const Queen = require("./pieces/Queen"); |
|
| 6 | const Knight = require("./pieces/Knight"); |
|
| 7 | ||
| 8 | /** |
|
| 9 | * The chess player module |
|
| 10 | * @module |
|
| 11 | */ |
|
| 12 | "use strict"; |
|
| 13 | ||
| 14 | /** |
|
| 15 | * Player class to controll the players pieces |
|
| 16 | */ |
|
| 17 | class Player { |
|
| 18 | /** |
|
| 19 | * Constructor that that inits a player with name and oclor |
|
| 20 | * @param {String} color |
|
| 21 | * @param {String} name |
|
| 22 | */ |
|
| 23 | constructor(color, name) { |
|
| 24 | this.color = color; |
|
| 25 | this.name = name; |
|
| 26 | this.takesPieces = []; |
|
| 27 | this.pawns = []; |
|
| 28 | this.rooks = []; |
|
| 29 | this.bishops = []; |
|
| 30 | this.knights = []; |
|
| 31 | this.queen = new Queen(color); |
|
| 32 | this.king = new King(color); |
|
| 33 | ||
| 34 | for (let i = 0; i < 8; i++) { |
|
| 35 | this.pawns.push(new Pawn(color)); |
|
| 36 | } |
|
| 37 | ||
| 38 | for (let i = 0; i < 2; i++) { |
|
| 39 | this.rooks.push(new Rook(color)); |
|
| 40 | } |
|
| 41 | ||
| 42 | for (let i = 0; i < 2; i++) { |
|
| 43 | this.bishops.push(new Bishop(color)); |
|
| 44 | } |
|
| 45 | ||
| 46 | for (let i = 0; i < 2; i++) { |
|
| 47 | this.knights.push(new Knight(color)); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||
| 51 | getActivePieces() { |
|
| 52 | ||
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| 56 | module.exports = Player; |
|
| 57 | ||