Changeset 9941 for code/trunk/src/orxonox/gametypes/TeamGametype.cc
- Timestamp:
- Dec 29, 2013, 8:06:44 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/gametypes/TeamGametype.cc
r9667 r9941 173 173 } 174 174 175 int TeamGametype::getTeamScore(PlayerInfo* player) 176 { 177 int teamscore = 0; 178 if(!player || this->getTeam(player) == -1) 179 return 0; 180 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 181 { 182 if ( this->getTeam(it->first) == this->getTeam(player) ) 183 { 184 teamscore += it->second.frags_; 185 } 186 } 187 return teamscore; 188 } 189 190 int TeamGametype::getTeamSize(int team) 191 { 192 int teamSize = 0; 193 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 194 { 195 if (it->second == team) 196 teamSize++; 197 } 198 return teamSize; 199 } 200 201 int TeamGametype::getHumansInTeam(int team) 202 { 203 int teamSize = 0; 204 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it) 205 { 206 if (it->second == team && it->first->isHumanPlayer()) 207 teamSize++; 208 } 209 return teamSize; 210 } 211 212 175 213 SpawnPoint* TeamGametype::getBestSpawnPoint(PlayerInfo* player) const 176 214 { … … 336 374 } 337 375 376 void TeamGametype::announceTeamWin(int winnerTeam) 377 { 378 for (std::map<PlayerInfo*, int>::iterator it3 = this->teamnumbers_.begin(); it3 != this->teamnumbers_.end(); ++it3) 379 { 380 if (it3->first->getClientID() == NETWORK_PEER_ID_UNKNOWN) 381 continue; 382 if (it3->second == winnerTeam) 383 { 384 this->gtinfo_->sendAnnounceMessage("Your team has won the match!", it3->first->getClientID()); 385 } 386 else 387 { 388 this->gtinfo_->sendAnnounceMessage("Your team has lost the match!", it3->first->getClientID()); 389 } 390 } 391 } 392 338 393 }
Note: See TracChangeset
for help on using the changeset viewer.