Compare commits
3 changed files with 10 additions and 39 deletions
|
|
@ -1,46 +1,17 @@
|
||||||
import { Game } from "./game";
|
import { Game } from "./utils";
|
||||||
export type GameListener = (board: Game) => void;
|
export type GameListener = (board: Game) => void;
|
||||||
|
|
||||||
export enum MoveFlag {
|
|
||||||
NORMAL = 0,
|
|
||||||
PAWN_DOUBLE = 1,
|
|
||||||
EN_PASSANT = 2,
|
|
||||||
CASTLE_KING = 3,
|
|
||||||
CASTLE_QUEEN = 4,
|
|
||||||
PROMOTION = 5,
|
|
||||||
CAPTURE = 6,
|
|
||||||
CAPTURE_PROMOTE = 7,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum Promotion {
|
|
||||||
QUEEN = 0,
|
|
||||||
ROOK = 1,
|
|
||||||
BISHOP = 2,
|
|
||||||
KNIGHT = 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum Capture {
|
|
||||||
NONE = 0,
|
|
||||||
PAWN = 1,
|
|
||||||
KNIGHT = 2,
|
|
||||||
BISHOP = 3,
|
|
||||||
ROOK = 4,
|
|
||||||
QUEEN = 5,
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum Piece {
|
export enum Piece {
|
||||||
// bit 0-2: piece type (0-6)
|
|
||||||
EMPTY = 0,
|
EMPTY = 0,
|
||||||
QUEEN = 1,
|
KING = 1,
|
||||||
ROOK = 2,
|
QUEEN = 2,
|
||||||
BISHOP = 3,
|
ROOK = 3,
|
||||||
KNIGHT = 4,
|
BISHOP = 4,
|
||||||
PAWN = 5,
|
KNIGHT = 5,
|
||||||
KING = 6,
|
PAWN = 6,
|
||||||
|
|
||||||
// bit 3: color (0-1)
|
WHITE = 8,
|
||||||
WHITE = 0<<3,
|
BLACK = 16,
|
||||||
BLACK = 1<<3,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CHAR_TO_PIECE: Record<string, number> = {
|
export const CHAR_TO_PIECE: Record<string, number> = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { PIECE_TO_CHAR } from "$lib/chess/types";
|
import { PIECE_TO_CHAR } from "$lib/chess/types";
|
||||||
import { boardToAscii, Game, startFEN } from "$lib/chess/game";
|
import { boardToAscii, Game, startFEN } from "$lib/chess/utils";
|
||||||
|
|
||||||
let showIndex = $state(false);
|
let showIndex = $state(false);
|
||||||
let fen = $state(startFEN);
|
let fen = $state(startFEN);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue