Class: Tassadar::SC2::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/tassadar/sc2/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(replay) ⇒ Game

Returns a new instance of Game.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/tassadar/sc2/game.rb', line 6

def initialize(replay)
  @winner = replay.players.select {|p| p.won}.first
  @time = convert_windows_to_ruby_date_time(replay.details.data[5], replay.details.data[6])
  @map = replay.details.data[1]
  @type = replay.attributes.attributes.select {|a| a.id == 2001}.first.attribute_value

  speeds = {"Fasr" => "Faster", "Slow" => "Slow", "Fast" => "Fast", "Norm" => "Normal", "Slor" => "Slower"}
  @speed = speeds[replay.attributes.attributes.select {|a| a.id == 3000}.first.attribute_value]

  categories = {"Amm" => "Ladder", "Priv" => "Private", "Pub" => "Public"}
  @category = categories[replay.attributes.attributes.select {|a| a.id == 3009}.first.attribute_value]
end

Instance Attribute Details

#categoryObject

Returns the value of attribute category.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def category
  @category
end

#mapObject

Returns the value of attribute map.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def map
  @map
end

#speedObject

Returns the value of attribute speed.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def speed
  @speed
end

#timeObject

Returns the value of attribute time.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def time
  @time
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def type
  @type
end

#winnerObject

Returns the value of attribute winner.



4
5
6
# File 'lib/tassadar/sc2/game.rb', line 4

def winner
  @winner
end