forked from noxious/server
Moved models to simplify and improve prisma schemas , added logic to update characterTypes
This commit is contained in:
@ -28,26 +28,23 @@ export default class AlertCommandEvent {
|
||||
const character = await CharacterRepository.getByUserAndId(this.socket.userId!, this.socket.characterId!)
|
||||
if (!character) {
|
||||
gameLogger.error('chat:alert_command error', 'Character not found')
|
||||
callback(false)
|
||||
return
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
// Check if the user is the GM
|
||||
if (character.role !== 'gm') {
|
||||
gameLogger.info(`User ${character.id} tried to set time but is not a game master.`)
|
||||
callback(false)
|
||||
return
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
const args = getArgs('alert', data.message)
|
||||
|
||||
if (!args) {
|
||||
callback(false)
|
||||
return
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
this.io.emit('notification', { title: 'Message from GM', message: args.join(' ') })
|
||||
callback(true)
|
||||
return callback(true)
|
||||
} catch (error: any) {
|
||||
gameLogger.error('chat:alert_command error', error.message)
|
||||
callback(false)
|
||||
|
@ -29,14 +29,12 @@ export default class SetTimeCommand {
|
||||
const character = await CharacterRepository.getByUserAndId(this.socket.userId!, this.socket.characterId!)
|
||||
if (!character) {
|
||||
gameLogger.error('chat:alert_command error', 'Character not found')
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the user is the GM
|
||||
if (character.role !== 'gm') {
|
||||
gameLogger.info(`User ${character.id} tried to set time but is not a game master.`)
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
@ -44,20 +42,16 @@ export default class SetTimeCommand {
|
||||
const args = getArgs('time', data.message)
|
||||
|
||||
if (!args) {
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
const time = args[0] // 24h time, e.g. 17:34
|
||||
|
||||
if (!time) {
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
await DateManager.setTime(time)
|
||||
|
||||
callback(true)
|
||||
} catch (error: any) {
|
||||
gameLogger.error('command error', error.message)
|
||||
callback(false)
|
||||
|
@ -26,7 +26,6 @@ export default class TeleportCommandEvent {
|
||||
const zoneCharacter = ZoneManager.getCharacter(this.socket.characterId!)
|
||||
if (!zoneCharacter) {
|
||||
gameLogger.error('chat:message error', 'Character not found')
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
@ -35,7 +34,6 @@ export default class TeleportCommandEvent {
|
||||
// Check if the user is the GM
|
||||
if (character.role !== 'gm') {
|
||||
gameLogger.info(`User ${character.id} tried to set time but is not a game master.`)
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
@ -86,8 +84,6 @@ export default class TeleportCommandEvent {
|
||||
|
||||
this.socket.emit('notification', { title: 'Server message', message: `You have been teleported to ${zone.name}` })
|
||||
gameMasterLogger.info('teleport', `Character ${character.id} teleported to zone ${zone.id}`)
|
||||
|
||||
callback(true)
|
||||
} catch (error: any) {
|
||||
gameMasterLogger.error(`Error in teleport command: ${error.message}`)
|
||||
this.socket.emit('notification', { title: 'Server message', message: 'An error occurred while teleporting' })
|
||||
|
@ -29,20 +29,16 @@ export default class ToggleFogCommand {
|
||||
const character = await CharacterRepository.getByUserAndId(this.socket.userId!, this.socket.characterId!)
|
||||
if (!character) {
|
||||
gameLogger.error('chat:alert_command error', 'Character not found')
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the user is the GM
|
||||
if (character.role !== 'gm') {
|
||||
gameLogger.info(`User ${character.id} tried to set time but is not a game master.`)
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
await WeatherManager.toggleFog()
|
||||
|
||||
callback(true)
|
||||
} catch (error: any) {
|
||||
gameLogger.error('command error', error.message)
|
||||
callback(false)
|
||||
|
@ -29,20 +29,16 @@ export default class ToggleRainCommand {
|
||||
const character = await CharacterRepository.getByUserAndId(this.socket.userId!, this.socket.characterId!)
|
||||
if (!character) {
|
||||
gameLogger.error('chat:alert_command error', 'Character not found')
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the user is the GM
|
||||
if (character.role !== 'gm') {
|
||||
gameLogger.info(`User ${character.id} tried to set time but is not a game master.`)
|
||||
callback(false)
|
||||
return
|
||||
}
|
||||
|
||||
await WeatherManager.toggleRain()
|
||||
|
||||
callback(true)
|
||||
} catch (error: any) {
|
||||
gameLogger.error('command error', error.message)
|
||||
callback(false)
|
||||
|
Reference in New Issue
Block a user