File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -239,3 +239,33 @@ func ConvertSteamID32To64(steamID32 uint32) uint64 {
239
239
func ConvertSteamID64To32 (steamID64 uint64 ) uint32 {
240
240
return uint32 (steamID64 - steamID64IndividualIdentifier )
241
241
}
242
+
243
+ // Color is the type for the various colors constants.
244
+ type Color int
245
+
246
+ // Color constants give information about which color a player has.
247
+ const (
248
+ Grey Color = iota - 1
249
+ Yellow
250
+ Purple
251
+ Green
252
+ Blue
253
+ Orange
254
+ )
255
+
256
+ var strColors = map [Color ]string {
257
+ Grey : "Grey" ,
258
+ Yellow : "Yellow" ,
259
+ Purple : "Purple" ,
260
+ Green : "Green" ,
261
+ Blue : "Blue" ,
262
+ Orange : "Orange" ,
263
+ }
264
+
265
+ func (c Color ) String () string {
266
+ if _ , exists := strColors [c ]; ! exists {
267
+ return "Unknown-Color"
268
+ }
269
+
270
+ return strColors [c ]
271
+ }
Original file line number Diff line number Diff line change @@ -376,6 +376,11 @@ func (p *Player) Score() int {
376
376
return getInt (p .ResourceEntity (), "m_iScore." + p .entityIDStr ())
377
377
}
378
378
379
+ // Color returns the players color as shown on the match.
380
+ func (p * Player ) Color () Color {
381
+ return Color (getInt (p .ResourceEntity (), "m_iCompTeammateColor." + p .entityIDStr ()))
382
+ }
383
+
379
384
// Kills returns the amount of kills the player has as shown on the scoreboard.
380
385
func (p * Player ) Kills () int {
381
386
return getInt (p .ResourceEntity (), "m_iKills." + p .entityIDStr ())
Original file line number Diff line number Diff line change @@ -389,6 +389,12 @@ func TestPlayer_Score(t *testing.T) {
389
389
assert .Equal (t , 10 , pl .Score ())
390
390
}
391
391
392
+ func TestPlayer_Color (t * testing.T ) {
393
+ pl := playerWithResourceProperty ("m_iCompTeammateColor" , st.PropertyValue {IntVal : int (Yellow )})
394
+
395
+ assert .Equal (t , Yellow , pl .Color ())
396
+ }
397
+
392
398
func TestPlayer_Kills (t * testing.T ) {
393
399
pl := playerWithResourceProperty ("m_iKills" , st.PropertyValue {IntVal : 5 })
394
400
You can’t perform that action at this time.
0 commit comments