Renamed zone > map
This commit is contained in:
25
src/events/gameMaster/mapEditor/list.ts
Normal file
25
src/events/gameMaster/mapEditor/list.ts
Normal file
@ -0,0 +1,25 @@
|
||||
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_editor: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 created a new map via map editor.`)
|
||||
|
||||
const maps = await MapRepository.getAll()
|
||||
return callback(maps)
|
||||
} catch (error: any) {
|
||||
this.logger.error('gm:map_editor:map:list error', error.message)
|
||||
return callback([])
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user