Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11716 for code/trunk


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

[Highscore_HS16] moved logic to compare old an new score to Highscore; fixed formatting in Gametypes

Location:
code/trunk/src
Files:
7 edited

Legend:

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

    r11715 r11716  
    225225        // It will misteriously crash the game!
    226226        // Instead startMainMenu, this won't crash.
    227         if (Highscore::exists()){
    228                     int score = this->getPoints();
    229                     if(score > Highscore::getInstance().getHighestScoreOfGame("Dodge Race"))
    230                         Highscore::getInstance().storeHighscore("Dodge Race",score,this->getPlayer()->getPlayer());
    231 
    232           }
     227        if (Highscore::exists())
     228        {
     229            int score = this->getPoints();
     230            Highscore::getInstance().storeScore("Dodge Race", score, this->getPlayer()->getPlayer());
     231        }
    233232        GSLevel::startMainMenu();
    234233    }
  • code/trunk/src/modules/invader/Invader.cc

    r11715 r11716  
    189189        // It will misteriously crash the game!
    190190        // Instead startMainMenu, this won't crash.
    191         if (Highscore::exists()){
    192                     int score = this->getPoints();
    193                     if(score > Highscore::getInstance().getHighestScoreOfGame("Orxonox Arcade"))
    194                         Highscore::getInstance().storeHighscore("Orxonox Arcade",score,this->getPlayer()->getPlayer());
    195 
    196           }
     191        if (Highscore::exists())
     192        {
     193            int score = this->getPoints();
     194            Highscore::getInstance().storeScore("Orxonox Arcade", score, this->getPlayer()->getPlayer());
     195        }
    197196        GSLevel::startMainMenu();
    198197    }
  • code/trunk/src/modules/jump/Jump.cc

    r11715 r11716  
    312312        cleanup();
    313313        GSLevel::startMainMenu();
    314         if (Highscore::exists()){
    315                     int score = this->getScore(this->getPlayer());
    316                     if(score > Highscore::getInstance().getHighestScoreOfGame("Jump"))
    317                         Highscore::getInstance().storeHighscore("Jump",score,this->getPlayer());
    318 
    319           }
     314        if (Highscore::exists())
     315        {
     316            int score = this->getScore(this->getPlayer());
     317            Highscore::getInstance().storeScore("Jump", score, this->getPlayer());
     318        }
    320319        Deathmatch::end();
    321320    }
  • code/trunk/src/modules/tetris/Tetris.cc

    r11715 r11716  
    328328            this->player_->stopControl();
    329329        }
    330          if (Highscore::exists()){
    331                     int score = this->getScore(this->getPlayer());
    332                     if(score > Highscore::getInstance().getHighestScoreOfGame("Tetris"))
    333                         Highscore::getInstance().storeHighscore("Tetris",score,this->getPlayer());
    334 
    335           }
     330        if (Highscore::exists())
     331        {
     332            int score = this->getScore(this->getPlayer());
     333            Highscore::getInstance().storeScore("Tetris", score, this->getPlayer());
     334        }
    336335        this->cleanup();
    337336
  • code/trunk/src/modules/towerdefense/TowerDefense.cc

    r11715 r11716  
    198198    void TowerDefense::end()
    199199    {
    200         if (Highscore::exists()){
    201                     int score = this->getWaveNumber();
    202                     if(score > Highscore::getInstance().getHighestScoreOfGame("Tower Defense"))
    203                         Highscore::getInstance().storeHighscore("Tower Defense",score,this->getPlayer());
    204 
    205           }
     200        if (Highscore::exists())
     201        {
     202            int score = this->getWaveNumber();
     203            Highscore::getInstance().storeScore("Tower Defense", score, this->getPlayer());
     204        }
    206205        TeamDeathmatch::end();
    207206        ChatManager::message("Match is over! Gameover!");
  • code/trunk/src/orxonox/Highscore.cc

    r11715 r11716  
    5050
    5151    /**
    52      * @brief stores a new highscore in the orxonox.ini file
     52     * @brief stores a new highscore in the orxonox.ini file if the new score is better than the highest score so far.
    5353     */
    54     void Highscore::storeHighscore(const std::string& level, int points, PlayerInfo* player){
    55         ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
     54    void Highscore::storeScore(const std::string& level, int points, PlayerInfo* player){
     55        if (points > this->getHighestScoreOfGame(level)) {
     56            ModifyConfigValue(highscores_, add, player->getName() + "./." + level + "./." + multi_cast<std::string>(points));
     57        }
    5658    }
    5759}
  • code/trunk/src/orxonox/Highscore.h

    r11715 r11716  
    1818        void setConfigValues(); // Inherited function
    1919
    20         void storeHighscore(const std::string& level, int points, PlayerInfo* player);
     20        void storeScore(const std::string& level, int points, PlayerInfo* player);
    2121        int getHighestScoreOfGame(const std::string& game);
    2222
Note: See TracChangeset for help on using the changeset viewer.