Back to index

supertuxkart  0.5+dfsg1
highscores.hpp
Go to the documentation of this file.
00001 //  $Id: highscores.hpp 921 2007-02-28 05:43:34Z hiker $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 Joerg Henrichs
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_HIGHSCORES_H
00021 #define HEADER_HIGHSCORES_H
00022 #include <string>
00023 #include <vector>
00024 #include <map>
00025 
00026 #include "lisp/lisp.hpp"
00027 #include "lisp/writer.hpp"
00028 #include "race_manager.hpp"
00029 
00030 class Highscores
00031 {
00032 public:
00033     enum HighscoreType {HST_UNDEFINED,
00034                         HST_TIMETRIAL_FASTEST_LAP,
00035                         HST_TIMETRIAL_OVERALL_TIME,
00036                         HST_RACE_FASTEST_LAP,
00037                         HST_RACE_OVERALL_TIME};
00038 private:
00039     enum {HIGHSCORE_LEN = 3};       // It's a top 3 list
00040     std::string         m_track;
00041     HighscoreType       m_highscore_type;
00042     int                 m_number_of_karts;
00043     int                 m_difficulty;
00044     int                 m_number_of_laps;
00045     std::string         m_kart_name[HIGHSCORE_LEN];
00046     std::string         m_name[HIGHSCORE_LEN];
00047     float               m_time[HIGHSCORE_LEN];
00048 public:
00049          Highscores();
00050     void Read      (const lisp::Lisp* const node);
00051     void Write     (lisp::Writer* writer);
00052     int  matches   (HighscoreType highscore_type, int num_karts,
00053                     const RaceManager::Difficulty difficulty, 
00054                     const std::string &track, const int number_of_laps);
00055     int  addData   (const HighscoreType highscore_type, const std::string kart_name,
00056                     const std::string name, const float time);
00057     int  getNumberEntries() const;
00058     void getEntry  (int number, std::string &kart_name,
00059                     std::string &name, float *const time) const;
00060 };  // Highscores
00061 
00062 #endif