Changeset 8900 for code/branches/gamecontent/src
- Timestamp:
- Oct 19, 2011, 11:02:56 PM (13 years ago)
- Location:
- code/branches/gamecontent/src/modules/pong
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/gamecontent/src/modules/pong/Pong.cc
r8895 r8900 37 37 #include "core/EventIncludes.h" 38 38 #include "core/command/Executor.h" 39 #include "core/ConfigValueIncludes.h" 39 40 40 41 #include "gamestates/GSLevel.h" … … 75 76 // Set the type of Bots for this particular Gametype. 76 77 this->botclass_ = Class(PongBot); 77 this->scoreLimit_ = 3; //TODO: 21 78 this->scoreLimit_ = 10; 79 this->setConfigValues(); 78 80 } 79 81 … … 291 293 std::string message(name1 + " has won!"); 292 294 ChatManager::message(message); 295 this->tick(0); 293 296 this->end(); 294 297 } … … 298 301 std::string message2(name2 + " has won!"); 299 302 ChatManager::message(message2); 303 this->tick(0); 300 304 this->end(); 301 305 } … … 342 346 return 0; 343 347 } 348 349 /** 350 @brief 351 Make scoreLimit_ configurable e.g. in the menu. 352 */ 353 void Pong::setConfigValues() 354 { 355 SetConfigValue(scoreLimit_, 10).description("The player first reaching those points wins."); 356 } 344 357 } -
code/branches/gamecontent/src/modules/pong/Pong.h
r8895 r8900 81 81 void setCenterpoint(PongCenterpoint* center) 82 82 { this->center_ = center; } 83 84 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 83 void setConfigValues(); //!< Makes scoreLimit configurable. 84 85 PlayerInfo* getLeftPlayer() const; //!< Get the left player. 85 86 PlayerInfo* getRightPlayer() const; //!< Get the right player. 86 87 -
code/branches/gamecontent/src/modules/pong/PongScore.cc
r8108 r8900 60 60 this->bShowLeftPlayer_ = false; 61 61 this->bShowRightPlayer_ = false; 62 this->player1_ = NULL; 63 this->player2_ = NULL; 62 64 } 63 65 … … 98 100 if (this->owner_ != NULL) 99 101 { 100 // Get the two players. 101 PlayerInfo* player1 = this->owner_->getLeftPlayer(); 102 PlayerInfo* player2 = this->owner_->getRightPlayer(); 103 104 std::string name1; 105 std::string name2; 106 107 std::string score1("0"); 108 std::string score2("0"); 109 110 // Save the name and score of each player as a string. 111 if (player1 != NULL) 102 if(!this->owner_->hasEnded()) 112 103 { 113 name1 = player1->getName(); 114 score1 = multi_cast<std::string>(this->owner_->getScore(player1)); 115 } 116 if (player2 != NULL) 117 { 118 name2 = player2->getName(); 119 score2 = multi_cast<std::string>(this->owner_->getScore(player2)); 104 //get the two players 105 player1_ = this->owner_->getLeftPlayer(); 106 player2_ = this->owner_->getRightPlayer(); 120 107 } 121 108 122 // Assemble the strings, depending on what should all be displayed. 123 std::string output1; 124 if (this->bShowLeftPlayer_) 109 if(this->owner_->hasStarted()) 125 110 { 126 if (this->bShowName_ && this->bShowScore_ && player1 != NULL) 127 output1 = name1 + " - " + score1; 128 else if (this->bShowScore_) 129 output1 = score1; 130 else if (this->bShowName_) 131 output1 = name1; 132 } 111 // Get the two players. 133 112 134 std::string output2; 135 if (this->bShowRightPlayer_) 136 { 137 if (this->bShowName_ && this->bShowScore_ && player2 != NULL) 113 std::string name1; 114 std::string name2; 115 116 std::string score1("0"); 117 std::string score2("0"); 118 119 // Save the name and score of each player as a string. 120 if (player1_ != NULL) 121 { 122 name1 = player1_->getName(); 123 score1 = multi_cast<std::string>(this->owner_->getScore(player1_)); 124 } 125 if (player2_ != NULL) 126 { 127 name2 = player2_->getName(); 128 score2 = multi_cast<std::string>(this->owner_->getScore(player2_)); 129 } 130 131 // Assemble the strings, depending on what should all be displayed. 132 std::string output1; 133 if (this->bShowLeftPlayer_) 134 { 135 if (this->bShowName_ && this->bShowScore_ && player1_ != NULL) 136 output1 = name1 + " - " + score1; 137 else if (this->bShowScore_) 138 output1 = score1; 139 else if (this->bShowName_) 140 output1 = name1; 141 } 142 143 std::string output2; 144 if (this->bShowRightPlayer_) 145 { 146 if (this->bShowName_ && this->bShowScore_ && player2_ != NULL) 138 147 output2 = score2 + " - " + name2; 139 148 else if (this->bShowScore_) … … 143 152 } 144 153 145 std::string output("PONG"); 146 if (this->bShowName_ || this->bShowScore_) 147 { 148 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_) 149 output = output1 + ':' + output2; 150 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_) 151 output = output1 + output2; 154 std::string output("PONG"); 155 if (this->bShowName_ || this->bShowScore_) 156 { 157 if (this->bShowLeftPlayer_ && this->bShowRightPlayer_) 158 output = output1 + ':' + output2; 159 else if (this->bShowLeftPlayer_ || this->bShowRightPlayer_) 160 output = output1 + output2; 161 } 162 this->setCaption(output); 152 163 } 153 154 this->setCaption(output);155 164 } 156 165 } -
code/branches/gamecontent/src/modules/pong/PongScore.h
r8108 r8900 122 122 bool bShowLeftPlayer_; //!< Whether the left player is shown. 123 123 bool bShowRightPlayer_; //!< Whether the right player is shown. 124 PlayerInfo* player1_; //!< Store information about left player permanently. 125 PlayerInfo* player2_; //!< Same for the right player. To end the game properly. 124 126 }; 125 127 }
Note: See TracChangeset
for help on using the changeset viewer.