export type Notification = {
  id?: string
  title?: string
  message?: string
}

export type AssetDataT = {
  key: string
  data: string
  group: 'tiles' | 'objects' | 'sprites' | 'sprite_animations' | 'sound' | 'music' | 'ui' | 'font' | 'other'
  updatedAt: Date
  originX?: number
  originY?: number
  isAnimated?: boolean
  frameCount?: number
  frameWidth?: number
  frameHeight?: number
  frameRate?: number
}

export type Tile = {
  id: string
  name: string
  tags: any | null
  createdAt: Date
  updatedAt: Date
}

export type Object = {
  id: string
  name: string
  tags: any | null
  originX: number
  originY: number
  isAnimated: boolean
  frameRate: number
  frameWidth: number
  frameHeight: number
  createdAt: Date
  updatedAt: Date
  ZoneObject: ZoneObject[]
}

export type Item = {
  id: string
  name: string
  description: string | null
  itemType: ItemType
  stackable: boolean
  rarity: ItemRarity
  spriteId: string | null
  sprite?: Sprite
  createdAt: Date
  updatedAt: Date
}

export type ItemType = 'WEAPON' | 'HELMET' | 'CHEST' | 'LEGS' | 'BOOTS' | 'GLOVES' | 'RING' | 'NECKLACE'
export type ItemRarity = 'COMMON' | 'UNCOMMON' | 'RARE' | 'EPIC' | 'LEGENDARY'

export type Zone = {
  id: number
  name: string
  width: number
  height: number
  tiles: any | null
  pvp: boolean
  zoneEffects: ZoneEffect[]
  zoneEventTiles: ZoneEventTile[]
  zoneObjects: ZoneObject[]
  characters: Character[]
  chats: Chat[]
  createdAt: Date
  updatedAt: Date
}

export type ZoneEffect = {
  id: string
  zoneId: number
  zone: Zone
  effect: string
  strength: number
}

export type ZoneObject = {
  id: string
  zoneId: number
  zone: Zone
  objectId: string
  object: Object
  depth: number
  isRotated: boolean
  positionX: number
  positionY: number
}

export enum ZoneEventTileType {
  BLOCK = 'BLOCK',
  TELEPORT = 'TELEPORT',
  NPC = 'NPC',
  ITEM = 'ITEM'
}

export type ZoneEventTile = {
  id: string
  zoneId: number
  zone: Zone
  type: ZoneEventTileType
  positionX: number
  positionY: number
  teleport?: ZoneEventTileTeleport
}

export type ZoneEventTileTeleport = {
  id: string
  zoneEventTileId: string
  zoneEventTile: ZoneEventTile
  toZoneId: number
  toZone: Zone
  toPositionX: number
  toPositionY: number
  toRotation: number
}

export type User = {
  id: number
  username: string
  password: string
  characters: Character[]
}

export enum CharacterGender {
  MALE = 'MALE',
  FEMALE = 'FEMALE'
}

export enum CharacterRace {
  HUMAN = 'HUMAN',
  ELF = 'ELF',
  DWARF = 'DWARF',
  ORC = 'ORC',
  GOBLIN = 'GOBLIN'
}

export type CharacterType = {
  id: number
  name: string
  gender: CharacterGender
  race: CharacterRace
  isSelectable: boolean
  characters: Character[]
  spriteId?: string
  sprite?: Sprite
  createdAt: Date
  updatedAt: Date
}

export type CharacterHair = {
  id: number
  name: string
  spriteId: string
  sprite: Sprite
  gender: CharacterGender
  isSelectable: boolean
}

export type Character = {
  id: number
  userId: number
  user: User
  name: string
  hitpoints: number
  mana: number
  level: number
  experience: number
  alignment: number
  role: string
  positionX: number
  positionY: number
  rotation: number
  characterTypeId: number | null
  characterType: CharacterType | null
  characterHairId: number | null
  characterHair: CharacterHair | null
  zoneId: number
  zone: Zone
  chats: Chat[]
  items: CharacterItem[]
}

export type ZoneCharacter = {
  character: Character
  isMoving?: boolean
}

export type CharacterItem = {
  id: number
  characterId: number
  character: Character
  itemId: string
  item: Item
  quantity: number
}

export type Sprite = {
  id: string
  name: string
  createdAt: Date
  updatedAt: Date
  spriteActions: SpriteAction[]
  characterTypes: CharacterType[]
}

export type SpriteAction = {
  id: string
  spriteId: string
  sprite: Sprite
  action: string
  sprites: string[]
  originX: number
  originY: number
  isAnimated: boolean
  isLooping: boolean
  frameWidth: number
  frameHeight: number
  frameRate: number
}

export type Chat = {
  id: number
  characterId: number
  character: Character
  zoneId: number
  zone: Zone
  message: string
  createdAt: Date
}

export type WorldSettings = {
  date: Date
  isRainEnabled: boolean
  isFogEnabled: boolean
  fogDensity: number
}

export type WeatherState = {
  isRainEnabled: boolean
  rainPercentage: number
  isFogEnabled: boolean
  fogDensity: number
}
