25 lines
695 B
TypeScript
25 lines
695 B
TypeScript
import { Server } from 'socket.io'
|
|
import { TSocket } from '../../../utilities/Types'
|
|
import { Object } from '@prisma/client'
|
|
import ObjectRepository from '../../../repositories/ObjectRepository'
|
|
|
|
interface IPayload {}
|
|
|
|
/**
|
|
* Handle game master list object event
|
|
* @param socket
|
|
* @param io
|
|
*/
|
|
export default function (socket: TSocket, io: Server) {
|
|
socket.on('gm:object:list', async (data: any, callback: (response: Object[]) => void) => {
|
|
if (socket.character?.role !== 'gm') {
|
|
console.log(`---Character #${socket.character?.id} is not a game master.`)
|
|
return
|
|
}
|
|
|
|
// get all objects
|
|
const objects = await ObjectRepository.getAll()
|
|
callback(objects)
|
|
})
|
|
}
|