import { preloadImage } from "./preloader.js"

export class Level {
  constructor(title, subtitle, maxHealth, threshold, startingValue, nbValue, musicPath, meteorPath, bossPath) {
    this.title = title
    this.subtitle = subtitle
    this.maxHealth = maxHealth
    this.startingValue = startingValue
    this.nbValue = nbValue
    this.threshold = threshold
    this.musicPath = musicPath
    this.meteorPath = meteorPath
    this.bossPath = bossPath
  }

  async loadLevel() {
    if (this.meteorPath) {
      this.meteorImg = await preloadImage(this.meteorPath)
      console.log('load custom meteor', this.meteorImg)
    } else {
      this.meteorImgList = []
      this.meteorImgList.push(await preloadImage("assets/img/meteors/meteor.webp"))
      this.meteorImgList.push(await preloadImage("assets/img/meteors/meteor_2.webp"))
      this.meteorImgList.push(await preloadImage("assets/img/meteors/meteor_3.webp"))
      this.meteorImgList.push(await preloadImage("assets/img/meteors/meteor_4.webp"))
      console.log('load meteor list', this.meteorImgList)
    }
    
    this.bossImg = await preloadImage(this.bossPath)
  }

}