import { randomUUID } from 'node:crypto' import { BaseEntity } from '@/application/base/baseEntity' import type { UUID } from '@/application/types' import type { MapEffect } from '@/entities/mapEffect' import type { MapEventTile } from '@/entities/mapEventTile' import type { PlacedMapObject } from '@/entities/placedMapObject' import { Collection, OneToMany, PrimaryKey, Property } from '@mikro-orm/core' export class BaseMap extends BaseEntity { @PrimaryKey() id = randomUUID() @Property() name: string = '' @Property() width = 10 @Property() height = 10 @Property({ type: 'json' }) tiles: Array> = [] @Property() pvp = false @Property() createdAt = new Date() @Property() updatedAt = new Date() @OneToMany({ mappedBy: 'map', orphanRemoval: true }) mapEffects = new Collection(this) @OneToMany({ mappedBy: 'map', orphanRemoval: true }) mapEventTiles = new Collection(this) @OneToMany({ mappedBy: 'map', orphanRemoval: true }) placedMapObjects = new Collection(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) { this.mapEffects = mapEffects return this } getMapEffects() { return this.mapEffects } setMapEventTiles(mapEventTiles: Collection) { this.mapEventTiles = mapEventTiles return this } getMapEventTiles() { return this.mapEventTiles } setPlacedMapObjects(placedMapObjects: Collection) { this.placedMapObjects = placedMapObjects return this } getPlacedMapObjects() { return this.placedMapObjects } }