1 /* ColorCode, a free MasterMind clone with built in solver
2  * Copyright (C) 2009  Dirk Laebisch
3  * http://www.laebisch.com/
4  *
5  * ColorCode is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * ColorCode is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with ColorCode. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "highscore.h"
20 
21 using namespace std;
22 
HighScore()23 HighScore::HighScore()
24 {
25     mCombinationsCnt = 0;
26     mRowsCnt = 0;
27     mTime = 0;
28 
29 }
30 
NewGame(int ccnt)31 void HighScore::NewGame(int ccnt)
32 {
33     mRowsCnt = 0;
34     mTime = 0;
35     mCombinationsCnt = ccnt;
36 }
37 
GetScore(int rcnt,int t)38 int HighScore::GetScore(int rcnt, int t)
39 {
40     mRowsCnt = rcnt;
41     mTime = t;
42     return GetScore();
43 }
44 
GetScore() const45 int HighScore::GetScore() const
46 {
47     if (mCombinationsCnt == 0 || mRowsCnt == 0 || mTime == 0)
48     {
49         return 0;
50     }
51 
52     double dd = mCombinationsCnt * 10000;
53     double dv = mRowsCnt * mTime / 100;
54     return int(dd / dv);
55 }
56