-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
108 lines (98 loc) · 2.44 KB
/
types.d.ts
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import type { Square, Color, PieceSymbol, Move } from "chess.js";
declare global {
type ChessPiece = {
color: Color;
piece: PieceSymbol;
from: Square;
};
interface BasePieceProps {
type: PieceSymbol;
color: Color;
pieceCanMove: boolean;
}
interface PieceProps extends Omit<BasePieceProps, "type"> {}
interface Options {
flipBoard: boolean;
showSquareName: boolean;
showAxisLabels: boolean;
showDefenseLayer: boolean;
showEnemyDefenseLayer: boolean;
defenseLayerColor: string;
enemyDefenseLayerColor: string;
disputedLayerColor: string;
primaryColor: string;
secondaryColor: string;
accentColor: string;
}
type CaptureEvent = {
piece: PieceSymbol;
type: "en-passant" | "capture";
color: Color;
};
type LockedPieces = { [squareName: string]: null };
type Conflict = Record<Square, { white: boolean; black: boolean }> | null;
interface GameState {
playerColor: Color | null;
ascii: string;
board: Board;
pieceMap: Record<Square, Square | null>;
conflict: Conflict;
moves: Move[];
lockedMoves: Move[];
lockedDefense: Move[];
turn: Color;
inCheck: boolean;
isCheckmate: boolean;
isDraw: boolean;
isInsufficientMaterial: boolean;
isGameOver: boolean;
isStalemate: boolean;
isThreefoldRepetition: boolean;
fen: string;
history: Move[];
whiteCaptured: PieceSymbol[];
blackCaptured: PieceSymbol[];
lastMove: Pick<Move, "to" | "from"> | null;
activeMoves: Move[];
skillLevel: number;
type: GameType;
navIndex: number;
promotion: {
to: Square;
from: Square;
promotion: "n" | "b" | "r" | "q";
} | null;
opening: string | undefined | null;
}
interface SelectionState {
activePiece: ChessPiece | null;
lockedOwn: Square[];
lockedTarget: Square[];
}
type Board = ({
square: Square;
type: PieceSymbol;
color: Color;
} | null)[][];
type GameUpdate = {
ascii: string;
board: Board;
conflict: Conflict;
moves: Move[];
turn: Color;
inCheck: boolean;
isCheckmate: boolean;
isDraw: boolean;
isInsufficientMaterial: boolean;
isGameOver: boolean;
isStalemate: boolean;
isThreefoldRepetition: boolean;
fen: string;
history: Move[];
};
type Position = { moves: Move[]; defending: Move[] } | never;
type ShowPosition = {
position: Position;
enemyPosition: Position;
};
}