mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 01:46:57 +00:00
move game state and head interfaces into shared file
This commit is contained in:
@@ -2,3 +2,27 @@ export interface IPosition {
|
|||||||
ply: number;
|
ply: number;
|
||||||
fen: string;
|
fen: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IHeader {
|
||||||
|
event: string;
|
||||||
|
site: string;
|
||||||
|
date: string;
|
||||||
|
round: string;
|
||||||
|
white: string;
|
||||||
|
black: string;
|
||||||
|
result: string;
|
||||||
|
eco: string;
|
||||||
|
whiteElo: string;
|
||||||
|
blackElo: string;
|
||||||
|
plyCount: string;
|
||||||
|
eventDate: string;
|
||||||
|
source: string;
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IGameState {
|
||||||
|
pgn: string;
|
||||||
|
headers: IHeader;
|
||||||
|
diagrams: IPosition[];
|
||||||
|
diagramClock: boolean;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,28 +1,4 @@
|
|||||||
import type { IPosition } from "#/interfaces.ts";
|
import type { IGameState, IHeader, IPosition } from "#/interfaces.ts";
|
||||||
|
|
||||||
export interface IHeader {
|
|
||||||
event: string;
|
|
||||||
site: string;
|
|
||||||
date: string;
|
|
||||||
round: string;
|
|
||||||
white: string;
|
|
||||||
black: string;
|
|
||||||
result: string;
|
|
||||||
eco: string;
|
|
||||||
whiteElo: string;
|
|
||||||
blackElo: string;
|
|
||||||
plyCount: string;
|
|
||||||
eventDate: string;
|
|
||||||
source: string;
|
|
||||||
[key: string]: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IGameState {
|
|
||||||
pgn: string;
|
|
||||||
headers: IHeader;
|
|
||||||
diagrams: IPosition[];
|
|
||||||
diagramClock: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
type GameAction =
|
type GameAction =
|
||||||
| { type: "SET_GAME"; payload: { pgn: string; headers: IHeader } }
|
| { type: "SET_GAME"; payload: { pgn: string; headers: IHeader } }
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { IGameState } from "#/reducers/gameReducer.ts";
|
import type { IGameState } from "#/interfaces.ts";
|
||||||
|
|
||||||
export const getHeaders = (pgn: string) => {
|
export const getHeaders = (pgn: string) => {
|
||||||
const pgnHeader = pgn.split(/\n\n/g)[0];
|
const pgnHeader = pgn.split(/\n\n/g)[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user