import prisma from '../utilities/prisma' import { gameLogger } from '../utilities/logger' import { World } from '@prisma/client' import WorldRepository from '../repositories/worldRepository' class WorldService { async update(worldData: Partial): Promise { try { const currentWorld = await WorldRepository.getFirst() if (!currentWorld) { // If no world exists, create first record await prisma.world.create({ data: { ...worldData, date: worldData.date || new Date() } }) return true } // Update existing world using its date as unique identifier await prisma.world.update({ where: { date: currentWorld.date }, data: worldData }) return true } catch (error: any) { gameLogger.error(`Failed to update world: ${error instanceof Error ? error.message : String(error)}`) return false } } } export default new WorldService()