Base class of chess clock.
+ ChessClock has not GUI itself, but it is subclass of QWidget
+ avoiding polymorphism.
+
*/
class ChessClock : public QWidget
{
bool isLoser() const { return loser_; }
int getTurn() const { return turn_; }
+ bool isWhite() const { return isWhite_; }
+ RunningStatus getStatus() const { return status_ ; }
/*! Start new turn */
@return Time available in msecs */
virtual int getTimeAvailable();
+ /*! Get total time played
+ @return Time played in msecs */
+ virtual int getTimePlayed() const;
+
+ /*! Set time available
+
+ @param msecs Time available in msecs */
+ void setTimeAvailable(int msecs);
+
+ /*! Add time
+
+ Add time to timeAvailableBeforeTurn_ total available time
+ counter.
+
+ @param msecs Time to add in msecs */
+ void addTime(int msecs);
+
+
signals:
- void timeOut();
+ void timeOutLoser();
+ void turnEnded();
public slots:
/*! Refresh clock information */
virtual void repaintClock() = 0;
+ /*! Update clock information, check looser state and refresh */
+ virtual void updateClock();
-protected:
+private:
ChessClock* another_; /*! Another player's clock */
bool loser_; /*! Is player losed because of timeout */
RunningStatus status_;
TurnInformation* currentTurn_;
- int timePlayed_; /*! Time played in this game */
- int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn!*/
+ int timePlayedBeforeTurn_; /*! Time played in this game BEFORE this turn msecs */
+ int timeAvailableBeforeTurn_; /*! Time available for play BEFORE this turn msecs !*/
bool isWhite_; /*! True if white player */