/
player.rb
28 lines (25 loc) · 918 Bytes
/
player.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Tassadar
module SC2
class Player
attr_accessor :id, :won, :color, :chosen_race, :actual_race, :handicap, :team
attr_writer :name
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]
@team = details_hash[5]
end
def winner?
@won
end
def name
@name.gsub("<sp/>","")
end
end
end
end