Changeset 11315 for code/branches/Highscore_HS16/src/orxonox
- Timestamp:
- Dec 1, 2016, 3:08:54 PM (8 years ago)
- Location:
- code/branches/Highscore_HS16/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Highscore_HS16/src/orxonox/Highscore.cc
r11313 r11315 20 20 void Highscore::setConfigValues() 21 21 { 22 SetConfigValue(highscores_, std::vector<std::string>()).description("HighscoreVektor"); 23 } 22 24 23 SetConfigValue(name_, "Test").description("The name of the game"); 24 SetConfigValue(tests_, std::vector<std::string>()).description("Testvektor"); 25 int Highscore::getHighestScoreOfGame(std::string game){ 26 std::string delimiter = "./."; 27 int best = -1; 28 for (std::string score : this->highscores_) 29 { 30 31 score.erase(0, score.find(delimiter) + delimiter.length()); 32 if(game.compare(score.substr(0,score.find(delimiter))) == 0){ 33 score.erase(0, score.find(delimiter) + delimiter.length()); 34 int possibleBest = std::stoi(score); 35 if(possibleBest > best) best = possibleBest; 36 } 37 38 39 } 40 41 return best; 42 25 43 } 44 26 45 void Highscore::storeHighscore(std::string player, std::string level, int points){ 27 ModifyConfigValue( tests_, add, player+"./."+level+"./."+std::to_string(points));46 ModifyConfigValue(highscores_, add, player+"./."+level+"./."+std::to_string(points)); 28 47 } 29 48 /* static std::string Highscore::getName(){ -
code/branches/Highscore_HS16/src/orxonox/Highscore.h
r11313 r11315 15 15 void setConfigValues(); // Inherited function 16 16 void storeHighscore(std::string player, std::string level, int points); 17 18 int getHighestScoreOfGame(std::string game); 17 19 // tolua_begin 18 inline const std::string& getName() {19 return this->name_;20 }21 inline void test(){22 this->storeHighscore("test","t",1);23 }24 20 inline unsigned int getNumberOfHighscores() 25 { return this-> tests_.size(); }21 { return this->highscores_.size(); } 26 22 inline const std::string& getHighscore(unsigned int index) 27 { return this-> tests_[index]; }23 { return this->highscores_[index]; } 28 24 29 25 static Highscore& getInstance() … … 34 30 35 31 private: 36 std::vector<std::string> tests_; 37 std::string name_; 32 std::vector<std::string> highscores_; 38 33 float version_; 39 34 static Highscore* singletonPtr_s;
Note: See TracChangeset
for help on using the changeset viewer.