// The roster board (design §6): role × venue = level select. A role is a lens
// + verb-set over the ONE simulation — picking a shift picks where you stand
// when the doors open, not which game you're playing. Wages are what the
// board says they are; the tips are your business.

import type { VenueDef } from './venues';

export type RoleId = 'glassie' | 'bartender' | 'doorgirl' | 'bouncer' | 'dj' | 'hos';

export interface RoleDef {
  id: RoleId;
  name: string;
  /** What the board admits the shift pays. */
  wage: number;
  /** The board's own words. */
  blurb: string;
  /** Where you stand when the doors open. */
  startLoc: 'door' | 'floor';
  /** Walk straight onto a post: the taps or the decks. */
  post?: 'taps' | 'decks';
  /** Venue ids where this shift is on the board (venue ladder, design §6). */
  venues: readonly string[];
}

export const ROLES: readonly RoleDef[] = [
  {
    id: 'glassie',
    name: 'GLASSIE',
    wage: 120,
    blurb: 'zero authority. all glasses. you will SEE things',
    startLoc: 'floor',
    venues: ['theRoyal'],
  },
  {
    id: 'bartender',
    name: 'BARTENDER',
    wage: 160,
    blurb: 'the taps, the tabs, the RSA line. nobody cooked gets a pour',
    startLoc: 'floor',
    post: 'taps',
    venues: ['theRoyal', 'voltage'],
  },
  {
    id: 'doorgirl',
    name: 'DOOR',
    wage: 180,
    blurb: 'the rope, the IDs, the whole street watching you decide',
    startLoc: 'door',
    venues: ['theRoyal', 'voltage'],
  },
  {
    id: 'bouncer',
    name: 'BOUNCER',
    wage: 190,
    blurb: 'the floor, the stalls, the yard. walk it like you mean it',
    startLoc: 'floor',
    venues: ['voltage'],
  },
  {
    id: 'dj',
    name: 'DJ',
    wage: 220,
    blurb: 'hold the decks. the room is a meter and youre the needle',
    startLoc: 'floor',
    post: 'decks',
    venues: ['room'],
  },
  {
    id: 'hos',
    name: 'HEAD OF SECURITY',
    wage: 260,
    blurb: 'door, floor, radio. everything, at once, all night',
    startLoc: 'door',
    venues: ['elevate', 'room'],
  },
];

export function rolesFor(venueId: string): RoleDef[] {
  return ROLES.filter((r) => r.venues.includes(venueId));
}

export function roleById(id: string | undefined): RoleDef | undefined {
  return ROLES.find((r) => r.id === id);
}

/** Booting a night without the board (dev routes): the sensible default. */
export function defaultRoleFor(venue: VenueDef): RoleDef {
  return rolesFor(venue.id).find((r) => r.startLoc === 'door') ?? ROLES.find((r) => r.id === 'hos')!;
}
