KDEGames

kgamesequence.h
1/*
2 This file is part of the KDE games library
3 SPDX-FileCopyrightText: 2003 Andreas Beckermann <b_mann@gmx.de>
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 "kdegamesprivate_export.h"
14// Qt
15#include <QObject>
16// Std
17#include <memory>
18
19class KPlayer;
20class 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 <b_mann@gmx.de>
34 */
35class KDEGAMESPRIVATE_EXPORT KGameSequence : public QObject
36{
37 Q_OBJECT
38
39public:
41 ~KGameSequence() override;
42
43 /**
44 * Select the next player in a turn based game. In an asynchronous game this
45 * function has no meaning. Overwrite this function for your own game sequence.
46 * Per default it selects the next player in the playerList
47 */
48 virtual KPlayer *nextPlayer(KPlayer *last, bool exclusive = true);
49
50 virtual void setCurrentPlayer(KPlayer *p);
51
52 /**
53 * @return The @ref KGame object this sequence is for, or NULL if none.
54 */
55 KGame *game() const;
56
57 KPlayer *currentPlayer() const;
58
59 /**
60 * Set the @ref KGame object for this sequence. This is called
61 * automatically by @ref KGame::setGameSequence and you should not call
62 * it.
63 */
64 void setGame(KGame *game);
65
66 /**
67 * Check whether the game is over. The default implementation always
68 * returns 0.
69 *
70 * @param player the player who made the last move
71 * @return anything else but 0 is considered as game over
72 */
73 virtual int checkGameOver(KPlayer *player);
74
75private:
76 std::unique_ptr<class KGameSequencePrivate> const d;
77
78 Q_DISABLE_COPY(KGameSequence)
79};
80
81#endif
This class takes care of round or move management as well of the gameover condition.
The main KDE game object.
Definition kgame.h:47
Base class for a game player.
Definition kplayer.h:60
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:56:07 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.