forked from noxious/server
OOP is my passion ( ͡° ͜ʖ ͡°)
This commit is contained in:
@ -1,5 +1,3 @@
|
||||
import { Server } from 'socket.io'
|
||||
|
||||
import { CommandRegistry } from '#application/console/commandRegistry'
|
||||
import { ConsolePrompt } from '#application/console/consolePrompt'
|
||||
import { LogReader } from '#application/console/logReader'
|
||||
|
@ -2,8 +2,8 @@ import { Server } from 'socket.io'
|
||||
|
||||
import Logger, { LoggerType } from '#application/logger'
|
||||
import SocketManager from '#managers/socketManager'
|
||||
import worldRepository from '#repositories/worldRepository'
|
||||
import worldService from '#services/worldService'
|
||||
import WorldRepository from '#repositories/worldRepository'
|
||||
import WorldService from '#services/worldService'
|
||||
|
||||
class DateManager {
|
||||
private static readonly CONFIG = {
|
||||
@ -47,6 +47,7 @@ class DateManager {
|
||||
|
||||
private async loadDate(): Promise<void> {
|
||||
try {
|
||||
const worldRepository = new WorldRepository()
|
||||
const world = await worldRepository.getFirst()
|
||||
this.currentDate = world?.date ?? new Date()
|
||||
} catch (error) {
|
||||
@ -88,7 +89,7 @@ class DateManager {
|
||||
|
||||
private async saveDate(): Promise<void> {
|
||||
try {
|
||||
await worldService.update({ date: this.currentDate })
|
||||
await WorldService.update({ date: this.currentDate })
|
||||
} catch (error) {
|
||||
this.handleError('Failed to save date', error)
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ class MapManager {
|
||||
private logger = Logger.type(LoggerType.GAME)
|
||||
|
||||
public async boot(): Promise<void> {
|
||||
const maps = await MapRepository.getAll()
|
||||
const mapRepository = new MapRepository()
|
||||
const maps = await mapRepository.getAll()
|
||||
await Promise.all(maps.map((map) => this.loadMap(map)))
|
||||
|
||||
this.logger.info(`Map manager loaded with ${Object.keys(this.maps).length} maps`)
|
||||
@ -47,4 +48,4 @@ class MapManager {
|
||||
}
|
||||
}
|
||||
|
||||
export default new MapManager()
|
||||
export default new MapManager()
|
||||
|
@ -2,8 +2,8 @@ import { Server } from 'socket.io'
|
||||
|
||||
import Logger, { LoggerType } from '#application/logger'
|
||||
import SocketManager from '#managers/socketManager'
|
||||
import worldRepository from '#repositories/worldRepository'
|
||||
import worldService from '#services/worldService'
|
||||
import WorldRepository from '#repositories/worldRepository'
|
||||
import WorldService from '#services/worldService'
|
||||
|
||||
type WeatherState = {
|
||||
isRainEnabled: boolean
|
||||
@ -59,6 +59,7 @@ class WeatherManager {
|
||||
|
||||
private async loadWeather(): Promise<void> {
|
||||
try {
|
||||
const worldRepository = new WorldRepository()
|
||||
const world = await worldRepository.getFirst()
|
||||
if (world) {
|
||||
this.weatherState = {
|
||||
@ -112,7 +113,7 @@ class WeatherManager {
|
||||
|
||||
private async saveWeather(): Promise<void> {
|
||||
try {
|
||||
await worldService.update(this.weatherState)
|
||||
await WorldService.update(this.weatherState)
|
||||
} catch (error) {
|
||||
this.logError('save', error)
|
||||
}
|
||||
|
Reference in New Issue
Block a user