ALPHA VERSION
[chessclock] / classes / timecontrol / delayclock.cpp
1  /**************************************************************************
2
3     Chess Clock
4
5     Copyright (c) Arto Hyvättinen 2010
6
7     This file is part of Chess Clock software.
8
9     Chess Clock is free software: you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation, either version 3 of the License, or
12     (at your option) any later version.
13
14     Chess Clock is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19
20 **************************************************************************/
21
22 #include "delayclock.h"
23
24 DelayClock::DelayClock(bool white, int delay, QWidget *parent) :
25     ChessClockWidget(white, parent)
26 {
27     delay_ = delay;
28     setGreenTime( delay_ );
29 }
30
31 int DelayClock::getTimeAvailable()
32 {
33     if( currentTurn_)
34     {
35         int played = currentTurnPlayed();
36         if( played > delay_)
37         {
38             // Will add the whole delay
39             return timeAvailableBeforeTurn_ + delay_ - played;
40         }
41     }
42     // in delay or not in turn.
43     return timeAvailableBeforeTurn_;
44 }