// ─── Combat State Types ────────────────────────────────────────────────────────
// Shared types for combat store and combat actions to avoid circular dependency

import type { GameAction, SpellState, FloorState, GolemancyState, ActivityLogEntry, AchievementState, EquipmentSpellState, ActivityEventType } from '../types';

export interface CombatState {
  // Floor state
  currentFloor: number;
  floorHP: number;
  floorMaxHP: number;
  maxFloorReached: number;

  // Action state
  activeSpell: string;
  currentAction: GameAction;
  castProgress: number;

  // Spire mode
  spireMode: boolean;

  // Room system for special floors
  currentRoom: FloorState;

  // Spire climbing state
  clearedFloors: Record<number, boolean>;
  climbDirection: 'up' | 'down' | null;
  isDescending: boolean;

  // Golemancy (summoned golems)
  golemancy: GolemancyState;

  // Equipment spell states for multi-casting
  equipmentSpellStates: EquipmentSpellState[];

  // Combat special effect tracking
  comboHitCount: number;
  floorHitCount: number;

  // Spells
  spells: Record<string, SpellState>;

  // Activity Log (for Spire Mode UI)
  activityLog: ActivityLogEntry[];

  // Achievements
  achievements: AchievementState;

  // Stats tracking
  totalSpellsCast: number;
  totalDamageDealt: number;
  totalCraftsCompleted: number;

  // Actions
  setCurrentFloor: (floor: number) => void;
  advanceFloor: () => void;
  setFloorHP: (hp: number) => void;
  setMaxFloorReached: (floor: number) => void;

  setAction: (action: GameAction) => void;
  setSpell: (spellId: string) => void;
  setCastProgress: (progress: number) => void;

  // Room state
  setCurrentRoom: (room: FloorState) => void;

  // Spire climbing
  setClimbDirection: (direction: 'up' | 'down' | null) => void;
  setClearedFloor: (floor: number, cleared: boolean) => void;
  setIsDescending: (descending: boolean) => void;
  climbDownFloor: () => void;
  exitSpireMode: () => void;
  startClimbUp: () => void;
  startClimbDown: () => void;

  // Golemancy
  toggleGolem: (golemId: string) => void;
  setEnabledGolems: (golemIds: string[]) => void;

  // Spells
  learnSpell: (spellId: string) => void;
  setSpellState: (spellId: string, state: Partial<SpellState>) => void;

  // Activity Log
  addActivityLog: (eventType: ActivityEventType, message: string, details?: ActivityLogEntry['details']) => void;

  // Stats
  incrementSpellsCast: () => void;
  addDamageDealt: (damage: number) => void;
  incrementCraftsCompleted: () => void;

  // Spire mode
  enterSpireMode: () => void;

  // Combat tick
  processCombatTick: (
    rawMana: number,
    elements: Record<string, { current: number; max: number; unlocked: boolean }>,
    maxMana: number,
    attackSpeedMult: number,
    onFloorCleared: (floor: number, wasGuardian: boolean) => void,
    onDamageDealt: (damage: number) => { rawMana: number; elements: Record<string, { current: number; max: number; unlocked: boolean }> },
  ) => { rawMana: number; elements: Record<string, { current: number; max: number; unlocked: boolean }>; logMessages: string[]; totalManaGathered: number };

  // Reset
  resetCombat: (startFloor: number, spellsToKeep?: string[]) => void;

  // Debug helpers
  debugSetFloor: (floor: number) => void;
  resetFloorHP: () => void;
  debugSetTime: (day: number, hour: number) => void;
}
