-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- detect game over and show dialog - improve responsive design - end game dialog for win or lose. - fix issues with websockets. - improve performance
- Loading branch information
Showing
18 changed files
with
587 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Move, Square } from 'chess.js'; | ||
import { CSSProperties } from 'react'; | ||
import { ChessboardProps } from 'react-chessboard/dist/chessboard/types'; | ||
|
||
export interface SanitizedChessboardProps | ||
extends Partial< | ||
Pick< | ||
ChessboardProps, | ||
| 'id' | ||
| 'position' | ||
| 'customSquare' | ||
| 'customPieces' | ||
| 'isDraggablePiece' | ||
| 'boardOrientation' | ||
| 'areArrowsAllowed' | ||
| 'animationDuration' | ||
| 'arePremovesAllowed' | ||
| 'arePiecesDraggable' | ||
| 'customSquareStyles' | ||
| 'customDarkSquareStyle' | ||
| 'customLightSquareStyle' | ||
> | ||
> {} | ||
|
||
export type BoardProps = { | ||
fen?: string; | ||
isWhite?: boolean; | ||
player?: Player; | ||
opponent?: Player; | ||
disabled?: boolean; | ||
onChange?: (fen: string, move: Move, isGameOver: boolean) => void; | ||
}; | ||
|
||
export type Player = Partial<{ | ||
rating: number; | ||
picture: string; | ||
clockms: number; | ||
username: string; | ||
}>; | ||
|
||
export type BoardState = { | ||
possibleMoves: { [key in Square]?: CSSProperties }; | ||
moveFrom: Square | ''; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.board-container { | ||
width: 90vw; | ||
max-width: calc(80vh); | ||
margin: 0 auto; | ||
user-select: none; | ||
} | ||
|
||
@media screen and (min-width: 768px) { | ||
.board-container { | ||
max-width: calc(70vh); | ||
width: 70vw; | ||
margin: 0 auto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function getFormatedTime(time: number) { | ||
const formated = new Date(0); | ||
formated.setMilliseconds(time); | ||
return formated.toISOString().substring(14, 19); | ||
} | ||
export const PiecesCount = { | ||
k: 1, | ||
q: 1, | ||
b: 2, | ||
n: 2, | ||
r: 2, | ||
p: 8, | ||
}; |
Oops, something went wrong.