00001 /************************************************************************** 00002 00003 Chess Clock 00004 00005 Copyright (c) Arto Hyvättinen 2010 00006 00007 This file is part of Chess Clock software. 00008 00009 Chess Clock is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 Chess Clock is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 00020 **************************************************************************/ 00021 00022 #include "turninformation.h" 00023 00024 TurnInformation::TurnInformation(int turnId, bool white) 00025 { 00026 turnId_ = turnId; 00027 white_ = white; 00028 duration_ = 0; 00029 paused_ = 0; 00030 turnReady_ = false; 00031 } 00032 00033 00034 void TurnInformation::addTime(int msecs) 00035 { 00036 if( !turnReady_ ) 00037 duration_ += msecs; 00038 } 00039 00040 void TurnInformation::addPause(int msecs) 00041 { 00042 if( !turnReady_ ) 00043 pause_ += msecs; 00044 } 00045 00046 void TurnInformation::turnReady(int msecs) 00047 { 00048 timeAfter_ = msecs; 00049 turnReady_ = true; 00050 } 00051 00052 int TurnInformation::getTimeAfter() 00053 { 00054 if( turnReady_ ) 00055 return timeAfter_; 00056 else 00057 return 0; 00058 }