import type { Map, MapObject, Tile } from '@/application/types'
import { BaseStorage } from '@/storage/baseStorage'

export class MapStorage extends BaseStorage<Map> {
  constructor() {
    super('maps', 'id, name, createdAt, updatedAt')
  }
}

export class TileStorage extends BaseStorage<Tile> {
  constructor() {
    super('tiles', 'id, name, createdAt, updatedAt')
  }
}

export class MapObjectStorage extends BaseStorage<MapObject> {
  constructor() {
    super('mapObjects', 'id, name, createdAt, updatedAt')
  }
}

export class SpriteStorage extends BaseStorage<any> {
  constructor() {
    super('sprites', 'id, name, createdAt, updatedAt')
  }
}

export class CharacterTypeStorage extends BaseStorage<any> {
  constructor() {
    super('characterTypes', 'id, name, createdAt, updatedAt')
  }

  async getSpriteId(characterTypeId: string) {
    const characterType = await this.get(characterTypeId)
    return characterType?.sprite
  }
}

export class CharacterHairStorage extends BaseStorage<any> {
  constructor() {
    super('characterHairs', 'id, name, createdAt, updatedAt')
  }

  async getSpriteId(characterTypeId: string) {
    const characterType = await this.get(characterTypeId)
    return characterType?.sprite
  }
}

export class SoundStorage extends BaseStorage<{ id: string; name: string; base64: string }> {
  constructor() {
    super('sounds', 'id, name, createdAt, updatedAt')
  }
}
