// Minimal typed slice of the IGDB v4 response shape — only the fields this
// project actually requests. See src/lib/igdb/client.ts for the query.
// Full field reference: https://api-docs.igdb.com/#games

export interface IgdbGame {
  id: number;
  name: string;
  slug: string;
  summary?: string;
  storyline?: string;
  first_release_date?: number; // unix seconds
  rating?: number; // 0-100, IGDB's aggregated rating
  rating_count?: number;
  url?: string;
  genres?: { name: string }[];
  platforms?: { name: string }[];
  game_modes?: { name: string }[];
  cover?: { image_id: string };
  screenshots?: { image_id: string }[];
  videos?: { video_id: string }[];
  age_ratings?: { rating: number; category: number }[];
  involved_companies?: {
    developer: boolean;
    publisher: boolean;
    company: { name: string };
  }[];
  websites?: { url: string; category: number }[];
  updated_at?: number;
}

export interface IgdbTokenResponse {
  access_token: string;
  expires_in: number;
  token_type: string;
}

// IGDB image size tokens. See https://api-docs.igdb.com/#images
export type IgdbImageSize =
  | 'cover_small'
  | 'cover_big'
  | 'screenshot_med'
  | 'screenshot_big'
  | 'screenshot_huge'
  | '1080p'
  | '720p';

export function igdbImageUrl(imageId: string, size: IgdbImageSize = '1080p'): string {
  return `https://images.igdb.com/igdb/image/upload/t_${size}/${imageId}.jpg`;
}
