aboutsummaryrefslogtreecommitdiff
path: root/web/src/types.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/types.ts')
-rw-r--r--web/src/types.ts54
1 files changed, 54 insertions, 0 deletions
diff --git a/web/src/types.ts b/web/src/types.ts
new file mode 100644
index 0000000..07871c2
--- /dev/null
+++ b/web/src/types.ts
@@ -0,0 +1,54 @@
+export type Screen = 'main-menu' | 'typing-game' | 'end-screen';
+
+export interface Stats {
+ wpm: number;
+ rawWpm: number;
+ accuracy: number;
+ time: number;
+ correctChars: number;
+ incorrectChars: number;
+ totalChars: number;
+ currentStreak: number;
+ bestStreak: number;
+}
+
+export interface GameState {
+ screen: Screen;
+ currentText: string;
+ currentAttribution?: string;
+ input: string;
+ startTime: number | null;
+ isRunning: boolean;
+ stats: Stats;
+}
+
+export enum Theme {
+ Light = 'light',
+ Dark = 'dark'
+}
+
+export interface ThemeColors {
+ primary: string;
+ secondary: string;
+ background: string;
+ text: string;
+ error: string;
+ success: string;
+}
+
+export interface TyperPunkGame {
+ handle_input(input: string): void;
+ handle_backspace(ctrl: boolean): boolean;
+ get_stats(): [number, number];
+ get_stats_and_input(): [string, number, number];
+ is_finished(): boolean;
+ get_text(): string;
+ get_input(): string;
+ set_text(text: string): void;
+ start(): void;
+ get_wpm(): number;
+ get_time_elapsed(): number;
+ get_raw_wpm(): number;
+}
+
+export type TyperPunk = TyperPunkGame; \ No newline at end of file