UNPKG

@obliczeniowo/elementary

Version:
641 lines (629 loc) 32.5 kB
import * as i0 from '@angular/core'; import { HostBinding, Input, Component, ViewChildren, NgModule } from '@angular/core'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; var ChessEnum; (function (ChessEnum) { ChessEnum["whiteKing"] = "\u2654"; ChessEnum["whiteQueen"] = "\u2655"; ChessEnum["whiteRook"] = "\u2656"; ChessEnum["whiteBishop"] = "\u2657"; ChessEnum["whiteKnight"] = "\u2658"; ChessEnum["whitePawn"] = "\u2659"; ChessEnum["blackKing"] = "\u265A"; ChessEnum["blackQueen"] = "\u265B"; ChessEnum["blackRook"] = "\u265C"; ChessEnum["blackBishop"] = "\u265D"; ChessEnum["blackKnight"] = "\u265E"; ChessEnum["blackPawn"] = "\u265F"; ChessEnum["nonePiece"] = ""; })(ChessEnum || (ChessEnum = {})); var ChessColor; (function (ChessColor) { ChessColor[ChessColor["white"] = 0] = "white"; ChessColor[ChessColor["black"] = 1] = "black"; })(ChessColor || (ChessColor = {})); class ChessFieldComponent { ChessEnum = ChessEnum; row; column; chessField = true; get whiteField() { return this.row !== undefined && this.column !== undefined && this.isWhite; } get blackField() { return this.row !== undefined && this.column !== undefined && this.isBlack; } get columnIndex() { return this.column.charCodeAt(0) - 'a'.charCodeAt(0) + 1; } get isBlack() { return ((this.row) + (this.columnIndex) % 2) % 2 === 0; } get isWhite() { return !this.isBlack; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.4", type: ChessFieldComponent, isStandalone: false, selector: "obl-chess-field", inputs: { row: "row", column: "column" }, host: { properties: { "class.chess-field": "this.chessField", "class.white-field": "this.whiteField", "class.black-field": "this.blackField" } }, ngImport: i0, template: "<ng-content></ng-content>\n", styles: [""] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessFieldComponent, decorators: [{ type: Component, args: [{ selector: 'obl-chess-field', standalone: false, template: "<ng-content></ng-content>\n" }] }], propDecorators: { row: [{ type: Input }], column: [{ type: Input }], chessField: [{ type: HostBinding, args: ['class.chess-field'] }], whiteField: [{ type: HostBinding, args: ['class.white-field'] }], blackField: [{ type: HostBinding, args: ['class.black-field'] }] } }); class Chess { static isWhite(piece) { switch (piece) { case ChessEnum.whiteBishop: case ChessEnum.whiteQueen: case ChessEnum.whiteRook: case ChessEnum.whiteKnight: case ChessEnum.whitePawn: case ChessEnum.whiteKing: return true; default: return false; } } static isBlack(piece) { return !Chess.isWhite(piece) && piece !== ChessEnum.nonePiece; } } class ChessPawnComponent { elementRef; row; column; pawnType; dragstart = (event) => { event.dataTransfer.setData('text/plain', null); }; constructor(elementRef) { this.elementRef = elementRef; } ngAfterViewInit() { this.elementRef.nativeElement.setAttribute('draggable', 'true'); this.elementRef.nativeElement.addEventListener('dragstart', this.dragstart, false); } ngOnDestroy() { this.elementRef.nativeElement.removeEventListener('dragstart', this.dragstart); } isBlack() { return Chess.isBlack(this.pawnType); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessPawnComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.4", type: ChessPawnComponent, isStandalone: false, selector: "obl-chess-pawn", inputs: { row: "row", column: "column", pawnType: "pawnType" }, ngImport: i0, template: "<div\n [class]=\"'pawn-field ' + column + row\"\n (dragstart)=\"dragstart($event)\"\n draggable=\"true\"\n>\n {{ pawnType }}\n</div>\n", styles: [".pawn-field{display:flex;justify-content:center;align-items:center;cursor:pointer;color:#000}\n"] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessPawnComponent, decorators: [{ type: Component, args: [{ selector: 'obl-chess-pawn', standalone: false, template: "<div\n [class]=\"'pawn-field ' + column + row\"\n (dragstart)=\"dragstart($event)\"\n draggable=\"true\"\n>\n {{ pawnType }}\n</div>\n", styles: [".pawn-field{display:flex;justify-content:center;align-items:center;cursor:pointer;color:#000}\n"] }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { row: [{ type: Input }], column: [{ type: Input }], pawnType: [{ type: Input }] } }); const columns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']; const rows = [1, 2, 3, 4, 5, 6, 7, 8]; class Address { column; row; constructor(address) { if (address.length === 2) { if (columns.includes(address.charAt(0))) { this.column = address.charAt(0); } else { throw new Error(`This column not exist ${address.charAt(0)}`); } const row = parseInt(address.charAt(1), 10); if (rows.includes(row)) { this.row = row; } else { throw new Error(`This row not exist: ${row}`); } } } offset(row, column) { const columnIndex = columns.findIndex(columnI => columnI === this.column) + column; if (columnIndex < 0 || columnIndex > 7) { return undefined; } const rowPos = row + this.row; if (rowPos > 8 || rowPos < 1) { return undefined; } return new Address(columns[columnIndex] + rowPos); } toString() { return `${this.column}${this.row}`; } } class AbstractPiece { _type; get type() { return this._type; } _address; get address() { return this._address; } constructor(type, address) { this._type = type; this._address = address; } isEmpty(address, chessPieces) { return address !== undefined && chessPieces.find(piece => piece.column === address.column && piece.row === address.row)?.pawnType === ChessEnum.nonePiece; } isOppositePiece(address, chessPieces) { if (address) { if (Chess.isWhite(this._type)) { return Chess.isBlack(chessPieces.find(piece => piece.column === address.column && piece.row === address.row)?.pawnType); } else { return Chess.isWhite(chessPieces.find(piece => piece.column === address.column && piece.row === address.row)?.pawnType); } } return false; } } class Pawn extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const vector = Chess.isWhite(this._type) ? [1, 0] : [-1, 0]; const start = Chess.isWhite(this._type) ? 2 : 7; const oneFieldUp = this.address.offset(vector[0], vector[1]); if (this.isEmpty(oneFieldUp, chessPieces) && oneFieldUp) { fields.push(oneFieldUp.toString()); const twoFieldUp = this.address.offset(vector[0] * 2, vector[1]); if (this.address.row === start) { if (this.isEmpty(twoFieldUp, chessPieces) && twoFieldUp) { fields.push(twoFieldUp.toString()); } } } const leftField = this.address.offset(vector[0], -1); const rightField = this.address.offset(vector[0], 1); if (leftField && this.isOppositePiece(leftField, chessPieces)) { fields.push(leftField.toString()); } if (rightField && this.isOppositePiece(rightField, chessPieces)) { fields.push(rightField.toString()); } return fields; } } class Knight extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const offsets = [ [2, -1], [2, 1], [1, 2], [-1, 2], [-2, 1], [-2, -1], [-1, -2], [1, -2] ]; offsets.forEach(offset => { const field = this.address?.offset(offset[0], offset[1]); // eslint-disable-next-line @typescript-eslint/prefer-optional-chain if (field && (this.isEmpty(field, chessPieces) || this.isOppositePiece(field, chessPieces))) { fields.push(field.toString()); } }); return fields; } } class Bishop extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const offsets = [ [1, -1], [1, 1], [-1, 1], [-1, -1] ]; offsets.forEach(offset => { for (let k = 1; k < 9; k++) { const field = this.address?.offset(offset[0] * k, offset[1] * k); const empty = this.isEmpty(field, chessPieces); if (field && (empty || this.isOppositePiece(field, chessPieces))) { fields.push(field.toString()); } if (!empty || !field) { break; } } }); return fields; } } class Rook extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const offsets = [ [1, 0], [-1, 0], [0, 1], [0, -1] ]; offsets.forEach(offset => { for (let k = 1; k < 9; k++) { const field = this.address?.offset(offset[0] * k, offset[1] * k); const empty = this.isEmpty(field, chessPieces); // eslint-disable-next-line @typescript-eslint/prefer-optional-chain if (field && (empty || this.isOppositePiece(field, chessPieces))) { fields.push(field.toString()); } if (!empty || !field) { break; } } }); return fields; } } class Queen extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const offsets = [ [1, -1], [1, 0], [1, 1], [0, 1], [0, -1], [-1, 1], [-1, 0], [-1, -1] ]; offsets.forEach(offset => { for (let k = 1; k < 9; k++) { const field = this.address?.offset(offset[0] * k, offset[1] * k); const empty = this.isEmpty(field, chessPieces); if (field && (empty || this.isOppositePiece(field, chessPieces))) { fields.push(field.toString()); } if (!empty || !field) { break; } } }); return fields; } } class King extends AbstractPiece { moveFieldsList(chessPieces) { if (!this.address) { return []; } const fields = []; const offsets = [ [1, -1], [1, 0], [1, 1], [0, 1], [0, -1], [-1, 1], [-1, 0], [-1, -1] ]; offsets.forEach(offset => { const field = this.address?.offset(offset[0], offset[1]); // eslint-disable-next-line @typescript-eslint/prefer-optional-chain if (field && (this.isEmpty(field, chessPieces) || this.isOppositePiece(field, chessPieces))) { fields.push(field.toString()); } }); return fields; } } class AbstractPieceFactory { static getPiece(type, address) { switch (type) { case ChessEnum.blackBishop: case ChessEnum.whiteBishop: return new Bishop(type, address); case ChessEnum.whiteKing: case ChessEnum.blackKing: return new King(type, address); case ChessEnum.whitePawn: case ChessEnum.blackPawn: return new Pawn(type, address); case ChessEnum.whiteQueen: case ChessEnum.blackQueen: return new Queen(type, address); case ChessEnum.whiteRook: case ChessEnum.blackRook: return new Rook(type, address); case ChessEnum.whiteKnight: case ChessEnum.blackKnight: return new Knight(type, address); } return undefined; } } class ChessAbstractModel { stopSetOnDrop = false; display = { add: true }; } class ChessDragAndDropModel extends ChessAbstractModel { onDragged(dragged) { } onDropped(dropped) { return true; } } class ChessPieceMoveModel extends ChessAbstractModel { draggedPiece; constructor() { super(); this.stopSetOnDrop = true; this.display = { add: false }; } onDragged(dragged) { if (dragged.piece !== ChessEnum.nonePiece) { this.draggedPiece = AbstractPieceFactory.getPiece(dragged.piece, dragged.address && new Address(dragged.address) || undefined); } else { this.draggedPiece = undefined; } } onDropped(dropped) { if (this.draggedPiece) { const list = this.draggedPiece.moveFieldsList(dropped.chessPieces); const droppedField = dropped.chessPieces.find(piece => piece.column + piece.row === dropped.address); const draggedToField = dropped.chessPieces.find(piece => piece.column + piece.row === (this.draggedPiece?.address?.toString())); if (dropped.address && droppedField) { if (this.draggedPiece.address) { if (list.includes(dropped.address)) { droppedField.pawnType = this.pawnPromote(this.draggedPiece.type, new Address(dropped.address)); if (draggedToField) { draggedToField.pawnType = ChessEnum.nonePiece; } return true; } } else { droppedField.pawnType = this.draggedPiece.type; return true; } } else if (draggedToField) { draggedToField.pawnType = this.draggedPiece.type; } } return false; } pawnPromote(type, address) { if (type === ChessEnum.whitePawn && address.row === 8) { return ChessEnum.whiteQueen; } if (type === ChessEnum.blackPawn && address.row === 1) { return ChessEnum.blackQueen; } return type; } } class PlayChessModel extends ChessPieceMoveModel { moveTurn = ChessColor.white; onDragged(dragged) { if (this.moveTurn === ChessColor.white && Chess.isBlack(dragged.piece) || this.moveTurn === ChessColor.black && Chess.isWhite(dragged.piece)) { return; } super.onDragged(dragged); } onDropped(dropped) { if (super.onDropped(dropped)) { this.moveTurn = this.moveTurn === ChessColor.black ? ChessColor.white : ChessColor.black; this.draggedPiece = undefined; return true; } this.draggedPiece = undefined; return false; } } class ChessComponent { elementRef; ChessEnum = ChessEnum; dragged; chessPieces; chessPawnsMap = new Map(); chessModel = new ChessDragAndDropModel(); get stopSetOnDrop() { return this.chessModel.stopSetOnDrop; } _reverse = false; get reverse() { return this._reverse; } set reverse(value) { this._reverse = value; if (value) { this.rows = rows.reverse(); this.columns = columns.reverse(); } else { this.rows = rows; this.columns = columns; } } chessPawnsMapComponent = new Map(); rows = rows.reverse(); columns = columns; get hostHtml() { return this.elementRef.nativeElement; } dragstart = (event) => { this.dragged = event.target; event.target.style.opacity = 0.5; this.chessModel.onDragged({ address: Array.from(this.dragged.classList).filter(className => className.length === 2)[0], piece: this.dragged.innerText, chessPieces: this.chessPieces }); }; dragend = (event) => { event.target.style.opacity = ''; }; drag = (event) => { }; dragover = (event) => { event.preventDefault(); }; dragenter = (event) => { if (event.target.className === 'dropzone') { event.target.style.background = 'purple'; } }; dragleave = (event) => { if (event.target.className === 'dropzone') { event.target.style.background = ''; } }; drop = (event) => { event.preventDefault(); const target = event.target.classList.contains('pawn-field') ? event.target.parentElement : event.target; if (target) { const pawn = this.chessPawnsMapComponent.get(target.className); // get name of class that is an address of field const name = Array.from(this.dragged.classList).filter(className => className.length === 2)[0]; const pawnFrom = this.chessPawnsMapComponent.get(name); if (!this.stopSetOnDrop) { if (pawnFrom) { pawnFrom.pawnType = ChessEnum.nonePiece; } if (pawn && this.dragged.innerText !== ChessEnum.nonePiece) { pawn.pawnType = this.dragged.innerText; } } this.chessModel.onDropped({ address: target.className, piece: this.dragged.innerText, chessPieces: this.chessPieces }); } }; constructor(elementRef) { this.elementRef = elementRef; } ngAfterViewInit() { this.chessPieces.forEach((pawn) => { if (pawn.column && pawn.row) { this.chessPawnsMapComponent.set(pawn.column + pawn.row, pawn); } }); this.hostHtml.addEventListener('drag', this.drag, false); this.hostHtml.addEventListener('dragstart', this.dragstart, false); this.hostHtml.addEventListener('dragend', this.dragend, false); this.hostHtml.addEventListener('dragover', this.dragover, false); this.hostHtml.addEventListener('dragenter', this.dragenter, false); this.hostHtml.addEventListener('dragleave', this.dragleave, false); this.hostHtml.addEventListener('drop', this.drop, false); } ngOnDestroy() { this.hostHtml.removeEventListener('drag', this.drag); this.hostHtml.removeEventListener('dragstart', this.dragstart); this.hostHtml.removeEventListener('dragend', this.dragend); this.hostHtml.removeEventListener('dragover', this.dragover); this.hostHtml.removeEventListener('dragenter', this.dragenter); this.hostHtml.removeEventListener('dragleave', this.dragleave); this.hostHtml.removeEventListener('drop', this.drop); } setChessPawn(column, row, pawn) { this.chessPawnsMap.set(column + row, pawn); } moveChessPawn(startColumn, startRow, endColumn, endRow) { const chessPawn = this.getChessPawn(startColumn + startRow); if (chessPawn === ChessEnum.nonePiece) { return; } this.setChessPawn(endColumn, endRow, chessPawn); } getChessPawn(address) { const pawn = this.chessPawnsMap.get(address); return pawn || ChessEnum.nonePiece; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.4", type: ChessComponent, isStandalone: false, selector: "obl-chess", inputs: { chessPawnsMap: "chessPawnsMap", chessModel: "chessModel", reverse: "reverse" }, viewQueries: [{ propertyName: "chessPieces", predicate: ChessPawnComponent, descendants: true }], ngImport: i0, template: "<div class=\"columns-header\">\n @for (column of columns; track column) {\n <div class=\"column-header\">{{ column }}</div>\n }\n</div>\n\n<div class=\"pawns-and-board\">\n @if (chessModel.display.add) {\n <div class=\"white-pawns\">\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteKing\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteQueen\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteRook\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteBishop\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteKnight\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whitePawn\"></obl-chess-pawn>\n </div>\n }\n\n <div>\n @for (row of rows; track $index) {\n <div class=\"row-fields\">\n <div class=\"row-header\">\n <div>{{ row }}</div>\n </div>\n\n @for (column of columns; track $index) {\n <obl-chess-field\n class=\"dropzone\"\n [row]=\"row\"\n [column]=\"column\"\n [id]=\"column + row\"\n >\n <obl-chess-pawn\n [ngClass]=\"column + row\"\n [row]=\"row\"\n [column]=\"column\"\n [pawnType]=\"getChessPawn(column + row)\"\n draggable=\"true\"\n >\n </obl-chess-pawn>\n </obl-chess-field>\n }\n\n <div class=\"row-header\">\n <div>{{ row }}</div>\n </div>\n </div>\n }\n </div>\n\n @if (chessModel.display.add) {\n <div class=\"black-pawns\">\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackKing\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackQueen\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackRook\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackBishop\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackKnight\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackPawn\"></obl-chess-pawn>\n </div>\n }\n</div>\n\n<div class=\"columns-header\">\n @for (column of columns; track column) {\n <div class=\"column-header\">{{ column }}</div>\n }\n</div>\n", styles: [":host{display:flex;flex-direction:column;align-items:center;background-color:#fff;color:#000}:host .columns-header{margin:auto}:host .columns-header .column-header{display:flex;justify-content:center}.pawns-and-board{display:flex;flex-direction:row}.white-pawns,.black-pawns{display:flex;flex-direction:column;justify-content:center;align-items:center}.pawns-and-board .row-fields{display:flex;flex-direction:row}.row-header{width:30px;display:flex;align-items:center;justify-content:center}.columns-header{display:flex}.columns-header.column-header{display:flex;align-items:center;justify-items:center;height:30px}:host::ng-deep .white-pawns,:host::ng-deep .black-pawns,:host::ng-deep .pawn-field,:host::ng-deep .chess-field{width:70px;max-width:calc((100vw - 60px)*.1)}:host::ng-deep .row-header,:host::ng-deep .pawn-field,:host::ng-deep .chess-field{height:70px;max-height:calc((100vw - 60px)*.1)}:host::ng-deep .pawn-field{font-size:calc((100vw - 60px)*.06)}:host::ng-deep .columns-header{width:560px;max-width:calc((100vw - 60px)*.8)}:host::ng-deep .pawns-and-board{height:560px;max-height:calc((100vw - 60px)*.8)}:host::ng-deep .columns-header .column-header{width:70px;max-width:calc((100vw - 60px)*.1)}@media (min-width: 760px){:host::ng-deep .pawn-field,:host::ng-deep .chess-field{max-width:70px;max-height:70px}:host::ng-deep .pawn-field{font-size:42px}:host::ng-deep .white-pawns,:host::ng-deep .black-pawns{max-width:70px}:host::ng-deep .row-header{max-height:70px}:host::ng-deep .columns-header{max-width:560px}:host::ng-deep .pawns-and-board{max-height:560px}:host::ng-deep .columns-header .column-header{max-width:70px}}:host::ng-deep .white-field{background-color:#d2d4cd}:host::ng-deep .white-field:hover{background-color:#edf0e6}:host::ng-deep .black-field{background-color:#ac9a32}:host::ng-deep .black-field:hover{background-color:#d3bd40}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: ChessFieldComponent, selector: "obl-chess-field", inputs: ["row", "column"] }, { kind: "component", type: ChessPawnComponent, selector: "obl-chess-pawn", inputs: ["row", "column", "pawnType"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessComponent, decorators: [{ type: Component, args: [{ selector: 'obl-chess', standalone: false, template: "<div class=\"columns-header\">\n @for (column of columns; track column) {\n <div class=\"column-header\">{{ column }}</div>\n }\n</div>\n\n<div class=\"pawns-and-board\">\n @if (chessModel.display.add) {\n <div class=\"white-pawns\">\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteKing\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteQueen\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteRook\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteBishop\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whiteKnight\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.whitePawn\"></obl-chess-pawn>\n </div>\n }\n\n <div>\n @for (row of rows; track $index) {\n <div class=\"row-fields\">\n <div class=\"row-header\">\n <div>{{ row }}</div>\n </div>\n\n @for (column of columns; track $index) {\n <obl-chess-field\n class=\"dropzone\"\n [row]=\"row\"\n [column]=\"column\"\n [id]=\"column + row\"\n >\n <obl-chess-pawn\n [ngClass]=\"column + row\"\n [row]=\"row\"\n [column]=\"column\"\n [pawnType]=\"getChessPawn(column + row)\"\n draggable=\"true\"\n >\n </obl-chess-pawn>\n </obl-chess-field>\n }\n\n <div class=\"row-header\">\n <div>{{ row }}</div>\n </div>\n </div>\n }\n </div>\n\n @if (chessModel.display.add) {\n <div class=\"black-pawns\">\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackKing\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackQueen\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackRook\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackBishop\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackKnight\"></obl-chess-pawn>\n <obl-chess-pawn [pawnType]=\"ChessEnum.blackPawn\"></obl-chess-pawn>\n </div>\n }\n</div>\n\n<div class=\"columns-header\">\n @for (column of columns; track column) {\n <div class=\"column-header\">{{ column }}</div>\n }\n</div>\n", styles: [":host{display:flex;flex-direction:column;align-items:center;background-color:#fff;color:#000}:host .columns-header{margin:auto}:host .columns-header .column-header{display:flex;justify-content:center}.pawns-and-board{display:flex;flex-direction:row}.white-pawns,.black-pawns{display:flex;flex-direction:column;justify-content:center;align-items:center}.pawns-and-board .row-fields{display:flex;flex-direction:row}.row-header{width:30px;display:flex;align-items:center;justify-content:center}.columns-header{display:flex}.columns-header.column-header{display:flex;align-items:center;justify-items:center;height:30px}:host::ng-deep .white-pawns,:host::ng-deep .black-pawns,:host::ng-deep .pawn-field,:host::ng-deep .chess-field{width:70px;max-width:calc((100vw - 60px)*.1)}:host::ng-deep .row-header,:host::ng-deep .pawn-field,:host::ng-deep .chess-field{height:70px;max-height:calc((100vw - 60px)*.1)}:host::ng-deep .pawn-field{font-size:calc((100vw - 60px)*.06)}:host::ng-deep .columns-header{width:560px;max-width:calc((100vw - 60px)*.8)}:host::ng-deep .pawns-and-board{height:560px;max-height:calc((100vw - 60px)*.8)}:host::ng-deep .columns-header .column-header{width:70px;max-width:calc((100vw - 60px)*.1)}@media (min-width: 760px){:host::ng-deep .pawn-field,:host::ng-deep .chess-field{max-width:70px;max-height:70px}:host::ng-deep .pawn-field{font-size:42px}:host::ng-deep .white-pawns,:host::ng-deep .black-pawns{max-width:70px}:host::ng-deep .row-header{max-height:70px}:host::ng-deep .columns-header{max-width:560px}:host::ng-deep .pawns-and-board{max-height:560px}:host::ng-deep .columns-header .column-header{max-width:70px}}:host::ng-deep .white-field{background-color:#d2d4cd}:host::ng-deep .white-field:hover{background-color:#edf0e6}:host::ng-deep .black-field{background-color:#ac9a32}:host::ng-deep .black-field:hover{background-color:#d3bd40}\n"] }] }], ctorParameters: () => [{ type: i0.ElementRef }], propDecorators: { chessPieces: [{ type: ViewChildren, args: [ChessPawnComponent] }], chessPawnsMap: [{ type: Input }], chessModel: [{ type: Input }], reverse: [{ type: Input }] } }); class ChessModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.4", ngImport: i0, type: ChessModule, declarations: [ChessComponent, ChessFieldComponent, ChessPawnComponent], imports: [CommonModule], exports: [ChessComponent, ChessFieldComponent, ChessPawnComponent] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessModule, imports: [CommonModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChessModule, decorators: [{ type: NgModule, args: [{ declarations: [ ChessComponent, ChessFieldComponent, ChessPawnComponent ], imports: [ CommonModule ], exports: [ ChessComponent, ChessFieldComponent, ChessPawnComponent ] }] }] }); /** * Generated bundle index. Do not edit. */ export { AbstractPiece, AbstractPieceFactory, Address, Bishop, Chess, ChessAbstractModel, ChessColor, ChessComponent, ChessDragAndDropModel, ChessEnum, ChessFieldComponent, ChessModule, ChessPawnComponent, ChessPieceMoveModel, King, Knight, Pawn, PlayChessModel, Queen, Rook, columns, rows }; //# sourceMappingURL=obliczeniowo-elementary-chess.mjs.map