Class: Beefdump::Game::State

Inherits:
Object
  • Object
show all
Defined in:
lib/beefdump/game/state.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(players) ⇒ State

Returns a new instance of State.



7
8
9
# File 'lib/beefdump/game/state.rb', line 7

def initialize(players)
  @players = players
end

Instance Attribute Details

#gameObject (readonly)

Returns the value of attribute game.



5
6
7
# File 'lib/beefdump/game/state.rb', line 5

def game
  @game
end

#playersObject (readonly)

Returns the value of attribute players.



5
6
7
# File 'lib/beefdump/game/state.rb', line 5

def players
  @players
end

Class Method Details

.from_xml(xml, game) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/beefdump/game/state.rb', line 11

def self.from_xml(xml, game)
  players = []
  xml['players'].first['player'].each do |player|
    position = player['position'].first
    players << Game::Player.new(player['name'], OpenStruct.new({:x => position['x'].to_i, :y => position['y'].to_i}))
  end

  self.new(players)
end