/**
 * Focus System Constants
 *
 * Centralized focus modifiers used across the codebase.
 * Single source of truth for focus effects on energy, performance, and GPA.
 */

export type FocusType = 'Work Hard' | 'Balanced' | 'Slack Off' | 'Socialize';

/**
 * Focus energy modifiers - applied to peak energy calculation
 * Positive values increase energy cost, negative values decrease it
 *
 * - Work Hard: +10 energy cost (more effort, more tired)
 * - Slack Off: -10 energy cost (less effort, less tired)
 * - Socialize: +10 energy cost (social activities take energy)
 * - Balanced: 0 energy cost (neutral)
 */
export const FOCUS_ENERGY_MODIFIERS: Record<FocusType, number> = {
  'Work Hard': 10,
  'Slack Off': -10,
  'Socialize': 10,
  'Balanced': 0,
};

/**
 * Focus performance multipliers - applied to activity progress
 * Higher values = faster skill/performance gain
 *
 * - Work Hard: 1.0x (full progress)
 * - Balanced: 0.7x (moderate progress)
 * - Socialize: 0.5x (some progress, distracted)
 * - Slack Off: 0.2x (minimal progress)
 */
export const FOCUS_PERFORMANCE_MULTIPLIERS: Record<FocusType, number> = {
  'Work Hard': 1.0,
  'Balanced': 0.7,
  'Socialize': 0.5,
  'Slack Off': 0.2,
};

/**
 * Focus GPA modifiers - applied to education GPA changes
 * Modifies the range of random GPA change per week
 *
 * - Work Hard: +1 (random -1 to +2, bias toward improvement)
 * - Slack Off: -1 (random -1 to 0, bias toward decline)
 * - Balanced/Socialize: 0 (random -1 to +1, neutral)
 */
export const FOCUS_GPA_MODIFIERS: Record<FocusType, number> = {
  'Work Hard': 1,
  'Slack Off': -1,
  'Socialize': 0,
  'Balanced': 0,
};

/**
 * Learning activity focus modifiers - points gained per progress check
 */
export const LEARNING_FOCUS_MAP: Record<FocusType, number> = {
  'Work Hard': 25,
  'Balanced': 15,
  'Slack Off': 5,
  'Socialize': 10,
};

/**
 * Physical activity focus modifiers - points gained per progress check
 */
export const PHYSICAL_FOCUS_MAP: Record<FocusType, number> = {
  'Work Hard': 15,
  'Balanced': 10,
  'Slack Off': 3,
  'Socialize': 8,
};

/**
 * Focus definitions with descriptions (for UI display)
 */
export const FOCUS_DEFINITIONS = [
  {
    id: 1,
    name: 'Work Hard' as FocusType,
    description: 'Work hard to get ahead - higher energy cost but faster progress',
    energyModifier: FOCUS_ENERGY_MODIFIERS['Work Hard'],
  },
  {
    id: 2,
    name: 'Slack Off' as FocusType,
    description: 'Slack off to avoid stress - lower energy cost but slower progress',
    energyModifier: FOCUS_ENERGY_MODIFIERS['Slack Off'],
  },
  {
    id: 3,
    name: 'Socialize' as FocusType,
    description: 'Focus on social connections - higher energy but relationship benefits',
    energyModifier: FOCUS_ENERGY_MODIFIERS['Socialize'],
  },
  {
    id: 4,
    name: 'Balanced' as FocusType,
    description: 'Balance work and play - moderate progress with moderate energy',
    energyModifier: FOCUS_ENERGY_MODIFIERS['Balanced'],
  },
];

/**
 * Get focus by name
 */
export function getFocusByName(name: string): typeof FOCUS_DEFINITIONS[0] | undefined {
  return FOCUS_DEFINITIONS.find((f) => f.name === name);
}

/**
 * Get energy modifier for a focus type
 */
export function getEnergyModifier(focus: string): number {
  return FOCUS_ENERGY_MODIFIERS[focus as FocusType] ?? 0;
}

/**
 * Get performance multiplier for a focus type
 */
export function getPerformanceMultiplier(focus: string): number {
  return FOCUS_PERFORMANCE_MULTIPLIERS[focus as FocusType] ?? 0.7;
}

/**
 * Get GPA modifier for a focus type
 */
export function getGpaModifier(focus: string): number {
  return FOCUS_GPA_MODIFIERS[focus as FocusType] ?? 0;
}
