// ============================================================
// PolyCity — central game configuration & balance data
// ============================================================

export const GRID = 64;
export const TILE = 1; // world units per tile
export const START_MONEY = 20000;

export const ZONE = { NONE: 0, RES: 1, COM: 2, IND: 3 };
export const STRUCT = {
  NONE: 0, ROAD: 1,
  COAL: 2, SOLAR: 3, WIND: 4,
  POLICE: 5, FIRE: 6, HOSPITAL: 7, SCHOOL: 8,
  PARK: 9, PLAZA: 10, STADIUM: 11
};

export const ROAD_COST = 10;
export const BRIDGE_COST = 120;   // road over water
export const BULLDOZE_COST = 3;
export const TAX_DEFAULT = 9;     // percent

// --- Power ---------------------------------------------------
export const ZONE_POWER = { 1: [12, 32, 72], 2: [20, 48, 104], 3: [32, 80, 176] };

// --- Zone capacities per level -------------------------------
export const ZONE_POP  = { 1: [6, 16, 36] };
export const ZONE_JOBS = { 2: [8, 20, 42], 3: [10, 26, 52] };

// --- Land value thresholds for upgrading to level 2 / 3 ------
// Neighborhoods mature with age, adding up to +12 effective LV.
export const LV_UPGRADE = { 2: 34, 3: 74 };

// ============================================================
// Placeable buildings (services + utilities)
// ============================================================
export const BUILDINGS = {
  [STRUCT.ROAD]: {
    id: 'road', name: 'Road', cost: ROAD_COST, bridgeCost: BRIDGE_COST,
    w: 1, h: 1, upkeep: 1, cat: 'transport',
    desc: 'Connects everything. Zones must be built within 2 tiles of a road. Conducts power.',
    hotkey: 'r'
  },
  [STRUCT.COAL]: {
    id: 'coal', name: 'Coal Power Plant', cost: 3200, w: 2, h: 2,
    upkeep: 180, power: 6000, pollution: 46, pollutionRadius: 11, radius: 0,
    cat: 'power', desc: 'Cheap, dirty energy for ~6000 units. Keep it downwind of homes.', hotkey: ''
  },
  [STRUCT.SOLAR]: {
    id: 'solar', name: 'Solar Farm', cost: 4800, w: 2, h: 2,
    upkeep: 70, power: 2400, pollution: 0, pollutionRadius: 0, radius: 0,
    cat: 'power', desc: 'Clean energy for ~2400 units. Pricey upkeep, zero pollution.', hotkey: ''
  },
  [STRUCT.WIND]: {
    id: 'wind', name: 'Wind Turbine', cost: 1100, w: 1, h: 1,
    upkeep: 30, power: 750, pollution: 0, pollutionRadius: 0, radius: 0,
    cat: 'power', desc: 'Compact clean energy (~750). +50% output next to water.', hotkey: ''
  },
  [STRUCT.POLICE]: {
    id: 'police', name: 'Police Station', cost: 650, w: 1, h: 1,
    upkeep: 60, radius: 14, cat: 'safety',
    desc: 'Cuts crime nearby — boosts land value & happiness in radius.', hotkey: ''
  },
  [STRUCT.FIRE]: {
    id: 'fire', name: 'Fire Station', cost: 650, w: 1, h: 1,
    upkeep: 60, radius: 14, cat: 'safety',
    desc: 'Extinguishes fires in radius fast and prevents most ignitions.', hotkey: ''
  },
  [STRUCT.HOSPITAL]: {
    id: 'hospital', name: 'Hospital', cost: 1500, w: 1, h: 1,
    upkeep: 140, radius: 13, cat: 'health',
    desc: 'Healthy citizens are happy citizens. Big residential boost.', hotkey: ''
  },
  [STRUCT.SCHOOL]: {
    id: 'school', name: 'School', cost: 1000, w: 1, h: 1,
    upkeep: 100, radius: 13, cat: 'education',
    desc: 'Educated workers attract better industry and raise land value.', hotkey: ''
  },
  [STRUCT.PARK]: {
    id: 'park', name: 'Small Park', cost: 160, w: 1, h: 1,
    upkeep: 8, radius: 7, cat: 'leisure',
    desc: 'A patch of green. Cheap land-value magic for dense blocks.', hotkey: ''
  },
  [STRUCT.PLAZA]: {
    id: 'plaza', name: 'Fountain Plaza', cost: 240, w: 1, h: 1,
    upkeep: 12, radius: 7, cat: 'leisure',
    desc: 'Classy marble plaza. Stronger boost than a park.', hotkey: ''
  },
  [STRUCT.STADIUM]: {
    id: 'stadium', name: 'Stadium', cost: 4200, w: 2, h: 2,
    upkeep: 200, radius: 16, cat: 'leisure',
    desc: 'The pride of the city — huge happiness & land value aura.', hotkey: ''
  }
};

// Buildings that must touch a road (within Chebyshev distance 2) to work.
export const NEEDS_ROAD = new Set([
  STRUCT.COAL, STRUCT.SOLAR, STRUCT.WIND, STRUCT.POLICE, STRUCT.FIRE,
  STRUCT.HOSPITAL, STRUCT.SCHOOL, STRUCT.STADIUM
]);

// ============================================================
// Simulation tuning
// ============================================================
export const SIM = {
  msPerMonth: [0, 5000, 1800, 700],   // by speed index 0..3
  growthAttemptsBase: 55,
  upgradeSamplesPerMonth: 70,
  fireBaseChance: 0.00045,
  disasterMinMonth: 30,   // grace period before tornadoes can spawn
  disasterChance: 0.0022, // per-month probability once eligible
  fireSpreadChance: 0.06,
  abandonAfterBadPowerMonths: 2,
  autosaveEveryMonths: 12,
  milestonePops: [
    [0, 'Outpost'], [100, 'Settlement'], [500, 'Village'], [1500, 'Town'],
    [5000, 'City'], [12000, 'Metropolis'], [30000, 'Megalopolis']
  ],
  // tax income multipliers per month
  taxRes: 7, taxCom: 8, taxInd: 7,
  roadExpensePerTile: 1,
  maxDebtWarning: -2000
};

export const CARS = { max: 90, perPop: 1 / 90, perRoad: 1 / 7 };

export const SAVE_KEY = 'polycity.save.v1';
export const SETTINGS_KEY = 'polycity.settings.v1';
export const SEEN_HELP_KEY = 'polycity.helpSeen.v1';

export const MONTHS = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
