forked from noxious/server
31 lines
843 B
TypeScript
31 lines
843 B
TypeScript
import { Server } from 'socket.io'
|
|
import { TSocket } from '../../../utilities/Types'
|
|
import { Zone } from '@prisma/client'
|
|
import ZoneRepository from '../../../repositories/ZoneRepository'
|
|
|
|
interface IPayload {}
|
|
|
|
/**
|
|
* Handle game master list zones event
|
|
* @param socket
|
|
* @param io
|
|
*/
|
|
export default function (socket: TSocket, io: Server) {
|
|
socket.on('gm:zone_editor:zone:list', async (data: IPayload, callback: (response: Zone[]) => void) => {
|
|
if (socket.character?.role !== 'gm') {
|
|
console.log(`---Character #${socket.character?.id} is not a game master.`)
|
|
return
|
|
}
|
|
|
|
console.log(`---GM ${socket.character?.id} has requested zone list via zone editor.`)
|
|
|
|
try {
|
|
const zones = await ZoneRepository.getAll()
|
|
callback(zones)
|
|
} catch (e) {
|
|
console.error(e)
|
|
callback([])
|
|
}
|
|
})
|
|
}
|