ksquares
ksquaresgame.h
Go to the documentation of this file.00001 /*************************************************************************** 00002 * Copyright (C) 2006 by Matthew Williams <matt@milliams.com> * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License as published by * 00006 * the Free Software Foundation; either version 2 of the License, or * 00007 * (at your option) any later version. * 00008 ***************************************************************************/ 00009 00010 #ifndef KSQUARESGAME_H 00011 #define KSQUARESGAME_H 00012 00013 #include <QObject> 00014 #include <QVector> 00015 00016 #include "ksquaresplayer.h" 00017 00018 class QColor; 00019 00044 class KSquaresGame : public QObject 00045 { 00046 Q_OBJECT 00047 00048 public: 00050 KSquaresGame(); 00051 ~KSquaresGame(); 00052 00060 void createGame(const QVector<KSquaresPlayer> &startPlayers, int startWidth, int startHeight); 00064 void start() {gameInProgress = true;} 00068 void stop() {gameInProgress = false;} 00072 void switchPlayer(); 00076 int currentPlayerId() const {return i_currentPlayerId;} 00080 KSquaresPlayer* currentPlayer() {return &players[currentPlayerId()];} 00081 00082 //getters 00086 QList<int> squares() const {return squareOwnerTable;} 00090 QList<bool> lines() const {return lineList;} 00094 int boardWidth() const {return width;} 00098 int boardHeight() const {return height;} 00099 00100 public Q_SLOTS: 00104 void addLineToIndex(int index); 00105 00106 protected: 00112 int nextPlayer(); 00114 void resetEverything(); 00115 00117 void tryEndGo(); 00119 void checkForNewSquares(); 00125 void playerSquareComplete(int index); 00126 00127 // Static throughout each game 00129 int numOfPlayers; 00131 int width; 00133 int height; 00135 QList<int> squareOwnerTable; 00137 QList<bool> lineList; 00138 00139 // Updated as the game progresses 00141 QVector<KSquaresPlayer> players; 00142 00143 // Probably changes every go 00145 int i_currentPlayerId; 00147 bool anotherGo; 00149 bool gameInProgress; 00151 int lastLine; 00152 signals: 00154 void takeTurnSig(KSquaresPlayer*); //emit the new curent player 00156 void gameOver(const QVector<KSquaresPlayer> &); //for scoreboard purposes 00158 void drawLine(int,QColor); //int == lineList index 00160 void drawSquare(int,QColor); //int == squareOwnerTable index 00162 void highlightMove(int); 00163 }; 00164 00165 #endif // KSQUARESGAME_H
KDE 4.2 API Reference