Class: Tassadar::SC2::Player

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(details_hash, attributes) ⇒ Player

Returns a new instance of Player.



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

def initialize(details_hash, attributes)
  @name = details_hash[0]
  @id = details_hash[1][4]
  @won = [false, true, false][details_hash[8]]
  @color = {:alpha => details_hash[3][0], :red => details_hash[3][1], :green => details_hash[3][2], :blue => details_hash[3][3]}
  races = {"Terr" => "Terran", "Prot" => "Protoss", "Zerg" => "Zerg", "RAND" => "Random"}
  @chosen_race = races[attributes.select {|a| a.id == 0x0BB9 && a.player_number == details_hash[7] + 1}.first.attribute_value]
  @actual_race = details_hash[2]
  @handicap = details_hash[6]
end

Instance Attribute Details

#actual_raceObject

Returns the value of attribute actual_race.



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

def actual_race
  @actual_race
end

#chosen_raceObject

Returns the value of attribute chosen_race.



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

def chosen_race
  @chosen_race
end

#colorObject

Returns the value of attribute color.



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

def color
  @color
end

#handicapObject

Returns the value of attribute handicap.



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

def handicap
  @handicap
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#wonObject

Returns the value of attribute won.



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

def won
  @won
end

Instance Method Details

#winner?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/tassadar/sc2/player.rb', line 17

def winner?
  @won
end