 async = require 'async'
 {EventEmitter2: EventEmitter} = require 'eventemitter2'
+MersenneTwister = require 'mersennetwister'
 
 TimeManager = require './time-manager'
+Random = require './random'
 {Map} = require './map'
 
+{Dummy, FastDummy, Player} = require './creatures'
+
 {initialize, deinitialize, Renderer} = require './io/tty'
-
-{Dummy, FastDummy, Player} = require './creatures'
 
 class Game
 	constructor: ->
 		# console.error 'Starting game...'
-		@state = 'main menu'
+		@state = 'main-menu'
 
-		@timeManager = new TimeManager
 		@events = new EventEmitter
 			wildcard: yes
 			# newListener: yes

		initialize @
		@renderer = new Renderer @

		@currentMap = new Map @, 50, 15

		@entities = [


		@timeManager.targets.push @entities...

	quit: ->
		deinitialize @
		process.exit 0

	goState: (state) ->
		@events.emit "state.exit.#{@state}", 'exit', @state
		@state = state
		@events.emit "state.enter.#{@state}", 'enter', @state

		@renderer.invalidate()

	main: ->
		async.whilst (-> true),
			(next) =>
				switch @state
					when 'main-menu'
						@events.once 'key.s', =>
							@goState 'game'
							next()
