-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdepressing_game.ts
41 lines (35 loc) · 1.12 KB
/
depressing_game.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { VeryDepressingData, VERY_DEPRESSING_DATA } from './depressing_data'
import { FullGameComponent } from './depressing_ui'
import { DepressingState } from './depressing_state'
import { GameLogic, Broadcaster } from './depressing_logic'
import { createProjector } from './third-party/maquette'
declare global {
interface Window { game: DepressingGame; }
}
class DepressingGame {
data: VeryDepressingData
state: DepressingState
gameLogic: GameLogic
broadcaster: Broadcaster
fullGame: FullGameComponent
constructor() {
this.data = VERY_DEPRESSING_DATA
this.state = new DepressingState()
this.gameLogic = new GameLogic(this.state)
this.broadcaster = this.gameLogic.broadcaster()
this.fullGame = new FullGameComponent(this.state, this.broadcaster)
}
render() {
return this.fullGame.render()
}
}
// Initialize
export function initialize() {
let projector = createProjector()
let rootElem = document.getElementById('game')
let depressingGame = new DepressingGame()
if (rootElem !== null) {
projector.append(rootElem, () => depressingGame.render())
}
window.game = depressingGame
}