Code Search for Developers
 
 
  

kgamesequence.h from Boson at Krugle


Show kgamesequence.h syntax highlighted

/*
    This file is part of the KDE games library
    Copyright (C) 2003 Andreas Beckermann (b_mann@gmx.de)
    Copyright (C) 2003 Martin Heni (martin@heni-online.de)

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License version 2 as published by the Free Software Foundation.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
*/
#ifndef __KGAMESEQUENCE_H_
#define __KGAMESEQUENCE_H_

#include <qobject.h>

class KPlayer;
class KGame;

/**
 * This class takes care of round or move management as well of the gameover
 * condition. It is especially used for round based games. For these games @ref
 * nextPlayer and @ref checkGameOver are the most important methods.
 *
 * You can subclass KGameSequence and use @ref KGame::setGameSequence to use
 * your own rules. Note that @ref KGame will take ownership and therefore will
 * delete the object on destruction.
 * @short Round/move management class
 * @author Andreas Beckermann <b_mann@gmx.de>
 **/
class KGameSequence : public QObject
{
	Q_OBJECT
public:
	KGameSequence();
	virtual ~KGameSequence();

	/**
	 * Select the next player in a turn based game. In an asynchronous game this
	 * function has no meaning. Overwrite this function for your own game sequence.
	 * Per default it selects the next player in the playerList
	 */
	virtual KPlayer* nextPlayer(KPlayer *last, bool exclusive = true);

	virtual void setCurrentPlayer(KPlayer* p);

	/**
	 * @return The @ref KGame object this sequence is for, or NULL if none.
	 **/
	KGame* game() const { return mGame; }

	KPlayer* currentPlayer() const { return mCurrentPlayer; }

	/**
	 * Set the @ref KGame object for this sequence. This is called
	 * automatically by @ref KGame::setGameSequence and you should not call
	 * it.
	 **/
	void setGame(KGame* game);

	/**
	 * Check whether the game is over. The default implementation always
	 * returns 0.
	 *
	 * @param player the player who made the last move
	 * @return anything else but 0 is considered as game over
	**/
	virtual int checkGameOver(KPlayer *player);

private:
	KGame* mGame;
	KPlayer* mCurrentPlayer;
};

#endif





See more files for this project here

Boson

Boson is an OpenGL real-time strategy game. It is designed to run on Unix (Linux) computers, and is built on top of the KDE, Qt and kdegames libraries.

Project homepage: http://sourceforge.net/projects/boson
Programming language(s): C,C++
License: other

  CMakeLists.txt
  DESIGN
  kchatbase.cpp
  kchatbase.h
  kgame.cpp
  kgame.h
  kgamechat.cpp
  kgamechat.h
  kgamedebugdialog.cpp
  kgamedebugdialog.h
  kgameerror.cpp
  kgameerror.h
  kgameio.cpp
  kgameio.h
  kgamemessage.cpp
  kgamemessage.h
  kgamenetwork.cpp
  kgamenetwork.h
  kgameprocess.cpp
  kgameprocess.h
  kgameprogress.cpp
  kgameprogress.h
  kgameproperty.cpp
  kgameproperty.h
  kgamepropertyarray.h
  kgamepropertyhandler.cpp
  kgamepropertyhandler.h
  kgamepropertylist.h
  kgamesequence.cpp
  kgamesequence.h
  kgameversion.h
  kmessageclient.cpp
  kmessageclient.h
  kmessageio.cpp
  kmessageio.h
  kmessageserver.cpp
  kmessageserver.h
  kmessageserver.png
  kplayer.cpp
  kplayer.h
  kstdgameaction.cpp
  kstdgameaction.h
  libkdegames.html
  messages.txt
  scenario0.png
  scenario1.png
  scenario2.png