1 /**************************************************************************
5 Copyright (c) Arto Hyvättinen 2010
7 This file is part of Chess Clock software.
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.
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.
20 **************************************************************************/
22 #include "hourglassclock.h"
23 #include "../turninformation.h"
25 HourGlassClock::HourGlassClock(bool white, QWidget *parent) :
26 ChessClockWidget(white, parent)
31 int HourGlassClock::getTimeAvailable()
34 return timeAvailableBeforeTurn_;
38 return timeAvailableBeforeTurn_ - currentTurnPlayed();
42 return timeAvailableBeforeTurn_ + another_->currentTurnPlayed();
47 TurnInformation* HourGlassClock::endTurn()
54 timePlayedBeforeTurn_ = getTimePlayed();
56 // Count available times of BOTH the clocks!
57 setTimeAvailable( getTimeAvailable() );
58 another_->setTimeAvailable( another_->getTimeAvailable());
60 // Close and return turn information
61 currentTurn_->turnReady(timeAvailableBeforeTurn_ );
62 TurnInformation* information = currentTurn_;
69 void HourGlassClock::updateClock()
71 ChessClock::updateClock();
72 another_->ChessClock::updateClock();