Removed depth field from placedMapObject as this is calculated automatically
This commit is contained in:
parent
189fd39377
commit
1546deb811
70
package-lock.json
generated
70
package-lock.json
generated
@ -1683,12 +1683,6 @@
|
|||||||
"@types/node": "*"
|
"@types/node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/cookie": {
|
|
||||||
"version": "0.4.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
|
|
||||||
"integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/@types/cors": {
|
"node_modules/@types/cors": {
|
||||||
"version": "2.8.17",
|
"version": "2.8.17",
|
||||||
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
|
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
|
||||||
@ -1732,9 +1726,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/geojson": {
|
"node_modules/@types/geojson": {
|
||||||
"version": "7946.0.15",
|
"version": "7946.0.16",
|
||||||
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz",
|
||||||
"integrity": "sha512-9oSxFzDCT2Rj6DfcHF8G++jxBKS7mBqXl5xrRW+Kbvjry6Uduya2iiwqHPhVXpasAVMBYKkEPGgKhd3+/HZ6xA==",
|
"integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/http-errors": {
|
"node_modules/@types/http-errors": {
|
||||||
@ -1785,9 +1779,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.17.14",
|
"version": "20.17.16",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.14.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.16.tgz",
|
||||||
"integrity": "sha512-w6qdYetNL5KRBiSClK/KWai+2IMEJuAj+EujKCumalFOwXtvOXaEan9AuwcRID2IcOIAWSIfR495hBtgKlx2zg==",
|
"integrity": "sha512-vOTpLduLkZXePLxHiHsBLp98mHGnl8RptV4YAO3HfKO5UHjDvySGbxKtpYfy8Sx5+WKcgc45qNreJJRVM3L6mw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.2"
|
"undici-types": "~6.19.2"
|
||||||
@ -2323,6 +2317,16 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/async-function": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz",
|
||||||
|
"integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/atomic-sleep": {
|
"node_modules/atomic-sleep": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/atomic-sleep/-/atomic-sleep-1.0.0.tgz",
|
||||||
@ -2458,9 +2462,9 @@
|
|||||||
"license": "BSD-3-Clause"
|
"license": "BSD-3-Clause"
|
||||||
},
|
},
|
||||||
"node_modules/bullmq": {
|
"node_modules/bullmq": {
|
||||||
"version": "5.34.10",
|
"version": "5.35.1",
|
||||||
"resolved": "https://registry.npmjs.org/bullmq/-/bullmq-5.34.10.tgz",
|
"resolved": "https://registry.npmjs.org/bullmq/-/bullmq-5.35.1.tgz",
|
||||||
"integrity": "sha512-ia6EzpQm1ZPq6GUBSLyfvzJrhdBTd1f3Gn2g9pFtLX4hBOob6QHmcmBzGgPlSCyr/i2Qfe4OdjS21bRd02srbw==",
|
"integrity": "sha512-LnzqisWyF4V8KhgFnK7iaJdQn9Q61EdHdCT6sVTzA3jZr6CHxw/OBmBZhzA8Xq4bsvsmvdjr8pmGftC78aWgXQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cron-parser": "^4.9.0",
|
"cron-parser": "^4.9.0",
|
||||||
@ -3030,17 +3034,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io": {
|
"node_modules/engine.io": {
|
||||||
"version": "6.6.2",
|
"version": "6.6.3",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.3.tgz",
|
||||||
"integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==",
|
"integrity": "sha512-2hkLItQMBkoYSagneiisupWGvsQlWXqzhSMvsjaM8GYbnfUsX7tzYQq9QARnate5LRedVTX+MbkSZAANAr3NtQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/cookie": "^0.4.1",
|
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/node": ">=10.0.0",
|
"@types/node": ">=10.0.0",
|
||||||
"accepts": "~1.3.4",
|
"accepts": "~1.3.4",
|
||||||
"base64id": "2.0.0",
|
"base64id": "2.0.0",
|
||||||
"cookie": "~0.7.2",
|
"cookie": "~1.0.2",
|
||||||
"cors": "~2.8.5",
|
"cors": "~2.8.5",
|
||||||
"debug": "~4.3.1",
|
"debug": "~4.3.1",
|
||||||
"engine.io-parser": "~5.2.1",
|
"engine.io-parser": "~5.2.1",
|
||||||
@ -3060,12 +3063,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io/node_modules/cookie": {
|
"node_modules/engine.io/node_modules/cookie": {
|
||||||
"version": "0.7.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/cookie/-/cookie-1.0.2.tgz",
|
||||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
"integrity": "sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.6"
|
"node": ">=18"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io/node_modules/debug": {
|
"node_modules/engine.io/node_modules/debug": {
|
||||||
@ -4493,12 +4496,13 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/is-async-function": {
|
"node_modules/is-async-function": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz",
|
||||||
"integrity": "sha512-GExz9MtyhlZyXYLxzlJRj5WUCE661zhDa1Yna52CN57AJsymh+DvXXjyveSioqSRdxvUrdKdvqB1b5cVKsNpWQ==",
|
"integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"async-function": "^1.0.0",
|
||||||
"call-bound": "^1.0.3",
|
"call-bound": "^1.0.3",
|
||||||
"get-proto": "^1.0.1",
|
"get-proto": "^1.0.1",
|
||||||
"has-tostringtag": "^1.0.2",
|
"has-tostringtag": "^1.0.2",
|
||||||
@ -5247,9 +5251,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mariadb/node_modules/@types/node": {
|
"node_modules/mariadb/node_modules/@types/node": {
|
||||||
"version": "22.10.7",
|
"version": "22.10.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.7.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz",
|
||||||
"integrity": "sha512-V09KvXxFiutGp6B7XkpaDXlNadZxrzajcY50EuoLIpQ6WWYCSvf19lVIazzfIzQvhUN2HjX12spLojTnhuKlGg==",
|
"integrity": "sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.20.0"
|
"undici-types": "~6.20.0"
|
||||||
@ -5526,9 +5530,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "6.9.16",
|
"version": "6.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.9.16.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.10.0.tgz",
|
||||||
"integrity": "sha512-psAuZdTIRN08HKVd/E8ObdV6NO7NTBY3KsC30F7M4H1OnmLCUNaS56FpYxyb26zWLSyYF9Ozch9KYHhHegsiOQ==",
|
"integrity": "sha512-SQ3wZCExjeSatLE/HBaXS5vqUOQk6GtBdIIKxiFdmm01mOQZX/POJkO3SUX1wDiYcwUOJwT23scFSC9fY2H8IA==",
|
||||||
"license": "MIT-0",
|
"license": "MIT-0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
|
@ -19,9 +19,6 @@ export class BasePlacedMapObject extends BaseEntity {
|
|||||||
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
@ManyToOne({ deleteRule: 'cascade', eager: true })
|
||||||
mapObject!: MapObject
|
mapObject!: MapObject
|
||||||
|
|
||||||
@Property()
|
|
||||||
depth = 0
|
|
||||||
|
|
||||||
@Property()
|
@Property()
|
||||||
isRotated = false
|
isRotated = false
|
||||||
|
|
||||||
@ -58,15 +55,6 @@ export class BasePlacedMapObject extends BaseEntity {
|
|||||||
return this.mapObject
|
return this.mapObject
|
||||||
}
|
}
|
||||||
|
|
||||||
setDepth(depth: number) {
|
|
||||||
this.depth = depth
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
getDepth() {
|
|
||||||
return this.depth
|
|
||||||
}
|
|
||||||
|
|
||||||
setIsRotated(isRotated: boolean) {
|
setIsRotated(isRotated: boolean) {
|
||||||
this.isRotated = isRotated
|
this.isRotated = isRotated
|
||||||
return this
|
return this
|
||||||
|
@ -2,6 +2,8 @@ import { Entity } from '@mikro-orm/core'
|
|||||||
|
|
||||||
import { BaseMap } from '#entities/base/map'
|
import { BaseMap } from '#entities/base/map'
|
||||||
|
|
||||||
|
export type MapCacheT = ReturnType<Map['cache']> | {}
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Map extends BaseMap {
|
export class Map extends BaseMap {
|
||||||
public async cache() {
|
public async cache() {
|
||||||
@ -20,7 +22,6 @@ export class Map extends BaseMap {
|
|||||||
placedMapObjects: this.getPlacedMapObjects().map((placedMapObject) => ({
|
placedMapObjects: this.getPlacedMapObjects().map((placedMapObject) => ({
|
||||||
id: placedMapObject.getId(),
|
id: placedMapObject.getId(),
|
||||||
mapObject: placedMapObject.getMapObject().getId(),
|
mapObject: placedMapObject.getMapObject().getId(),
|
||||||
depth: placedMapObject.getDepth(),
|
|
||||||
isRotated: placedMapObject.getIsRotated(),
|
isRotated: placedMapObject.getIsRotated(),
|
||||||
positionX: placedMapObject.getPositionX(),
|
positionX: placedMapObject.getPositionX(),
|
||||||
positionY: placedMapObject.getPositionY()
|
positionY: placedMapObject.getPositionY()
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { BaseEvent } from '#application/base/baseEvent'
|
import { BaseEvent } from '#application/base/baseEvent'
|
||||||
import { Map } from '#entities/map'
|
import { Map, MapCacheT } from '#entities/map'
|
||||||
import MapRepository from '#repositories/mapRepository'
|
|
||||||
|
|
||||||
type Payload = {
|
type Payload = {
|
||||||
name: string
|
name: string
|
||||||
@ -13,11 +12,11 @@ export default class MapCreateEvent extends BaseEvent {
|
|||||||
this.socket.on('gm:map:create', this.handleEvent.bind(this))
|
this.socket.on('gm:map:create', this.handleEvent.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleEvent(data: Payload, callback: (response: Map[]) => void): Promise<void> {
|
private async handleEvent(data: Payload, callback: (response: MapCacheT | false) => void): Promise<void> {
|
||||||
try {
|
try {
|
||||||
if (!(await this.isCharacterGM())) return
|
if (!(await this.isCharacterGM())) return
|
||||||
|
|
||||||
this.logger.info(`User ${(await this.getCharacter())!.getId()} has created a new map via map editor.`)
|
this.logger.info(`GM ${(await this.getCharacter())!.getId()} has created a new map via map editor.`)
|
||||||
|
|
||||||
const map = new Map()
|
const map = new Map()
|
||||||
await map
|
await map
|
||||||
@ -27,14 +26,11 @@ export default class MapCreateEvent extends BaseEvent {
|
|||||||
.setTiles(Array.from({ length: data.height }, () => Array.from({ length: data.width }, () => 'blank_tile')))
|
.setTiles(Array.from({ length: data.height }, () => Array.from({ length: data.width }, () => 'blank_tile')))
|
||||||
.save()
|
.save()
|
||||||
|
|
||||||
const mapRepository = new MapRepository()
|
return callback(await map.cache())
|
||||||
const mapList = await mapRepository.getAll()
|
|
||||||
|
|
||||||
return callback(mapList)
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
this.logger.error('gm:map:create error', error.message)
|
this.logger.error('gm:map:create error', error.message)
|
||||||
this.socket.emit('notification', { message: 'Failed to create map.' })
|
this.socket.emit('notification', { message: 'Failed to create map.' })
|
||||||
return callback([])
|
return callback(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
import { BaseEvent } from '#application/base/baseEvent'
|
|
||||||
import { Map } from '#entities/map'
|
|
||||||
import MapRepository from '#repositories/mapRepository'
|
|
||||||
|
|
||||||
interface IPayload {}
|
|
||||||
|
|
||||||
export default class MapListEvent extends BaseEvent {
|
|
||||||
public listen(): void {
|
|
||||||
this.socket.on('gm:map:list', this.handleEvent.bind(this))
|
|
||||||
}
|
|
||||||
|
|
||||||
private async handleEvent(data: IPayload, callback: (response: Map[]) => void): Promise<void> {
|
|
||||||
try {
|
|
||||||
if (!(await this.isCharacterGM())) return
|
|
||||||
|
|
||||||
this.logger.info(`User ${(await this.getCharacter())!.getId()} has listed maps via map editor.`)
|
|
||||||
|
|
||||||
const mapRepository = new MapRepository()
|
|
||||||
const maps = await mapRepository.getAll()
|
|
||||||
|
|
||||||
return callback(maps)
|
|
||||||
} catch (error: any) {
|
|
||||||
this.logger.error('gm:map:list error', error.message)
|
|
||||||
return callback([])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -97,7 +97,6 @@ export default class MapUpdateEvent extends BaseEvent {
|
|||||||
for (const object of data.placedMapObjects) {
|
for (const object of data.placedMapObjects) {
|
||||||
const mapObject = new PlacedMapObject()
|
const mapObject = new PlacedMapObject()
|
||||||
.setMapObject(object.mapObject)
|
.setMapObject(object.mapObject)
|
||||||
.setDepth(object.depth)
|
|
||||||
.setIsRotated(object.isRotated)
|
.setIsRotated(object.isRotated)
|
||||||
.setPositionX(object.positionX)
|
.setPositionX(object.positionX)
|
||||||
.setPositionY(object.positionY)
|
.setPositionY(object.positionY)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user