185 lines
3.4 KiB
TypeScript
185 lines
3.4 KiB
TypeScript
import { randomUUID } from 'node:crypto'
|
|
|
|
import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
|
|
|
|
import { Character } from './character'
|
|
import { Chat } from './chat'
|
|
import { MapEffect } from './mapEffect'
|
|
import { MapEventTile } from './mapEventTile'
|
|
import { MapEventTileTeleport } from './mapEventTileTeleport'
|
|
|
|
import { BaseEntity } from '#application/base/baseEntity'
|
|
import { UUID } from '#application/types'
|
|
import { placedMapObject } from '#entities/placedMapObject'
|
|
|
|
@Entity()
|
|
export class Map extends BaseEntity {
|
|
@PrimaryKey()
|
|
id = randomUUID()
|
|
|
|
@Property()
|
|
name!: string
|
|
|
|
@Property()
|
|
width = 10
|
|
|
|
@Property()
|
|
height = 10
|
|
|
|
@Property({ type: 'json', nullable: true })
|
|
tiles?: any
|
|
|
|
@Property()
|
|
pvp = false
|
|
|
|
@Property()
|
|
createdAt = new Date()
|
|
|
|
@Property()
|
|
updatedAt = new Date()
|
|
|
|
@OneToMany(() => MapEffect, (effect) => effect.map)
|
|
mapEffects = new Collection<MapEffect>(this)
|
|
|
|
@OneToMany(() => MapEventTile, (tile) => tile.map)
|
|
mapEventTiles = new Collection<MapEventTile>(this)
|
|
|
|
@OneToMany(() => MapEventTileTeleport, (teleport) => teleport.toMap)
|
|
mapEventTileTeleports = new Collection<MapEventTileTeleport>(this)
|
|
|
|
@OneToMany(() => placedMapObject, (object) => object.map)
|
|
placedMapObjects = new Collection<placedMapObject>(this)
|
|
|
|
@OneToMany(() => Character, (character) => character.map)
|
|
characters = new Collection<Character>(this)
|
|
|
|
@OneToMany(() => Chat, (chat) => chat.map)
|
|
chats = new Collection<Chat>(this)
|
|
|
|
setId(id: UUID) {
|
|
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
|
|
}
|
|
|
|
setCreatedAt(createdAt: Date) {
|
|
this.createdAt = createdAt
|
|
return this
|
|
}
|
|
|
|
getCreatedAt() {
|
|
return this.createdAt
|
|
}
|
|
|
|
setUpdatedAt(updatedAt: Date) {
|
|
this.updatedAt = updatedAt
|
|
return this
|
|
}
|
|
|
|
getUpdatedAt() {
|
|
return this.updatedAt
|
|
}
|
|
|
|
setMapEffects(mapEffects: Collection<MapEffect>) {
|
|
this.mapEffects = mapEffects
|
|
return this
|
|
}
|
|
|
|
getMapEffects() {
|
|
return this.mapEffects
|
|
}
|
|
|
|
setMapEventTiles(mapEventTiles: Collection<MapEventTile>) {
|
|
this.mapEventTiles = mapEventTiles
|
|
return this
|
|
}
|
|
|
|
getMapEventTiles() {
|
|
return this.mapEventTiles
|
|
}
|
|
|
|
setMapEventTileTeleports(mapEventTileTeleports: Collection<MapEventTileTeleport>) {
|
|
this.mapEventTileTeleports = mapEventTileTeleports
|
|
return this
|
|
}
|
|
|
|
getMapEventTileTeleports() {
|
|
return this.mapEventTileTeleports
|
|
}
|
|
|
|
setPlacedMapObjects(placedMapObjects: Collection<placedMapObject>) {
|
|
this.placedMapObjects = placedMapObjects
|
|
return this
|
|
}
|
|
|
|
getPlacedMapObjects() {
|
|
return this.placedMapObjects
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|