All files / blacktrigram/src/systems game.ts

100% Statements 13/13
100% Branches 1/1
100% Functions 0/0
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91                                                      1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x                                                                                                      
// Core game state and flow management
 
import { GameMode, KoreanText } from "@/types";
import type { PlayerState } from "./player";
 
// Match configuration
export interface MatchConfig {
  readonly mode: GameMode;
  readonly rounds: number;
  readonly roundDuration: number; // seconds
  readonly player1Archetype: string;
  readonly player2Archetype: string;
  readonly stage: string;
  readonly difficulty?: "easy" | "medium" | "hard" | "expert";
}
 
// Game event system
export interface GameEvent {
  readonly id: string;
  readonly type: GameEventType;
  readonly timestamp: number;
  readonly playerId?: string;
  readonly data: Record<string, any>; // Fix: Keep consistent type
  readonly message?: KoreanText;
}
 
// Game event types
export enum GameEventType {
  GAME_START = "game_start",
  ROUND_START = "round_start",
  ROUND_END = "round_end",
  MATCH_END = "match_end",
  PLAYER_ATTACK = "player_attack",
  PLAYER_HIT = "player_hit",
  STANCE_CHANGE = "stance_change",
  TECHNIQUE_EXECUTE = "technique_execute",
  VITAL_POINT_HIT = "vital_point_hit",
  STATUS_EFFECT = "status_effect",
  PAUSE_TOGGLE = "pause_toggle",
  ERROR = "error",
}
 
// Game session interface
export interface GameSession {
  readonly id: string;
  readonly gameMode: GameMode;
  readonly players: readonly [PlayerState, PlayerState];
  readonly currentRound: number;
  readonly maxRounds: number;
  readonly roundTimeLimit: number;
  readonly timeRemaining: number;
  readonly isPaused: boolean;
  readonly isGameOver: boolean;
  readonly winner: PlayerState | null;
}
 
// Game configuration
export interface GameConfig {
  readonly maxHealth: number;
  readonly maxKi: number;
  readonly maxStamina: number;
  readonly roundDuration: number;
  readonly maxRounds: number;
  readonly difficulty: "beginner" | "intermediate" | "expert" | "master";
  readonly enableVitalPoints: boolean;
  readonly enableStatusEffects: boolean;
  readonly allowArchetypeSwitching: boolean;
}
 
// Game save data
export interface GameSaveData {
  readonly version: string;
  readonly playerId: string;
  readonly playerProgress: {
    readonly archetypeExperience: Record<string, number>;
    readonly unlockedTechniques: readonly string[];
    readonly achievements: readonly string[];
  };
  readonly settings: {
    readonly volume: number;
    readonly difficulty: string;
    readonly controls: Record<string, string>;
  };
  readonly statistics: {
    readonly totalMatches: number;
    readonly wins: number;
    readonly losses: number;
    readonly favoriteArchetype: string;
  };
}