182 lines
3.3 KiB
TypeScript
182 lines
3.3 KiB
TypeScript
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<ZoneEffect>(this)
|
|
|
|
@OneToMany(() => ZoneEventTile, (tile) => tile.zone)
|
|
zoneEventTiles = new Collection<ZoneEventTile>(this)
|
|
|
|
@OneToMany(() => ZoneEventTileTeleport, (teleport) => teleport.toZone)
|
|
zoneEventTileTeleports = new Collection<ZoneEventTileTeleport>(this)
|
|
|
|
@OneToMany(() => ZoneObject, (object) => object.zone)
|
|
zoneObjects = new Collection<ZoneObject>(this)
|
|
|
|
@OneToMany(() => Character, (character) => character.zone)
|
|
characters = new Collection<Character>(this)
|
|
|
|
@OneToMany(() => Chat, (chat) => chat.zone)
|
|
chats = new Collection<Chat>(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<ZoneEffect>) {
|
|
this.zoneEffects = zoneEffects
|
|
return this
|
|
}
|
|
|
|
getZoneEffects() {
|
|
return this.zoneEffects
|
|
}
|
|
|
|
setZoneEventTiles(zoneEventTiles: Collection<ZoneEventTile>) {
|
|
this.zoneEventTiles = zoneEventTiles
|
|
return this
|
|
}
|
|
|
|
getZoneEventTiles() {
|
|
return this.zoneEventTiles
|
|
}
|
|
|
|
setZoneEventTileTeleports(zoneEventTileTeleports: Collection<ZoneEventTileTeleport>) {
|
|
this.zoneEventTileTeleports = zoneEventTileTeleports
|
|
return this
|
|
}
|
|
|
|
getZoneEventTileTeleports() {
|
|
return this.zoneEventTileTeleports
|
|
}
|
|
|
|
setZoneObjects(zoneObjects: Collection<ZoneObject>) {
|
|
this.zoneObjects = zoneObjects
|
|
return this
|
|
}
|
|
|
|
getZoneObjects() {
|
|
return this.zoneObjects
|
|
}
|
|
|
|
setCharacters(characters: Collection<Character>) {
|
|
this.characters = characters
|
|
return this
|
|
}
|
|
|
|
getCharacters() {
|
|
return this.characters
|
|
}
|
|
|
|
setChats(chats: Collection<Chat>) {
|
|
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
|
|
}
|
|
}
|