Changeset 9285 for code/branches/pCuts/src/modules/pong/Pong.cc
- Timestamp:
- Jun 10, 2012, 5:03:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pCuts/src/modules/pong/Pong.cc
r9090 r9285 76 76 // Set the type of Bots for this particular Gametype. 77 77 this->botclass_ = Class(PongBot); 78 78 79 this->scoreLimit_ = 10; 79 80 this->setConfigValues(); … … 88 89 if (this->isInitialized()) 89 90 this->cleanup(); 91 } 92 93 void Pong::setConfigValues() 94 { 95 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins."); 90 96 } 91 97 … … 283 289 } 284 290 285 // If a palyer gets 21 points, he won the game -> end of game 286 287 PlayerInfo* player1 = this->getLeftPlayer(); 288 PlayerInfo* player2 = this->getRightPlayer(); 289 if(player1==NULL||player2==NULL) return; //safety 290 if(this->getScore(player1) >= scoreLimit_) 291 { 292 std::string name1=player1->getName(); 293 std::string message(name1 + " has won!"); 294 ChatManager::message(message); 295 this->end(); 296 } 297 else if(this->getScore(player2) >= scoreLimit_) 298 { 299 std::string name2=player2->getName(); 300 std::string message2(name2 + " has won!"); 301 ChatManager::message(message2); 291 // If a player gets enough points, he won the game -> end of game 292 PlayerInfo* winningPlayer = NULL; 293 if (this->getLeftPlayer() && this->getScore(this->getLeftPlayer()) >= scoreLimit_) 294 winningPlayer = this->getLeftPlayer(); 295 else if (this->getRightPlayer() && this->getScore(this->getRightPlayer()) >= scoreLimit_) 296 winningPlayer = this->getRightPlayer(); 297 298 if (winningPlayer) 299 { 300 ChatManager::message(winningPlayer->getName() + " has won!"); 302 301 this->end(); 303 302 } 303 304 304 // Restart the timer to start the ball. 305 305 this->starttimer_.startTimer(); 306 307 306 } 308 307 … … 344 343 return 0; 345 344 } 346 347 /**348 @brief349 Make scoreLimit_ configurable e.g. in the menu.350 */351 void Pong::setConfigValues()352 {353 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins.");354 }355 345 }
Note: See TracChangeset
for help on using the changeset viewer.