1
0
forked from noxious/server

GM event fixes

This commit is contained in:
2024-09-21 00:42:08 +02:00
parent 0a629bf80f
commit 6b2433f814
20 changed files with 105 additions and 72 deletions

View File

@ -2,6 +2,7 @@ import { Server } from 'socket.io'
import { TSocket } from '../../../../utilities/types'
import prisma from '../../../../utilities/prisma'
import CharacterManager from '../../../../managers/characterManager'
import characterRepository from '../../../../repositories/characterRepository'
type Payload = {
id: string
@ -22,9 +23,11 @@ type Payload = {
*/
export default function (socket: TSocket, io: Server) {
socket.on('gm:object:update', async (data: Payload, callback: (success: boolean) => void) => {
const character = CharacterManager.getCharacterFromSocket(socket);
if (character?.role !== 'gm') {
return
const character = await characterRepository.getById(socket.characterId as number);
if (!character) return callback(false)
if (character.role !== 'gm') {
return callback(false)
}
try {