Changeset 11715 for code/trunk
- Timestamp:
- Jan 7, 2018, 9:16:52 PM (7 years ago)
- Location:
- code/trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/dodgerace/DodgeRace.cc
r11356 r11715 228 228 int score = this->getPoints(); 229 229 if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race")) 230 Highscore::getInstance().storeHighscore("Dodge Race",score );230 Highscore::getInstance().storeHighscore("Dodge Race",score,this->getPlayer()->getPlayer()); 231 231 232 232 } -
code/trunk/src/modules/invader/Invader.cc
r11356 r11715 192 192 int score = this->getPoints(); 193 193 if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade")) 194 Highscore::getInstance().storeHighscore("Orxonox Arcade",score );194 Highscore::getInstance().storeHighscore("Orxonox Arcade",score,this->getPlayer()->getPlayer()); 195 195 196 196 } -
code/trunk/src/modules/jump/Jump.cc
r11356 r11715 315 315 int score = this->getScore(this->getPlayer()); 316 316 if(score > Highscore::getInstance().getHighestScoreOfGame("Jump")) 317 Highscore::getInstance().storeHighscore("Jump",score );317 Highscore::getInstance().storeHighscore("Jump",score,this->getPlayer()); 318 318 319 319 } -
code/trunk/src/modules/tetris/Tetris.cc
r11356 r11715 331 331 int score = this->getScore(this->getPlayer()); 332 332 if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris")) 333 Highscore::getInstance().storeHighscore("Tetris",score );333 Highscore::getInstance().storeHighscore("Tetris",score,this->getPlayer()); 334 334 335 335 } -
code/trunk/src/modules/towerdefense/TowerDefense.cc
r11356 r11715 201 201 int score = this->getWaveNumber(); 202 202 if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense")) 203 Highscore::getInstance().storeHighscore("Tower Defense",score );203 Highscore::getInstance().storeHighscore("Tower Defense",score,this->getPlayer()); 204 204 205 205 } -
code/trunk/src/orxonox/Highscore.cc
r11356 r11715 1 1 #include "Highscore.h" 2 2 3 #include <vector>4 3 #include "core/CoreIncludes.h" 5 4 #include "core/config/ConfigValueIncludes.h" 6 5 #include "core/singleton/ScopedSingletonIncludes.h" 6 #include "infos/PlayerInfo.h" 7 #include "util/Convert.h" 7 8 8 9 namespace orxonox 9 10 { 10 11 11 ManageScopedSingleton(Highscore, ScopeID::ROOT, false); 12 12 RegisterClassNoArgs(Highscore); … … 17 17 this->setConfigValues(); 18 18 } 19 19 20 /** 20 21 * @brief set the config values in the orxonox.ini file … … 23 24 { 24 25 SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector"); 25 SetConfigValue(playerName_, "Player").description("Name of the player");26 26 } 27 27 28 /** 28 29 * @brief Returns highest score of given game, if exists. 29 30 * Else returns -1. 30 31 */ 31 int Highscore::getHighestScoreOfGame( std::stringgame){32 std::string delimiter = "./."; //score save as "Playername./.game./.score"32 int Highscore::getHighestScoreOfGame(const std::string& game){ 33 const std::string delimiter = "./."; //score save as "Playername./.game./.score" 33 34 int best = -1; 34 35 //check for the highest Score of given game … … 39 40 if(game.compare(score.substr(0,score.find(delimiter))) == 0){ 40 41 score.erase(0, score.find(delimiter) + delimiter.length()); 41 int possibleBest = std::stoi(score);42 int possibleBest = multi_cast<int>(score); 42 43 if(possibleBest > best) best = possibleBest; 43 44 } 44 45 46 45 } 47 46 … … 49 48 50 49 } 50 51 51 /** 52 52 * @brief stores a new highscore in the orxonox.ini file 53 53 */ 54 void Highscore::storeHighscore( std::string level, int points){55 ModifyConfigValue(highscores_, add, player Name_+"./."+level+"./."+std::to_string(points));54 void Highscore::storeHighscore(const std::string& level, int points, PlayerInfo* player){ 55 ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points)); 56 56 } 57 58 57 } -
code/trunk/src/orxonox/Highscore.h
r11356 r11715 1 1 #include <string> 2 #include <vector> 3 4 #include "OrxonoxPrereqs.h" 2 5 #include "core/config/Configurable.h" 3 #include "OrxonoxPrereqs.h"4 6 #include "util/Singleton.h" 7 5 8 // tolua_begin 6 9 namespace orxonox … … 14 17 Highscore(); // Constructor 15 18 void setConfigValues(); // Inherited function 16 void storeHighscore(std::string level, int points);17 19 18 int getHighestScoreOfGame(std::string game); 20 void storeHighscore(const std::string& level, int points, PlayerInfo* player); 21 int getHighestScoreOfGame(const std::string& game); 22 19 23 // tolua_begin 20 24 inline unsigned int getNumberOfHighscores() 21 22 23 25 { return this->highscores_.size(); } 26 inline const std::string& getHighscore(unsigned int index) 27 { return this->highscores_[index]; } 24 28 25 29 static Highscore& getInstance() 26 { return Singleton<Highscore>::getInstance(); } 27 30 { return Singleton<Highscore>::getInstance(); } 28 31 // tolua_end 29 30 32 31 33 private: 32 34 std::vector<std::string> highscores_; 33 float version_;34 std::string playerName_;35 35 static Highscore* singletonPtr_s; 36 36 }; //tolua_export
Note: See TracChangeset
for help on using the changeset viewer.