| 14 | const GAME_TIME_MS = 10 * 60 * 60 * 1000; |
| 15 | |
| 16 | export function isPromoting(chess: Chess, from: Square, to: Square) { |
| 17 | if (!from) { |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | const piece = chess.get(from); |
| 22 | |
| 23 | if (piece?.type !== 'p') { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | if (piece.color !== chess.turn()) { |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | if (!['1', '8'].some((it) => to.endsWith(it))) { |
| 32 | return false; |
| 33 | } |
| 34 | |
| 35 | return chess |
| 36 | .moves({ square: from, verbose: true }) |
| 37 | .map((it) => it.to) |
| 38 | .includes(to); |
| 39 | } |
| 40 | |
| 41 | export class Game { |
| 42 | public gameId: string; |