Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 13x 13x 13x 13x 13x 13x 13x 13x 7629x 7629x 7629x 7629x 7629x 1092x 1092x 1092x 1092x 1092x 1092x 7629x 3754x 7629x 121x 121x 7629x 7629x 3891x 3891x 3891x 7629x 7629x 7629x 152x 152x 152x 152x 7629x 358x 358x 358x 358x 7629x 7629x 4x 4x 4x 4x 4x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x 7629x | import {createCoordinate} from './coordinate.js';
function createPieceMoveRule(){
let currentCoordinate = createCoordinate();
let boardPieces;
function updateCurrentPosition(currentPosition, boardPieceList) {
currentCoordinate.setPosition(currentPosition);
boardPieces = boardPieceList;
}
function getCurrentCoordinate() {
return currentCoordinate;
}
function getBoardPieces() {
return boardPieces;
}
function isEmptyCoordinate(coordinate) {
return boardPieces[coordinate.getPosition()].isEmpty();
}
function isOpposingColor(coordinate) {
return boardPieces[currentCoordinate.getPosition()]
.isOpposingColor(boardPieces[coordinate.getPosition()]);
}
// Function overriden on lower child level requires 'this', otherwise calls local empty implementation
function isPossibleMove (origin, destination, pieces) {
updateCurrentPosition(origin, pieces);
return (this.getPossibleMovements().map(mv => mv.getPosition()).includes(destination));
};
function getAttackMovements (origin, pieces) {
updateCurrentPosition(origin, pieces);
return this.getPossibleMovements().map(mv => mv.getPosition());
}
function getPossibleMovements () {};
function getNextMoveRule(currentAbbreviation) {
return { moveRule: this, abbreviation: currentAbbreviation }
}
return {
updateCurrentPosition,
getCurrentCoordinate,
getBoardPieces,
isEmptyCoordinate,
isOpposingColor,
isPossibleMove,
getAttackMovements,
getPossibleMovements,
getNextMoveRule
}
}
export {
createPieceMoveRule
}
|