KDEGames
13 #include "kgamenetwork.h"
14 #include "libkdegamesprivate_export.h"
16 #include <kcoreaddons_export.h>
18 #include <QDataStream>
20 #include <QLoggingCategory>
23 Q_DECLARE_LOGGING_CATEGORY(GAMES_PRIVATE_KGAME)
25 #if KDEGAMESPRIVATE_ENABLE_DEPRECATED_SINCE(7, 3)
83 enum GamePolicy { PolicyUndefined = 0, PolicyClean = 1, PolicyDirty = 2, PolicyLocal = 3 };
90 explicit KGame(
int cookie = 42,
QObject *parent =
nullptr);
100 void Debug()
override;
107 enum GameStatus { Init = 0, Run = 1, Pause = 2, End = 3, Abort = 4, SystemPause = 5, Intro = 6, UserStatus = 7 };
115 KGamePlayerList *playerList();
120 const KGamePlayerList *playerList()
const;
126 KGamePlayerList *inactivePlayerList();
131 const KGamePlayerList *inactivePlayerList()
const;
133 #if KDEGAMESPRIVATE_ENABLE_DEPRECATED_SINCE(7, 3)
134 #if KCOREADDONS_ENABLE_DEPRECATED_SINCE(5, 75)
141 KDEGAMESPRIVATE_DEPRECATED_VERSION(7, 3,
"No known users. Any replacement should use QRandomGenerator.")
156 bool isRunning()
const;
164 KPlayer *findPlayer(quint32
id)
const;
194 bool addPlayer(
KPlayer *newplayer);
207 return removePlayer(player, 0);
214 void playerDeleted(
KPlayer *player);
219 bool activatePlayer(
KPlayer *player);
224 bool inactivatePlayer(
KPlayer *player);
232 void setMaxPlayers(uint maxnumber);
238 int maxPlayers()
const;
246 void setMinPlayers(uint minnumber);
252 uint minPlayers()
const;
258 uint playerCount()
const;
260 #if KDEGAMESPRIVATE_BUILD_DEPRECATED_SINCE(3, 2)
264 KDEGAMESPRIVATE_DEPRECATED_VERSION(3, 2,
"Use KGameSequence::nextPlayer()")
265 virtual
KPlayer *nextPlayer(
KPlayer *last,
bool exclusive = true);
285 virtual bool systemPlayerInput(
QDataStream &msg,
KPlayer *player, quint32 sender = 0);
313 virtual KPlayer *createPlayer(
int rtti,
int io,
bool isvirtual);
328 virtual bool load(
QDataStream &stream,
bool reset =
true);
338 virtual bool load(
const QString &filename,
bool reset =
true);
349 virtual bool save(
QDataStream &stream,
bool saveplayers =
true);
359 virtual bool save(
const QString &filename,
bool saveplayers =
true);
368 virtual bool reset();
376 int gameStatus()
const;
383 void setGameStatus(
int status);
393 bool sendPlayerProperty(
int msgid,
QDataStream &s, quint32 playerId);
407 void setPolicy(GamePolicy p,
bool recursive =
true);
412 GamePolicy policy()
const;
425 bool sendGroupMessage(
const QByteArray &msg,
int msgid, quint32 sender,
const QString &group);
426 bool sendGroupMessage(
const QDataStream &msg,
int msgid, quint32 sender,
const QString &group);
427 bool sendGroupMessage(
int msg,
int msgid, quint32 sender,
const QString &group);
428 bool sendGroupMessage(
const QString &msg,
int msgid, quint32 sender,
const QString &group);
459 void sendProperty(
int msgid,
QDataStream &stream,
bool *sent);
466 #if KDEGAMESPRIVATE_BUILD_DEPRECATED_SINCE(3, 2)
470 KDEGAMESPRIVATE_DEPRECATED_VERSION(3, 2,
"Use KGameSequence::nextPlayer() & KGameSequence::currentPlayer()")
471 virtual
void prepareNext();
478 void slotClientConnected(quint32 clientId);
487 void slotClientDisconnected(quint32 clientId,
bool broken);
494 void slotServerDisconnected();
514 void signalReplacePlayerIO(
KPlayer *player,
bool *remove);
576 void signalLoadError(
QDataStream &stream,
bool network,
int cookie,
bool &result);
584 void signalNetworkData(
int msgid,
const QByteArray &buffer, quint32 receiver, quint32 sender);
591 void signalMessageUpdate(
int msgid, quint32 receiver, quint32 sender);
603 void signalPlayerLeftGame(
KPlayer *player);
610 void signalPlayerJoinedGame(
KPlayer *player);
639 void signalClientJoinedGame(quint32 clientid,
KGame *me);
658 void signalClientLeftGame(
int clientID,
int oldgamestatus,
KGame *me);
740 Q_UNUSED(inactivate);
751 void savePlayers(
QDataStream &stream, KGamePlayerList *list =
nullptr);
778 bool systemInactivatePlayer(
KPlayer *player);
783 bool systemActivatePlayer(
KPlayer *player);
802 bool systemAddPlayer(
KPlayer *newplayer);
811 void systemRemovePlayer(
KPlayer *player,
bool deleteit);
823 virtual void negotiateNetworkGame(quint32 clientID);
825 #if KDEGAMESPRIVATE_ENABLE_DEPRECATED_SINCE(7, 3)
831 KDEGAMESPRIVATE_DEPRECATED_VERSION(7, 3,
"No known users")
835 void deletePlayers();
836 void deleteInactivePlayers();
838 #if KDEGAMESPRIVATE_BUILD_DEPRECATED_SINCE(3, 2)
845 KDEGAMESPRIVATE_DEPRECATED_VERSION(3, 2,
"Use KGameSequence")
846 virtual
int checkGameOver(
KPlayer *player);
862 virtual bool loadgame(
QDataStream &stream,
bool network,
bool reset);
873 virtual bool savegame(
QDataStream &stream,
bool network,
bool saveplayers);
893 bool removePlayer(
KPlayer *player, quint32 receiver);
898 void setupGame(quint32 sender);
903 void setupGameContinue(
QDataStream &msg, quint32 sender);
912 bool systemRemove(
KPlayer *player,
bool deleteit);
915 KGamePrivate *
const d;
bool removePlayer(KPlayer *player)
Sends a message over the network, msgid=IdRemovePlayer.
GameStatus
Game status - Use this to Control the game flow.
virtual void newPlayersJoin(KGamePlayerList *oldplayer, KGamePlayerList *newplayer, QList< int > &inactivate)
This virtual function can be overwritten for your own player management.
GamePolicy
The policy of the property.
The main KDE game object.
Base class for a game player.
A collection class for KGameProperty objects.
Q_SCRIPTABLE CaptureState status()
Base class of KGameProperty.
virtual void Debug()
Gives debug output of the game status.
The main KDE game object.
virtual void networkTransmission(QDataStream &, int, quint32, quint32, quint32 clientID)=0
Called by ReceiveNetworkTransmission().
Round/move management class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 03:49:44 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.