UNPKG

@obliczeniowo/elementary

Version:
182 lines (171 loc) 7.56 kB
import * as i0 from '@angular/core'; import { OnDestroy, AfterViewInit, ElementRef, QueryList } from '@angular/core'; import * as i4 from '@angular/common'; type ChessColumn = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h'; type ChessRow = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; declare const columns: ChessColumn[]; declare const rows: ChessRow[]; declare class Address { column: ChessColumn; row: ChessRow; constructor(address: string); offset(row: number, column: number): Address | undefined; toString(): string; } declare enum ChessEnum { whiteKing = "\u2654", whiteQueen = "\u2655", whiteRook = "\u2656", whiteBishop = "\u2657", whiteKnight = "\u2658", whitePawn = "\u2659", blackKing = "\u265A", blackQueen = "\u265B", blackRook = "\u265C", blackBishop = "\u265D", blackKnight = "\u265E", blackPawn = "\u265F", nonePiece = "" } declare enum ChessColor { white = 0, black = 1 } declare class ChessPawnComponent implements OnDestroy, AfterViewInit { private readonly elementRef; row: number; column: string; pawnType: ChessEnum; dragstart: (event: any) => void; constructor(elementRef: ElementRef<HTMLElement>); ngAfterViewInit(): void; ngOnDestroy(): void; isBlack(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<ChessPawnComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ChessPawnComponent, "obl-chess-pawn", never, { "row": { "alias": "row"; "required": false; }; "column": { "alias": "column"; "required": false; }; "pawnType": { "alias": "pawnType"; "required": false; }; }, {}, never, never, false, never>; } type ChessPiece = ChessEnum.whiteKing | ChessEnum.whiteQueen | ChessEnum.whiteRook | ChessEnum.whiteBishop | ChessEnum.whiteKnight | ChessEnum.whitePawn | ChessEnum.blackKing | ChessEnum.blackQueen | ChessEnum.blackRook | ChessEnum.blackBishop | ChessEnum.blackKnight | ChessEnum.blackPawn; declare abstract class AbstractPiece { protected _type: ChessPiece; get type(): ChessPiece; protected _address: Address | undefined; get address(): Address | undefined; constructor(type: ChessPiece, address: Address | undefined); abstract moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; protected isEmpty(address: Address | undefined, chessPieces: QueryList<ChessPawnComponent>): boolean; protected isOppositePiece(address: Address | undefined, chessPieces: QueryList<ChessPawnComponent>): boolean; } declare class Pawn extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class Knight extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class Bishop extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class Rook extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class Queen extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class King extends AbstractPiece { moveFieldsList(chessPieces: QueryList<ChessPawnComponent>): string[]; } declare class AbstractPieceFactory { static getPiece(type: ChessPiece, address: Address | undefined): AbstractPiece | undefined; } interface AddressPiece { address: string | undefined; piece: ChessEnum; chessPieces: QueryList<ChessPawnComponent>; } declare abstract class ChessAbstractModel { stopSetOnDrop: boolean; display: { add: boolean; }; /** * Triggered on dragged * @param dragged describe dragged field */ abstract onDragged(dragged: AddressPiece): void; /** * Triggered on drop * @param dropped Describe dropped field * @returns true when dropped is done, false when dropped fail */ abstract onDropped(dropped: AddressPiece): boolean; } declare class ChessDragAndDropModel extends ChessAbstractModel { onDragged(dragged: AddressPiece): void; onDropped(dropped: AddressPiece): boolean; } declare class ChessPieceMoveModel extends ChessAbstractModel { protected draggedPiece: AbstractPiece | undefined; constructor(); onDragged(dragged: AddressPiece): void; onDropped(dropped: AddressPiece): boolean; protected pawnPromote(type: ChessEnum, address: Address): ChessEnum; } declare class PlayChessModel extends ChessPieceMoveModel { protected moveTurn: ChessColor; onDragged(dragged: AddressPiece): void; onDropped(dropped: AddressPiece): boolean; } declare class ChessComponent implements AfterViewInit, OnDestroy { private readonly elementRef; ChessEnum: typeof ChessEnum; dragged: HTMLElement; chessPieces: QueryList<ChessPawnComponent>; chessPawnsMap: Map<string, ChessEnum>; chessModel: ChessAbstractModel; get stopSetOnDrop(): boolean; private _reverse; get reverse(): boolean; set reverse(value: boolean); private readonly chessPawnsMapComponent; rows: ChessRow[]; columns: ChessColumn[]; private get hostHtml(); dragstart: (event: any) => void; dragend: (event: any) => void; drag: (event: any) => void; dragover: (event: any) => void; dragenter: (event: any) => void; dragleave: (event: any) => void; drop: (event: any) => void; constructor(elementRef: ElementRef<HTMLElement>); ngAfterViewInit(): void; ngOnDestroy(): void; setChessPawn(column: string, row: number, pawn: ChessEnum): void; moveChessPawn(startColumn: string, startRow: number, endColumn: string, endRow: number): void; getChessPawn(address: string): ChessEnum; static ɵfac: i0.ɵɵFactoryDeclaration<ChessComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ChessComponent, "obl-chess", never, { "chessPawnsMap": { "alias": "chessPawnsMap"; "required": false; }; "chessModel": { "alias": "chessModel"; "required": false; }; "reverse": { "alias": "reverse"; "required": false; }; }, {}, never, never, false, never>; } declare class ChessFieldComponent { ChessEnum: typeof ChessEnum; row: number; column: string; chessField: boolean; get whiteField(): boolean; get blackField(): boolean; get columnIndex(): number; get isBlack(): boolean; get isWhite(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration<ChessFieldComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<ChessFieldComponent, "obl-chess-field", never, { "row": { "alias": "row"; "required": false; }; "column": { "alias": "column"; "required": false; }; }, {}, never, ["*"], false, never>; } declare class ChessModule { static ɵfac: i0.ɵɵFactoryDeclaration<ChessModule, never>; static ɵmod: i0.ɵɵNgModuleDeclaration<ChessModule, [typeof ChessComponent, typeof ChessFieldComponent, typeof ChessPawnComponent], [typeof i4.CommonModule], [typeof ChessComponent, typeof ChessFieldComponent, typeof ChessPawnComponent]>; static ɵinj: i0.ɵɵInjectorDeclaration<ChessModule>; } declare class Chess { static isWhite(piece: ChessEnum | undefined): boolean; static isBlack(piece: ChessEnum | undefined): boolean; } export { AbstractPiece, AbstractPieceFactory, Address, Bishop, Chess, ChessAbstractModel, ChessColor, ChessComponent, ChessDragAndDropModel, ChessEnum, ChessFieldComponent, ChessModule, ChessPawnComponent, ChessPieceMoveModel, King, Knight, Pawn, PlayChessModel, Queen, Rook, columns, rows }; export type { AddressPiece, ChessColumn, ChessPiece, ChessRow };