Class: Lomic::GameState

Inherits:
Object
  • Object
show all
Defined in:
lib/lomic/GameState.rb

Instance Method Summary collapse

Constructor Details

#initializeGameState

Returns a new instance of GameState.



6
7
8
9
10
11
# File 'lib/lomic/GameState.rb', line 6

def initialize
  super
  @globals
  @rules = []
  @em = EventEngine.new
end

Instance Method Details

#addRule(rule) ⇒ Object



26
27
28
# File 'lib/lomic/GameState.rb', line 26

def addRule(rule)
  @rules.push(rule)
end

#globalsObject



13
14
15
# File 'lib/lomic/GameState.rb', line 13

def globals
  @globals
end

#globals=(globals_obj) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/lomic/GameState.rb', line 17

def globals=(globals_obj)
  return if @globals.nil? == false
  @globals = globals_obj
  klass = @globals.class
  
  klass.new_var :rules => []
  @globals.rules = @rules
end

#run(event_name, socket) ⇒ Object



30
31
32
# File 'lib/lomic/GameState.rb', line 30

def run(event_name,socket)
  @em.run(event_name,@globals.rules,socket)
end