Major refractor, cleaning and improvements.
This commit is contained in:
39
src/events/gameMaster/assetManager/tile/update.ts
Normal file
39
src/events/gameMaster/assetManager/tile/update.ts
Normal file
@ -0,0 +1,39 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user