Renamed zone > map

This commit is contained in:
2025-01-02 17:31:24 +01:00
parent 887da447e0
commit 11041fec83
54 changed files with 871 additions and 895 deletions

View File

@ -1,7 +1,7 @@
import { BaseEvent } from '#application/base/baseEvent'
import { UUID } from '#application/types'
import ZoneManager from '#managers/zoneManager'
import ZoneRepository from '#repositories/zoneRepository'
import MapManager from '#managers/mapManager'
import MapRepository from '#repositories/mapRepository'
import ChatService from '#services/chatService'
import TeleportService from '#services/teleportService'
@ -16,13 +16,13 @@ export default class TeleportCommandEvent extends BaseEvent {
private async handleEvent(data: TypePayload, callback: (response: boolean) => void) {
try {
const zoneCharacter = ZoneManager.getCharacterById(this.socket.characterId!)
if (!zoneCharacter) {
const mapCharacter = MapManager.getCharacterById(this.socket.characterId!)
if (!mapCharacter) {
this.logger.error('chat:message error', 'Character not found')
return
}
const character = zoneCharacter.character
const character = mapCharacter.character
if (character.role !== 'gm') {
this.logger.info(`User ${character.id} tried to set time but is not a game master.`)
@ -36,16 +36,16 @@ export default class TeleportCommandEvent extends BaseEvent {
if (!args || args.length === 0 || args.length > 3) {
this.socket.emit('notification', {
title: 'Server message',
message: 'Usage: /teleport <zoneId> [x] [y]'
message: 'Usage: /teleport <mapId> [x] [y]'
})
return
}
const zoneId = args[0] as UUID
const mapId = args[0] as UUID
const targetX = args[1] ? parseInt(args[1], 10) : 0
const targetY = args[2] ? parseInt(args[2], 10) : 0
if (!zoneId || isNaN(targetX) || isNaN(targetY)) {
if (!mapId || isNaN(targetX) || isNaN(targetY)) {
this.socket.emit('notification', {
title: 'Server message',
message: 'Invalid parameters. X and Y coordinates must be numbers.'
@ -53,16 +53,16 @@ export default class TeleportCommandEvent extends BaseEvent {
return
}
const zone = await ZoneRepository.getById(zoneId)
if (!zone) {
const map = await MapRepository.getById(mapId)
if (!map) {
this.socket.emit('notification', {
title: 'Server message',
message: 'Zone not found'
message: 'Map not found'
})
return
}
if (character.zone.id === zone.id && targetX === character.positionX && targetY === character.positionY) {
if (character.map.id === map.id && targetX === character.positionX && targetY === character.positionY) {
this.socket.emit('notification', {
title: 'Server message',
message: 'You are already at that location'
@ -71,7 +71,7 @@ export default class TeleportCommandEvent extends BaseEvent {
}
const success = await TeleportService.teleportCharacter(character.id, {
targetZoneId: zone.id,
targetMapId: map.id,
targetX,
targetY,
rotation: character.rotation
@ -86,9 +86,9 @@ export default class TeleportCommandEvent extends BaseEvent {
this.socket.emit('notification', {
title: 'Server message',
message: `Teleported to ${zone.name} (${targetX}, ${targetY})`
message: `Teleported to ${map.name} (${targetX}, ${targetY})`
})
this.logger.info('teleport', `Character ${character.id} teleported to zone ${zone.id} at position (${targetX}, ${targetY})`)
this.logger.info('teleport', `Character ${character.id} teleported to map ${map.id} at position (${targetX}, ${targetY})`)
} catch (error: any) {
this.logger.error(`Error in teleport command: ${error.message}`)
this.socket.emit('notification', {

View File

@ -1,6 +1,6 @@
import { BaseEvent } from '#application/base/baseEvent'
import ZoneManager from '#managers/zoneManager'
import ZoneRepository from '#repositories/zoneRepository'
import MapManager from '#managers/mapManager'
import MapRepository from '#repositories/mapRepository'
import ChatService from '#services/chatService'
type TypePayload = {
@ -18,21 +18,21 @@ export default class ChatMessageEvent extends BaseEvent {
return callback(false)
}
const zoneCharacter = ZoneManager.getCharacterById(this.socket.characterId!)
if (!zoneCharacter) {
const mapCharacter = MapManager.getCharacterById(this.socket.characterId!)
if (!mapCharacter) {
this.logger.error('chat:message error', 'Character not found')
return callback(false)
}
const character = zoneCharacter.character
const character = mapCharacter.character
const zone = await ZoneRepository.getById(character.zone.id)
if (!zone) {
this.logger.error('chat:message error', 'Zone not found')
const map = await MapRepository.getById(character.map.id)
if (!map) {
this.logger.error('chat:message error', 'Map not found')
return callback(false)
}
if (await ChatService.sendZoneMessage(character.getId(), zone.getId(), data.message)) {
if (await ChatService.sendMapMessage(character.getId(), map.getId(), data.message)) {
return callback(true)
}