From 932325ffa95d8529507ea356543b5d4cfe0adeb6 Mon Sep 17 00:00:00 2001 From: tiennm99 Date: Tue, 7 Apr 2026 20:50:16 +0700 Subject: [PATCH] feat: add shared types and difficulty constants --- src/game/constants.ts | 32 ++++++++++++++++++++++++++++++++ src/types/index.ts | 24 ++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/game/constants.ts create mode 100644 src/types/index.ts diff --git a/src/game/constants.ts b/src/game/constants.ts new file mode 100644 index 0000000..3dea814 --- /dev/null +++ b/src/game/constants.ts @@ -0,0 +1,32 @@ +import { Difficulty, DifficultyConfig } from "../types"; + +export const DIFFICULTY_CONFIGS: Record = { + easy: { + rows: 4, + cols: 6, + timerSeconds: 300, + hints: 5, + shuffles: 3, + pairCount: 12, + }, + medium: { + rows: 6, + cols: 8, + timerSeconds: 240, + hints: 3, + shuffles: 2, + pairCount: 24, + }, + hard: { + rows: 8, + cols: 10, + timerSeconds: 180, + hints: 1, + shuffles: 1, + pairCount: 40, + }, +}; + +export const BASE_MATCH_SCORE = 100; +export const SPEED_BONUS_MAX = 50; +export const SPEED_BONUS_WINDOW_MS = 5000; diff --git a/src/types/index.ts b/src/types/index.ts new file mode 100644 index 0000000..db86353 --- /dev/null +++ b/src/types/index.ts @@ -0,0 +1,24 @@ +export type Difficulty = "easy" | "medium" | "hard"; + +export interface Point { + row: number; + col: number; +} + +export type GameStatus = "menu" | "playing" | "paused" | "won" | "lost"; + +export interface DifficultyConfig { + rows: number; + cols: number; + timerSeconds: number; + hints: number; + shuffles: number; + pairCount: number; +} + +export interface TileData { + emoji: string; + id: number; +} + +export type Board = (TileData | null)[][];