State.ts
1 import { Level, LevelManager } from './Level' 2 import { Storage } from './Storage' 3 4 class State { 5 private readonly storage: Storage 6 private levels: { [key: string]: Level } 7 8 public constructor() { 9 const levelManager = new LevelManager() 10 11 this.storage = new Storage(levelManager) 12 } 13 14 public getStorage(): Storage { 15 return this.storage 16 } 17 18 public loadLevels(): void { 19 this.levels = this.storage.getLevels() 20 } 21 22 public getLevels(): { [key: string]: Level } { 23 return this.levels 24 } 25 } 26 27 export const state = new State()