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

@ -6,22 +6,22 @@ import { Chat } from '#entities/chat'
import SocketManager from '#managers/socketManager'
import CharacterRepository from '#repositories/characterRepository'
import ChatRepository from '#repositories/chatRepository'
import ZoneRepository from '#repositories/zoneRepository'
import MapRepository from '#repositories/mapRepository'
class ChatService extends BaseService {
async sendZoneMessage(characterId: UUID, zoneId: UUID, message: string): Promise<boolean> {
async sendMapMessage(characterId: UUID, mapId: UUID, message: string): Promise<boolean> {
try {
const character = await CharacterRepository.getById(characterId)
if (!character) return false
const zone = await ZoneRepository.getById(zoneId)
if (!zone) return false
const map = await MapRepository.getById(mapId)
if (!map) return false
const chat = new Chat()
await chat.setCharacter(character).setZone(zone).setMessage(message).save()
await chat.setCharacter(character).setMap(map).setMessage(message).save()
const io = SocketManager.getIO()
io.to(zoneId).emit('chat:message', chat)
io.to(mapId).emit('chat:message', chat)
return true
} catch (error: any) {
this.logger.error(`Failed to save chat message: ${error instanceof Error ? error.message : String(error)}`)