Cute Chess
0.1
projects
lib
src
timecontrol.h
1
/*
2
This file is part of Cute Chess.
3
4
Cute Chess 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 3 of the License, or
7
(at your option) any later version.
8
9
Cute Chess 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 Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef TIMECONTROL_H
19
#define TIMECONTROL_H
20
21
#include <QElapsedTimer>
22
#include <QString>
23
#include <QCoreApplication>
24
class
QSettings
;
25
34
class
LIB_EXPORT
TimeControl
35
{
36
Q_DECLARE_TR_FUNCTIONS(
TimeControl
)
37
38
public
:
40
TimeControl
();
41
66
TimeControl
(
const
QString
& str);
67
74
bool
operator==(
const
TimeControl
& other)
const
;
75
77
bool
isValid()
const
;
78
80
QString
toString()
const
;
81
83
QString
toVerboseString()
const
;
84
86
void
initialize();
87
89
bool
isInfinite()
const
;
90
95
int
timePerTc()
const
;
96
101
int
movesPerTc()
const
;
102
104
int
timeIncrement()
const
;
105
112
int
timePerMove()
const
;
113
115
int
timeLeft()
const
;
116
121
int
movesLeft()
const
;
122
124
int
plyLimit()
const
;
125
127
int
nodeLimit()
const
;
128
136
int
expiryMargin()
const
;
137
138
143
void
setInfinity(
bool
enabled =
true
);
144
146
void
setTimePerTc(
int
timePerTc);
147
149
void
setMovesPerTc(
int
movesPerTc);
150
152
void
setTimeIncrement(
int
increment);
153
155
void
setTimePerMove(
int
timePerMove);
156
158
void
setTimeLeft(
int
timeLeft);
159
161
void
setMovesLeft(
int
movesLeft);
162
164
void
setPlyLimit(
int
plies);
165
167
void
setNodeLimit(
int
nodes);
168
170
void
setExpiryMargin(
int
expiryMargin);
171
172
174
void
startTimer();
175
183
void
update(
bool
applyIncrement =
true
);
184
186
int
lastMoveTime()
const
;
187
189
bool
expired()
const
;
190
198
int
activeTimeLeft()
const
;
199
201
void
readSettings(
QSettings
* settings);
202
204
void
writeSettings(
QSettings
* settings);
205
206
private
:
207
int
m_movesPerTc;
208
int
m_timePerTc;
209
int
m_timePerMove;
210
int
m_increment;
211
int
m_timeLeft;
212
int
m_movesLeft;
213
int
m_plyLimit;
214
int
m_nodeLimit;
215
int
m_lastMoveTime;
216
int
m_expiryMargin;
217
bool
m_expired;
218
bool
m_infinite;
219
QElapsedTimer m_time;
220
};
221
222
#endif // TIMECONTROL_H
TimeControl
Time controls of a chess game.
Definition:
timecontrol.h:34
QString
QSettings
Generated by
1.8.14