/**
 * World Events Database
 * Time-sensitive events that spawn based on conditions
 */

export const worldEvents = [
  {
    id: 'woodstock_1969',
    name: 'Woodstock Festival 1969',
    era: '1960s',
    location: { city: 'New York', country: 'USA' },
    duration: 3600000, // 1 hour
    spawnConditions: {
      timePeriod: '1960s',
      playerLevel: 3,
      randomChance: 0.1
    },
    rewards: {
      fans: 500,
      credits: 200,
      unlocks: ['psychedelic_master']
    },
    description: '🎸 The legendary Woodstock Festival is happening! Join the peace and music movement.',
    objectives: [
      { type: 'complete_challenge', genre: 'psychedelic', count: 3, current: 0, completed: false },
      { type: 'visit_location', target: 'any', count: 1, current: 0, completed: false }
    ],
    icon: '🎸'
  },

  {
    id: 'beatles_breakup',
    name: 'The Beatles Are Breaking Up',
    era: '1970s',
    location: { city: 'London', country: 'UK' },
    duration: 1800000, // 30 minutes
    spawnConditions: {
      timePeriod: '1970s',
      playerLevel: 2,
      randomChance: 0.08
    },
    rewards: {
      fans: 300,
      credits: 150
    },
    description: '💔 The Beatles are splitting up! Can you help preserve their legacy?',
    objectives: [
      { type: 'complete_challenge', genre: 'rock', count: 2, current: 0, completed: false }
    ],
    icon: '💔'
  },

  {
    id: 'bach_organ_repair',
    name: "Bach's Organ Needs Repair",
    era: '1720s',
    location: { city: 'Leipzig', country: 'Germany' },
    duration: 2700000, // 45 minutes
    spawnConditions: {
      timePeriod: '1720s',
      playerLevel: 2,
      randomChance: 0.12
    },
    rewards: {
      fans: 200,
      credits: 100,
      unlocks: ['organ_master']
    },
    description: '🎹 Bach\'s church organ has broken down before a major performance! Help repair it.',
    objectives: [
      { type: 'collect_materials', material: 'fine_wood', count: 5, current: 0, completed: false },
      { type: 'complete_challenge', genre: 'baroque', count: 1, current: 0, completed: false }
    ],
    icon: '🎹'
  },

  {
    id: 'elvis_drafting',
    name: 'Elvis Draft Notice',
    era: '1950s',
    location: { city: 'Memphis', country: 'USA' },
    duration: 1800000, // 30 minutes
    spawnConditions: {
      timePeriod: '1950s',
      playerLevel: 3,
      randomChance: 0.07
    },
    rewards: {
      fans: 400,
      credits: 180
    },
    description: '📬 Elvis received his draft notice! Help him before he joins the army.',
    objectives: [
      { type: 'complete_challenge', genre: 'rock', count: 3, current: 0, completed: false }
    ],
    icon: '📬'
  },

  {
    id: 'disco_demolition',
    name: 'Disco Demolition Night',
    era: '1970s',
    location: { city: 'Chicago', country: 'USA' },
    duration: 2400000, // 40 minutes
    spawnConditions: {
      timePeriod: '1970s',
      playerLevel: 2,
      randomChance: 0.09
    },
    rewards: {
      fans: 250,
      credits: 120
    },
    description: '🪩 Save disco music from being destroyed! Defend the genre.',
    objectives: [
      { type: 'complete_challenge', genre: 'disco', count: 2, current: 0, completed: false }
    ],
    icon: '🪩'
  },

  {
    id: 'hip_hop_birth',
    name: 'Birth of Hip Hop',
    era: '1970s',
    location: { city: 'New York', country: 'USA' },
    duration: 3000000, // 50 minutes
    spawnConditions: {
      timePeriod: '1970s',
      playerLevel: 2,
      randomChance: 0.1
    },
    rewards: {
      fans: 350,
      credits: 160,
      unlocks: ['hip_hop_pioneer']
    },
    description: '🎤 DJ Kool Herc is throwing the first hip hop party! Witness history.',
    objectives: [
      { type: 'visit_location', target: 'bronx', count: 1, current: 0, completed: false },
      { type: 'complete_challenge', genre: 'hip_hop', count: 1, current: 0, completed: false }
    ],
    icon: '🎤'
  },

  {
    id: 'monterey_pop_festival',
    name: 'Monterey Pop Festival',
    era: '1960s',
    location: { city: 'San Francisco', country: 'USA' },
    duration: 3600000, // 1 hour
    spawnConditions: {
      timePeriod: '1960s',
      playerLevel: 2,
      randomChance: 0.11
    },
    rewards: {
      fans: 450,
      credits: 190
    },
    description: '🌺 Summer of Love festival is underway! Join Hendrix, Joplin, and The Who.',
    objectives: [
      { type: 'complete_challenge', genre: 'rock', count: 2, current: 0, completed: false },
      { type: 'complete_challenge', genre: 'psychedelic', count: 1, current: 0, completed: false }
    ],
    icon: '🌺'
  },

  {
    id: 'motown_golden_age',
    name: 'Motown Golden Age',
    era: '1960s',
    location: { city: 'Detroit', country: 'USA' },
    duration: 2700000, // 45 minutes
    spawnConditions: {
      timePeriod: '1960s',
      playerLevel: 2,
      randomChance: 0.1
    },
    rewards: {
      fans: 300,
      credits: 140
    },
    description: '💫 Motown Records is in its golden age! Join the hit factory.',
    objectives: [
      { type: 'complete_challenge', genre: 'soul', count: 3, current: 0, completed: false }
    ],
    icon: '💫'
  },

  {
    id: 'live_aid',
    name: 'Live Aid Concert',
    era: '1980s',
    location: { city: 'London', country: 'UK' },
    duration: 3600000, // 1 hour
    spawnConditions: {
      timePeriod: '1980s',
      playerLevel: 3,
      randomChance: 0.08
    },
    rewards: {
      fans: 600,
      credits: 250,
      unlocks: ['stadium_performer']
    },
    description: '🌍 Global charity concert Live Aid is happening! Perform for the world.',
    objectives: [
      { type: 'complete_challenge', genre: 'rock', count: 2, current: 0, completed: false },
      { type: 'complete_challenge', genre: 'pop', count: 1, current: 0, completed: false }
    ],
    icon: '🌍'
  },

  {
    id: 'mtv_launch',
    name: 'MTV Launches',
    era: '1980s',
    location: { city: 'New York', country: 'USA' },
    duration: 2400000, // 40 minutes
    spawnConditions: {
      timePeriod: '1980s',
      playerLevel: 2,
      randomChance: 0.09
    },
    rewards: {
      fans: 350,
      credits: 170
    },
    description: '📺 MTV has launched! Create the first music videos.',
    objectives: [
      { type: 'complete_challenge', genre: 'pop', count: 3, current: 0, completed: false }
    ],
    icon: '📺'
  },

  {
    id: 'internet_music_revolution',
    name: 'Napster Revolution',
    era: '2000s',
    location: { city: 'San Francisco', country: 'USA' },
    duration: 1800000, // 30 minutes
    spawnConditions: {
      timePeriod: '2000s',
      playerLevel: 2,
      randomChance: 0.1
    },
    rewards: {
      fans: 280,
      credits: 130
    },
    description: '💿 The internet is changing music forever! Adapt or die.',
    objectives: [
      { type: 'complete_challenge', genre: 'any', count: 3, current: 0, completed: false }
    ],
    icon: '💿'
  },

  {
    id: 'streaming_era_begins',
    name: 'Streaming Era Begins',
    era: '2010s',
    location: { city: 'Stockholm', country: 'Sweden' },
    duration: 2100000, // 35 minutes
    spawnConditions: {
      timePeriod: '2010s',
      playerLevel: 2,
      randomChance: 0.11
    },
    rewards: {
      fans: 320,
      credits: 150
    },
    description: '🎧 Spotify has launched! The streaming revolution is here.',
    objectives: [
      { type: 'complete_challenge', genre: 'electronic', count: 2, current: 0, completed: false }
    ],
    icon: '🎧'
  }
];

/**
 * Get events available for current era and level
 */
export const getAvailableEvents = (era, playerLevel) => {
  return worldEvents.filter(event => 
    (!event.spawnConditions.timePeriod || event.spawnConditions.timePeriod === era) &&
    (!event.spawnConditions.playerLevel || playerLevel >= event.spawnConditions.playerLevel)
  );
};

/**
 * Get event by ID
 */
export const getEventById = (id) => {
  return worldEvents.find(e => e.id === id);
};

