home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2002 June / Game.EXE_06_2002.iso / Alawar / src / Hiscore.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-06  |  849 b   |  48 lines

  1. #ifndef __HISCORE_H__
  2. #define __HISCORE_H__
  3.  
  4. #include <vector>
  5. #include <String.hpp>
  6.  
  7. class Hiscore
  8. {
  9. public:
  10.     class Entry
  11.     {
  12.         int score;
  13.         String player_name;
  14.     public:
  15.         Entry(const String & player_name, int score)
  16.         :    player_name( player_name ),
  17.             score( score )
  18.         {}
  19.         Entry()
  20.         :    score( 0 )
  21.         {}
  22.         const String & get_player_name()const
  23.         {
  24.             return player_name;
  25.         }
  26.         int get_score()const
  27.         {
  28.             return score;
  29.         }
  30.         bool operator<(const Entry & entry)const
  31.         {
  32.             return score < entry.score;
  33.         }
  34.     };
  35.     explicit Hiscore( int max_entries );
  36.     virtual ~Hiscore();
  37.     void add_entry( const Entry & entry );
  38.     const Entry & get_entry( int number )const;
  39.     int get_worst_score()const;
  40. private:
  41.     void save()const;
  42.     void load();
  43.  
  44.     const int max_entries;
  45.     std::vector<Entry> entries;
  46. };
  47.  
  48. #endif //__HISCORE_H__