Score.hpp (771B)
1 #ifndef _SCORE_HPP_ 2 #define _SCORE_HPP_ 3 4 #include <algorithm> 5 #include <array> 6 #include <cstring> 7 #include <fstream> 8 #include <stdexcept> 9 #include <string> 10 #include <vector> 11 12 #define NAMEMAX 11 13 #define SCORE_STONE 10 14 #define SCORE_PARCHMENT 100 15 16 class Score { 17 private: 18 struct HighScore { 19 char name[NAMEMAX]; 20 int score; 21 }; 22 23 std::array<HighScore, 5> hiscores; 24 std::string fpath; 25 std::fstream sf; 26 char curname[NAMEMAX]; 27 int curscore; 28 29 public: 30 Score(const char *scorefile, const char *name); 31 ~Score(); 32 33 Score& operator<< (const char *name); 34 Score& operator<< (const int score); 35 36 std::vector<std::string> scores_strfmt() const; 37 const char *get_curname() const; 38 int get_curscore() const; 39 40 private: 41 void add_new_hiscore(); 42 }; 43 44 #endif /* _SCORE_HPP_ */