Continuation of refactor
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { gameLogger } from '#application/logger'
|
||||
import Logger, { LoggerType } from '#application/logger'
|
||||
import { Zone } from '#entities/zone'
|
||||
import LoadedZone from '#models/loadedZone'
|
||||
import ZoneCharacter from '#models/zoneCharacter'
|
||||
@ -6,23 +6,24 @@ import ZoneRepository from '#repositories/zoneRepository'
|
||||
|
||||
class ZoneManager {
|
||||
private readonly zones = new Map<number, LoadedZone>()
|
||||
private logger = Logger.type(LoggerType.GAME)
|
||||
|
||||
public async boot(): Promise<void> {
|
||||
const zones = await ZoneRepository.getAll()
|
||||
await Promise.all(zones.map((zone) => this.loadZone(zone)))
|
||||
|
||||
gameLogger.info(`Zone manager loaded with ${this.zones.size} zones`)
|
||||
this.logger.info(`Zone manager loaded with ${this.zones.size} zones`)
|
||||
}
|
||||
|
||||
public async loadZone(zone: Zone): Promise<void> {
|
||||
const loadedZone = new LoadedZone(zone)
|
||||
this.zones.set(zone.id, loadedZone)
|
||||
gameLogger.info(`Zone ID ${zone.id} loaded`)
|
||||
this.logger.info(`Zone ID ${zone.id} loaded`)
|
||||
}
|
||||
|
||||
public unloadZone(zoneId: number): void {
|
||||
this.zones.delete(zoneId)
|
||||
gameLogger.info(`Zone ID ${zoneId} unloaded`)
|
||||
this.logger.info(`Zone ID ${zoneId} unloaded`)
|
||||
}
|
||||
|
||||
public getLoadedZones(): LoadedZone[] {
|
||||
|
Reference in New Issue
Block a user