1 /*
2  * Copyright (c) 2000 Mark B. Allan. All rights reserved.
3  *
4  * "Chromium B.S.U." is free software; you can redistribute
5  * it and/or use it and/or modify it under the terms of the
6  * "Clarified Artistic License"
7  */
8 #ifndef HiScore_h
9 #define HiScore_h
10 
11 #include <cstdio>
12 #include <ctime>
13 
14 #include "define.h"
15 
16 /**
17  * keep track of high scores. A history of HI_SCORE_HIST scores is
18  * retained for each skill level. Singleton.
19  */
20 //====================================================================
21 class HiScore
22 {
23 public:
24 	~HiScore();
25 
26 	static HiScore	*init();
27 	static HiScore	*getInstance();
28 	static void		destroy();
29 
30 	double		getScore(int skill, int index);
31 	const char	*getName(int skill, int index);
32 	time_t		getDate(int skill, int index);
33 
34 	const char	*getFileName();
35 	const char	*getOldFileName();
36 	bool		readFile();
37 	bool		saveFile();
38 	int			set(int skill, float score);
39 	int			check(int skill, float score);
40 	void		print(int skill);
41 
42 private:
43 	void	insertScore(int skill, int rank, float score);
44 
45 private:
46 	static HiScore	*instance;
47 
48 	double	hiScore[10][HI_SCORE_HIST];
49 	char	hiScoreName[10][HI_SCORE_HIST][100];
50 	time_t	hiScoreDate[10][HI_SCORE_HIST];
51 
52 	HiScore();
53 };
54 
55 #endif // HiScore_h
56