import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core' import { Character } from './character' import { Chat } from './chat' import { ZoneEffect } from './zoneEffect' import { ZoneEventTile } from './zoneEventTile' import { ZoneEventTileTeleport } from './zoneEventTileTeleport' import { ZoneObject } from './zoneObject' import { BaseEntity } from '#application/base/baseEntity' @Entity() export class Zone extends BaseEntity { @PrimaryKey() id!: number @Property() name!: string @Property() width = 10 @Property() height = 10 @Property({ type: 'json', nullable: true }) tiles?: any @Property() pvp = false @OneToMany(() => ZoneEffect, (effect) => effect.zone) zoneEffects = new Collection(this) @OneToMany(() => ZoneEventTile, (tile) => tile.zone) zoneEventTiles = new Collection(this) @OneToMany(() => ZoneEventTileTeleport, (teleport) => teleport.toZone) zoneEventTileTeleports = new Collection(this) @OneToMany(() => ZoneObject, (object) => object.zone) zoneObjects = new Collection(this) @OneToMany(() => Character, (character) => character.zone) characters = new Collection(this) @OneToMany(() => Chat, (chat) => chat.zone) chats = new Collection(this) @Property() createdAt = new Date() @Property() updatedAt = new Date() setId(id: number) { this.id = id return this } getId() { return this.id } setName(name: string) { this.name = name return this } getName() { return this.name } setWidth(width: number) { this.width = width return this } getWidth() { return this.width } setHeight(height: number) { this.height = height return this } getHeight() { return this.height } setTiles(tiles: any) { this.tiles = tiles return this } getTiles() { return this.tiles } setPvp(pvp: boolean) { this.pvp = pvp return this } getPvp() { return this.pvp } setZoneEffects(zoneEffects: Collection) { this.zoneEffects = zoneEffects return this } getZoneEffects() { return this.zoneEffects } setZoneEventTiles(zoneEventTiles: Collection) { this.zoneEventTiles = zoneEventTiles return this } getZoneEventTiles() { return this.zoneEventTiles } setZoneEventTileTeleports(zoneEventTileTeleports: Collection) { this.zoneEventTileTeleports = zoneEventTileTeleports return this } getZoneEventTileTeleports() { return this.zoneEventTileTeleports } setZoneObjects(zoneObjects: Collection) { this.zoneObjects = zoneObjects return this } getZoneObjects() { return this.zoneObjects } setCharacters(characters: Collection) { this.characters = characters return this } getCharacters() { return this.characters } setChats(chats: Collection) { this.chats = chats return this } getChats() { return this.chats } setCreatedAt(createdAt: Date) { this.createdAt = createdAt return this } getCreatedAt() { return this.createdAt } setUpdatedAt(updatedAt: Date) { this.updatedAt = updatedAt return this } getUpdatedAt() { return this.updatedAt } }