From 7d8f390a50304e163ee1ac1d040e2db26f3ac1ea Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 2 Jun 2026 20:19:47 +0200 Subject: [PATCH] move game state and head interfaces into shared file --- src/interfaces.ts | 24 ++++++++++++++++++++++++ src/reducers/gameReducer.ts | 26 +------------------------- src/utils/pgnUtils.ts | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/interfaces.ts b/src/interfaces.ts index 02f8305..6e614ea 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -2,3 +2,27 @@ export interface IPosition { ply: number; 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; +} diff --git a/src/reducers/gameReducer.ts b/src/reducers/gameReducer.ts index fe1e5b6..db97788 100644 --- a/src/reducers/gameReducer.ts +++ b/src/reducers/gameReducer.ts @@ -1,28 +1,4 @@ -import type { 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; -} +import type { IGameState, IHeader, IPosition } from "#/interfaces.ts"; type GameAction = | { type: "SET_GAME"; payload: { pgn: string; headers: IHeader } } diff --git a/src/utils/pgnUtils.ts b/src/utils/pgnUtils.ts index ffb48a8..7abb9b5 100644 --- a/src/utils/pgnUtils.ts +++ b/src/utils/pgnUtils.ts @@ -1,4 +1,4 @@ -import type { IGameState } from "#/reducers/gameReducer.ts"; +import type { IGameState } from "#/interfaces.ts"; export const getHeaders = (pgn: string) => { const pgnHeader = pgn.split(/\n\n/g)[0];