Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11715


Ignore:
Timestamp:
Jan 7, 2018, 9:16:52 PM (7 years ago)
Author:
landauf
Message:

[Highscore_HS16] removed playerName from Highscore because the player already has a name (see HumanPlayer.nick)

Location:
code/trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/dodgerace/DodgeRace.cc

    r11356 r11715  
    228228                    int score = this->getPoints();
    229229                    if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
    230                         Highscore::getInstance().storeHighscore("Dodge Race",score);
     230                        Highscore::getInstance().storeHighscore("Dodge Race",score,this->getPlayer()->getPlayer());
    231231
    232232          }
  • code/trunk/src/modules/invader/Invader.cc

    r11356 r11715  
    192192                    int score = this->getPoints();
    193193                    if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
    194                         Highscore::getInstance().storeHighscore("Orxonox Arcade",score);
     194                        Highscore::getInstance().storeHighscore("Orxonox Arcade",score,this->getPlayer()->getPlayer());
    195195
    196196          }
  • code/trunk/src/modules/jump/Jump.cc

    r11356 r11715  
    315315                    int score = this->getScore(this->getPlayer());
    316316                    if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
    317                         Highscore::getInstance().storeHighscore("Jump",score);
     317                        Highscore::getInstance().storeHighscore("Jump",score,this->getPlayer());
    318318
    319319          }
  • code/trunk/src/modules/tetris/Tetris.cc

    r11356 r11715  
    331331                    int score = this->getScore(this->getPlayer());
    332332                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
    333                         Highscore::getInstance().storeHighscore("Tetris",score);
     333                        Highscore::getInstance().storeHighscore("Tetris",score,this->getPlayer());
    334334
    335335          }
  • code/trunk/src/modules/towerdefense/TowerDefense.cc

    r11356 r11715  
    201201                    int score = this->getWaveNumber();
    202202                    if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
    203                         Highscore::getInstance().storeHighscore("Tower Defense",score);
     203                        Highscore::getInstance().storeHighscore("Tower Defense",score,this->getPlayer());
    204204
    205205          }
  • code/trunk/src/orxonox/Highscore.cc

    r11356 r11715  
    11#include "Highscore.h"
    22
    3 #include <vector>
    43#include "core/CoreIncludes.h"
    54#include "core/config/ConfigValueIncludes.h"
    65#include "core/singleton/ScopedSingletonIncludes.h"
     6#include "infos/PlayerInfo.h"
     7#include "util/Convert.h"
    78
    89namespace orxonox
    910{
    10 
    1111    ManageScopedSingleton(Highscore, ScopeID::ROOT, false);
    1212        RegisterClassNoArgs(Highscore);
     
    1717        this->setConfigValues();
    1818    }
     19
    1920    /**
    2021     * @brief set the config values in the orxonox.ini file
     
    2324    {
    2425        SetConfigValue(highscores_, std::vector<std::string>()).description("Highscores saved as vector");
    25         SetConfigValue(playerName_, "Player").description("Name of the player");
    2626    }
     27
    2728    /**
    2829     * @brief Returns highest score of given game, if exists.
    2930     * Else returns -1.
    3031     */
    31     int Highscore::getHighestScoreOfGame(std::string game){
    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"
    3334        int best = -1;
    3435        //check for the highest Score of given game
     
    3940            if(game.compare(score.substr(0,score.find(delimiter))) == 0){
    4041                score.erase(0, score.find(delimiter) + delimiter.length());
    41                 int possibleBest = std::stoi(score);
     42                int possibleBest = multi_cast<int>(score);
    4243                if(possibleBest > best) best = possibleBest;
    4344            }
    44 
    45 
    4645        }
    4746       
     
    4948       
    5049    }
     50
    5151    /**
    5252     * @brief stores a new highscore in the orxonox.ini file
    5353     */
    54     void Highscore::storeHighscore(std::string level, int points){
    55         ModifyConfigValue(highscores_, add, playerName_+"./."+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));
    5656    }
    57    
    5857}
  • code/trunk/src/orxonox/Highscore.h

    r11356 r11715  
    11#include <string>
     2#include <vector>
     3
     4#include "OrxonoxPrereqs.h"
    25#include "core/config/Configurable.h"
    3 #include "OrxonoxPrereqs.h"
    46#include "util/Singleton.h"
     7
    58// tolua_begin
    69namespace orxonox
     
    1417        Highscore();              // Constructor
    1518        void setConfigValues(); // Inherited function
    16         void storeHighscore(std::string level, int points);
    1719
    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
    1923        // tolua_begin
    2024        inline unsigned int getNumberOfHighscores()
    21                 { return this->highscores_.size(); }
    22             inline const std::string& getHighscore(unsigned int index)
    23                 { return this->highscores_[index]; }
     25            { return this->highscores_.size(); }
     26        inline const std::string& getHighscore(unsigned int index)
     27            { return this->highscores_[index]; }
    2428
    2529        static Highscore& getInstance()
    26                 { return Singleton<Highscore>::getInstance(); }
    27 
     30            { return Singleton<Highscore>::getInstance(); }
    2831        // tolua_end
    29 
    3032
    3133    private:
    3234        std::vector<std::string> highscores_;
    33         float version_;
    34         std::string playerName_;
    3535        static Highscore* singletonPtr_s;
    3636}; //tolua_export
Note: See TracChangeset for help on using the changeset viewer.