1 | /* |
2 | Copyright (C) 2007 Dmitry Suzdalev (dimsuz@gmail.com) |
3 | |
4 | This program is free software; you can redistribute it and/or modify |
5 | it under the terms of the GNU General Public License as published by |
6 | the Free Software Foundation; either version 2 of the License, or |
7 | (at your option) any later version. |
8 | |
9 | This program is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | GNU General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU General Public License |
15 | along with this program; if not, write to the Free Software |
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | */ |
18 | |
19 | #ifndef KATOMIC_HIGHSCORES_H |
20 | #define KATOMIC_HIGHSCORES_H |
21 | |
22 | #include <QString> |
23 | #include <KSharedConfig> |
24 | |
25 | /** |
26 | * This class is used to manage katomic's highscores. |
27 | * There's one highscore for each level per each player - it's |
28 | * the number of moves it took to complete level. |
29 | */ |
30 | class KAtomicHighscores |
31 | { |
32 | public: |
33 | /** |
34 | * Constructor. |
35 | * By default sets player name to current user login name |
36 | * @see setCurrentPlayerName |
37 | */ |
38 | KAtomicHighscores(); |
39 | /** |
40 | * Changes current player name to playerName |
41 | */ |
42 | void setCurrentPlayerName( const QString& playerName ) { m_playerName = playerName; } |
43 | /** |
44 | * @return current player name |
45 | */ |
46 | QString currentPlayerName() const { return m_playerName; } |
47 | /** |
48 | * Tries to add new result to highscores. |
49 | * If numMoves is lesser than current highscore for this level, |
50 | * this result will become a new highscore of currentPlayerName for this level |
51 | * @return whether numMoves was set as a new highscore |
52 | */ |
53 | bool addScore( int numMoves, const QString& levelSetName, int level ); |
54 | /** |
55 | * @return highscore of current player for level |
56 | */ |
57 | int levelHighscore( const QString& levelSetName, int level ) const; |
58 | private: |
59 | /** |
60 | * Current player name |
61 | */ |
62 | QString m_playerName; |
63 | |
64 | KSharedConfigPtr m_hsFile; |
65 | }; |
66 | |
67 | #endif |
68 | |