File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,14 @@ func TestDemoInfoCs(t *testing.T) {
103103 // We know there should be 10 players at match start in the default demo
104104 t .Error ("Expected 10 players; got" , nPlayers )
105105 }
106+ if nTerrorists := len (gs .TeamMembers (common .TeamTerrorists )); nTerrorists != 5 {
107+ // We know there should be 5 terrorists at match start in the default demo
108+ t .Error ("Expected 5 terrorists; got" , nTerrorists )
109+ }
110+ if nCTs := len (gs .TeamMembers (common .TeamCounterTerrorists )); nCTs != 5 {
111+ // We know there should be 5 CTs at match start in the default demo
112+ t .Error ("Expected 5 CTs; got" , nCTs )
113+ }
106114 })
107115
108116 // Net-message stuff
Original file line number Diff line number Diff line change @@ -58,6 +58,17 @@ func (gs GameState) PlayingParticipants() []*common.Player {
5858 return r
5959}
6060
61+ // TeamMembers returns all players belonging to the requested team.
62+ func (gs GameState ) TeamMembers (team common.Team ) []* common.Player {
63+ r := make ([]* common.Player , 0 , len (gs .players ))
64+ for _ , ptcp := range gs .players {
65+ if ptcp .Team == team {
66+ r = append (r , ptcp )
67+ }
68+ }
69+ return r
70+ }
71+
6172func newGameState () GameState {
6273 return GameState {players : make (map [int ]* common.Player )}
6374}
You can’t perform that action at this time.
0 commit comments