1
0
forked from noxious/server
noxious_server/src/events/gm/tile/GmTileUpdate.ts

40 lines
791 B
TypeScript

import { Server } from 'socket.io'
import { TSocket } from '../../../utilities/Types'
import prisma from '../../../utilities/Prisma'
type Payload = {
id: string
name: string
tags: string[]
}
/**
* Handle game master tile update event
* @param socket
* @param io
*/
export default function (socket: TSocket, io: Server) {
socket.on('gm:tile:update', async (data: Payload, callback: (success: boolean) => void) => {
if (socket.character?.role !== 'gm') {
return
}
try {
const Tile = await prisma.tile.update({
where: {
id: data.id
},
data: {
name: data.name,
tags: data.tags
}
})
callback(true)
} catch (error) {
console.error(error)
callback(false)
}
})
}