• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

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         int currentPlayerId() const {return i_currentPlayerId;}
00076         KSquaresPlayer* currentPlayer() {return &players[currentPlayerId()];}
00077         
00078         //getters
00082         QList<int> squares() const {return squareOwnerTable;}
00086         QList<bool> lines() const {return lineList;}
00090         int boardWidth() const {return width;}
00094         int boardHeight() const {return height;}
00095         
00096     public Q_SLOTS:
00100         void addLineToIndex(int index);
00101 
00102     protected:
00108         int nextPlayer();
00110         void resetEverything();
00111         
00113         void tryEndGo();
00115         void checkForNewSquares();
00121         void playerSquareComplete(int index);
00122         
00123         // Static throughout each game
00125         int numOfPlayers;
00127         int width;
00129         int height;
00131         QList<int> squareOwnerTable;
00133         QList<bool> lineList;
00134         
00135         // Updated as the game progresses
00137         QVector<KSquaresPlayer> players;
00138         
00139         // Probably changes every go
00141         int i_currentPlayerId;
00143         bool anotherGo;
00145         bool gameInProgress;
00146         
00147     signals:
00149         void takeTurnSig(KSquaresPlayer*);  //emit the new curent player
00151         void gameOver(const QVector<KSquaresPlayer> &); //for scoreboard purposes
00153         void drawLine(int,QColor);  //int == lineList index
00155         void drawSquare(int,QColor);    //int == squareOwnerTable index
00156 };
00157 
00158 #endif // KSQUARESGAME_H

ksquares

Skip menu "ksquares"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal