forked from noxious/server
More event progress
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
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 SocketManager from '#managers/socketManager'
|
||||
|
||||
class DateManager {
|
||||
private static readonly CONFIG = {
|
||||
GAME_SPEED: 8, // 24 game hours / 3 real hours
|
||||
UPDATE_INTERVAL: 1000, // 1 second
|
||||
UPDATE_INTERVAL: 1000 // 1 second
|
||||
} as const
|
||||
|
||||
private io: Server | null = null
|
||||
@ -98,4 +99,4 @@ class DateManager {
|
||||
}
|
||||
}
|
||||
|
||||
export default new DateManager()
|
||||
export default new DateManager()
|
||||
|
@ -1,8 +1,9 @@
|
||||
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 SocketManager from '#managers/socketManager'
|
||||
|
||||
type WeatherState = {
|
||||
isRainEnabled: boolean
|
||||
@ -91,22 +92,12 @@ class WeatherManager {
|
||||
private updateWeatherProperty(type: 'rain' | 'fog'): void {
|
||||
if (type === 'rain') {
|
||||
this.weatherState.isRainEnabled = !this.weatherState.isRainEnabled
|
||||
this.weatherState.rainPercentage = this.weatherState.isRainEnabled
|
||||
? this.getRandomNumber(
|
||||
WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.min,
|
||||
WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.max
|
||||
)
|
||||
: 0
|
||||
this.weatherState.rainPercentage = this.weatherState.isRainEnabled ? this.getRandomNumber(WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.min, WeatherManager.CONFIG.RAIN_PERCENTAGE_RANGE.max) : 0
|
||||
}
|
||||
|
||||
if (type === 'fog') {
|
||||
this.weatherState.isFogEnabled = !this.weatherState.isFogEnabled
|
||||
this.weatherState.fogDensity = this.weatherState.isFogEnabled
|
||||
? this.getRandomNumber(
|
||||
WeatherManager.CONFIG.FOG_DENSITY_RANGE.min,
|
||||
WeatherManager.CONFIG.FOG_DENSITY_RANGE.max
|
||||
)
|
||||
: 0
|
||||
this.weatherState.fogDensity = this.weatherState.isFogEnabled ? this.getRandomNumber(WeatherManager.CONFIG.FOG_DENSITY_RANGE.min, WeatherManager.CONFIG.FOG_DENSITY_RANGE.max) : 0
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,10 +123,8 @@ class WeatherManager {
|
||||
}
|
||||
|
||||
private logError(operation: string, error: unknown): void {
|
||||
this.logger.error(
|
||||
`Failed to ${operation} weather: ${error instanceof Error ? error.message : String(error)}`
|
||||
)
|
||||
this.logger.error(`Failed to ${operation} weather: ${error instanceof Error ? error.message : String(error)}`)
|
||||
}
|
||||
}
|
||||
|
||||
export default new WeatherManager()
|
||||
export default new WeatherManager()
|
||||
|
Reference in New Issue
Block a user