// The venue ladder (design §6): each venue is a week of Thu→Fri→Sat, and a
// difficulty tier expressed as knobs on systems that already exist. Survive a
// week, get the next venue's door. Three strikes anywhere, the run dies.

export interface VenueDef {
  id: string;
  name: string;
  /** Dazza's blurb on the promotion screen. */
  pitch: string;
  licensed: number;
  /** Multiplies the arrival curve — how hard the queue slams. */
  arrivalScale: number;
  /**
   * How many of Dazza's rule texts fire this week (chronological prefix).
   * The live-rule cap (dressCode.ACTIVE_RULE_CAP) applies on top.
   */
  ruleLimit: number;
  /** Does the plainclothes inspector work this venue? */
  inspector: boolean;
  /**
   * Spawn-weight OVERRIDES merged over data/archetypes.ts — the venue's crowd
   * identity. Omitted keys keep their default weight.
   */
  archetypeWeights?: Partial<Record<import('./types').Archetype, number>>;
}

export const VENUES: readonly VenueDef[] = [
  {
    id: 'theRoyal',
    name: 'The Royal',
    pitch: 'a dive with a dance floor. nobody checks anything. u will',
    licensed: 80,
    arrivalScale: 0.8,
    ruleLimit: 4,
    inspector: false,
    // A local's pub that happens to have a dance floor: regulars and punters,
    // barely an influencer in sight.
    archetypeWeights: { regular: 14, influencer: 2, financeBro: 6, ownersMate: 2 },
  },
  {
    id: 'voltage',
    name: 'Voltage',
    pitch: 'valley institution. full rulebook. the inspector drinks here. lemonade',
    licensed: 110,
    arrivalScale: 1.0,
    ruleLimit: 8,
    inspector: true,
    // The balanced book — the tuning baseline. No overrides.
  },
  {
    id: 'elevate',
    name: 'Elevate',
    pitch: 'rooftop. small room, big opinions. every second person is a VIP apparently',
    licensed: 70,
    arrivalScale: 1.1,
    ruleLimit: 8,
    inspector: true,
    // Rooftop VIP politics: every second person is on a list, knows the owner,
    // or is filming. Regulars don't come here; they can't get in either.
    archetypeWeights: { influencer: 18, ownersMate: 7, financeBro: 14, punter: 38, regular: 3 },
  },
];

export const TOTAL_VENUES = VENUES.length;

export function venueByIndex(i: number): VenueDef {
  return VENUES[Math.max(0, Math.min(VENUES.length - 1, i))]!;
}

/** Week `w` (venue index) shifts the base night dates forward 7 days per week. */
export function nightDateFor(baseIso: string, venueIndex: number): string {
  const [y = '2026', m = '07', d = '16'] = baseIso.split('-');
  const date = new Date(Number(y), Number(m) - 1, Number(d) + venueIndex * 7);
  const mm = String(date.getMonth() + 1).padStart(2, '0');
  const dd = String(date.getDate()).padStart(2, '0');
  return `${date.getFullYear()}-${mm}-${dd}`;
}
