KDEGames

kgamesequence.h
1 /*
2  This file is part of the KDE games library
3  SPDX-FileCopyrightText: 2003 Andreas Beckermann <[email protected]>
4  SPDX-FileCopyrightText: 2003 Martin Heni <kde at heni-online.de>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 
9 #ifndef __KGAMESEQUENCE_H_
10 #define __KGAMESEQUENCE_H_
11 
12 // own
13 #include "libkdegamesprivate_export.h"
14 // Qt
15 #include <QObject>
16 // Std
17 #include <memory>
18 
19 class KPlayer;
20 class KGame;
21 
22 /**
23  * \class KGameSequence kgamesequence.h <KGame/KGameSequence>
24  *
25  * This class takes care of round or move management as well of the gameover
26  * condition. It is especially used for round based games. For these games @ref
27  * nextPlayer and @ref checkGameOver are the most important methods.
28  *
29  * You can subclass KGameSequence and use @ref KGame::setGameSequence to use
30  * your own rules. Note that @ref KGame will take ownership and therefore will
31  * delete the object on destruction.
32  * @short Round/move management class
33  * @author Andreas Beckermann <[email protected]>
34  **/
35 class KDEGAMESPRIVATE_EXPORT KGameSequence : public QObject
36 {
37  Q_OBJECT
38 public:
39  KGameSequence();
40  virtual ~KGameSequence();
41 
42  /**
43  * Select the next player in a turn based game. In an asynchronous game this
44  * function has no meaning. Overwrite this function for your own game sequence.
45  * Per default it selects the next player in the playerList
46  */
47  virtual KPlayer* nextPlayer(KPlayer *last, bool exclusive = true);
48 
49  virtual void setCurrentPlayer(KPlayer* p);
50 
51  /**
52  * @return The @ref KGame object this sequence is for, or NULL if none.
53  **/
54  KGame* game() const;
55 
56  KPlayer* currentPlayer() const;
57 
58  /**
59  * Set the @ref KGame object for this sequence. This is called
60  * automatically by @ref KGame::setGameSequence and you should not call
61  * it.
62  **/
63  void setGame(KGame* game);
64 
65  /**
66  * Check whether the game is over. The default implementation always
67  * returns 0.
68  *
69  * @param player the player who made the last move
70  * @return anything else but 0 is considered as game over
71  **/
72  virtual int checkGameOver(KPlayer *player);
73 
74 private:
75  std::unique_ptr<class KGameSequencePrivate> const d;
76 
78 };
79 
80 #endif
81 
This class takes care of round or move management as well of the gameover condition.
Definition: kgamesequence.h:35
Base class for a game player.
Definition: kplayer.h:60
Q_DISABLE_COPY(Class)
The main KDE game object.
Definition: kgame.h:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri May 14 2021 22:37:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.