|
| KGame (int cookie=42, QObject *parent=nullptr) |
|
| ~KGame () override |
|
bool | activatePlayer (KPlayer *player) |
|
bool | addPlayer (KPlayer *newplayer) |
|
bool | addProperty (KGamePropertyBase *data) |
|
virtual KPlayer * | createPlayer (int rtti, int io, bool isvirtual) |
|
KGamePropertyHandler * | dataHandler () const |
|
void | Debug () override |
|
KPlayer * | findPlayer (quint32 id) const |
|
KGamePropertyBase * | findProperty (int id) const |
|
KGameSequence * | gameSequence () const |
|
int | gameStatus () const |
|
bool | inactivatePlayer (KPlayer *player) |
|
KGamePlayerList * | inactivePlayerList () |
|
const KGamePlayerList * | inactivePlayerList () const |
|
bool | isRunning () const |
|
virtual bool | load (const QString &filename, bool reset=true) |
|
virtual bool | load (QDataStream &stream, bool reset=true) |
|
int | maxPlayers () const |
|
uint | minPlayers () const |
|
void | networkTransmission (QDataStream &stream, int msgid, quint32 receiver, quint32 sender, quint32 clientID) override |
|
uint | playerCount () const |
|
void | playerDeleted (KPlayer *player) |
|
KGamePlayerList * | playerList () |
|
const KGamePlayerList * | playerList () const |
|
GamePolicy | policy () const |
|
bool | removePlayer (KPlayer *player) |
|
virtual bool | reset () |
|
virtual bool | save (const QString &filename, bool saveplayers=true) |
|
virtual bool | save (QDataStream &stream, bool saveplayers=true) |
|
bool | sendGroupMessage (const QByteArray &msg, int msgid, quint32 sender, const QString &group) |
|
bool | sendGroupMessage (const QDataStream &msg, int msgid, quint32 sender, const QString &group) |
|
bool | sendGroupMessage (const QString &msg, int msgid, quint32 sender, const QString &group) |
|
bool | sendGroupMessage (int msg, int msgid, quint32 sender, const QString &group) |
|
virtual bool | sendPlayerInput (QDataStream &msg, KPlayer *player, quint32 sender=0) |
|
bool | sendPlayerProperty (int msgid, QDataStream &s, quint32 playerId) |
|
void | setGameSequence (KGameSequence *sequence) |
|
void | setGameStatus (int status) |
|
void | setMaxPlayers (uint maxnumber) |
|
void | setMinPlayers (uint minnumber) |
|
void | setPolicy (GamePolicy p, bool recursive=true) |
|
virtual bool | systemPlayerInput (QDataStream &msg, KPlayer *player, quint32 sender=0) |
|
| KGameNetwork (int cookie=42, QObject *parent=nullptr) |
|
bool | connectToServer (const QString &host, quint16 port) |
|
bool | connectToServer (KMessageIO *connection) |
|
int | cookie () const |
|
void | disconnect () |
|
void | electAdmin (quint32 clientID) |
|
quint32 | gameId () const |
|
QString | hostName () const |
|
bool | isAdmin () const |
|
bool | isMaster () const |
|
bool | isNetwork () const |
|
bool | isOfferingConnections () const |
|
virtual void | lock () |
|
KMessageClient * | messageClient () const |
|
KMessageServer * | messageServer () const |
|
bool | offerConnections (quint16 port) |
|
quint16 | port () const |
|
void | sendError (int error, const QByteArray &message, quint32 receiver=0, quint32 sender=0) |
|
bool | sendMessage (const QByteArray &buffer, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendMessage (const QDataStream &msg, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendMessage (const QString &msg, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendMessage (int data, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendSystemMessage (const QByteArray &buffer, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendSystemMessage (const QDataStream &msg, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendSystemMessage (const QString &msg, int msgid, quint32 receiver=0, quint32 sender=0) |
|
bool | sendSystemMessage (int data, int msgid, quint32 receiver=0, quint32 sender=0) |
|
void | setDiscoveryInfo (const QString &type, const QString &name=QString()) |
|
void | setMaxClients (int max) |
|
bool | stopServerConnection () |
|
virtual void | unlock () |
|
| QObject (QObject *parent) |
|
QBindable< QString > | bindableObjectName () |
|
bool | blockSignals (bool block) |
|
const QObjectList & | children () const const |
|
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
|
void | deleteLater () |
|
void | destroyed (QObject *obj) |
|
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
|
bool | disconnect (const QObject *receiver, const char *method) const const |
|
void | dumpObjectInfo () const const |
|
void | dumpObjectTree () const const |
|
QList< QByteArray > | dynamicPropertyNames () const const |
|
virtual bool | event (QEvent *e) |
|
virtual bool | eventFilter (QObject *watched, QEvent *event) |
|
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
|
QList< T > | findChildren (Qt::FindChildOptions options) const const |
|
bool | inherits (const char *className) const const |
|
void | installEventFilter (QObject *filterObj) |
|
bool | isQuickItemType () const const |
|
bool | isWidgetType () const const |
|
bool | isWindowType () const const |
|
void | killTimer (int id) |
|
virtual const QMetaObject * | metaObject () const const |
|
void | moveToThread (QThread *targetThread) |
|
QString | objectName () const const |
|
void | objectNameChanged (const QString &objectName) |
|
QObject * | parent () const const |
|
QVariant | property (const char *name) const const |
|
| Q_CLASSINFO (Name, Value) |
|
| Q_EMIT Q_EMIT |
|
| Q_ENUM (...) |
|
| Q_ENUM_NS (...) |
|
| Q_ENUMS (...) |
|
| Q_FLAG (...) |
|
| Q_FLAG_NS (...) |
|
| Q_FLAGS (...) |
|
| Q_GADGET Q_GADGET |
|
| Q_GADGET_EXPORT (EXPORT_MACRO) |
|
| Q_INTERFACES (...) |
|
| Q_INVOKABLE Q_INVOKABLE |
|
| Q_MOC_INCLUDE Q_MOC_INCLUDE |
|
| Q_NAMESPACE Q_NAMESPACE |
|
| Q_NAMESPACE_EXPORT (EXPORT_MACRO) |
|
| Q_OBJECT Q_OBJECT |
|
| Q_PROPERTY (...) |
|
| Q_REVISION Q_REVISION |
|
| Q_SET_OBJECT_NAME (Object) |
|
| Q_SIGNAL Q_SIGNAL |
|
| Q_SIGNALS Q_SIGNALS |
|
| Q_SLOT Q_SLOT |
|
| Q_SLOTS Q_SLOTS |
|
T | qobject_cast (const QObject *object) |
|
T | qobject_cast (QObject *object) |
|
| QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT |
|
void | removeEventFilter (QObject *obj) |
|
void | setObjectName (const QString &name) |
|
void | setObjectName (QAnyStringView name) |
|
void | setParent (QObject *parent) |
|
bool | setProperty (const char *name, const QVariant &value) |
|
bool | setProperty (const char *name, QVariant &&value) |
|
bool | signalsBlocked () const const |
|
int | startTimer (int interval, Qt::TimerType timerType) |
|
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
|
QThread * | thread () const const |
|
The main KDE game object.
The KGame class is the central game object. A game basically consists of following features:
- Player handling (add, remove,...)
- Game status (end,start,pause,...)
- load/save
- Move (and message) handling
- nextPlayer and gameOver()
- Network connection (for KGameNetwork)
Example:
The main KDE game object.
KGame(int cookie=42, QObject *parent=nullptr)
Create a KGame object.
Definition at line 46 of file kgame.h.
The policy of the property.
This can be PolicyClean (setVale uses send), PolicyDirty (setValue uses changeValue) or PolicyLocal (setValue uses setLocal).
A "clean" policy means that the property is always the same on every client. This is achieved by calling send which actually changes the value only when the message from the MessageServer is received.
A "dirty" policy means that as soon as setValue is called the property is changed immediately. And additionally sent over network. This can sometimes lead to bugs as the other clients do not immediately have the same value. For more information see changeValue.
PolicyLocal means that a KGameProperty behaves like ever "normal" variable. Whenever setValue is called (e.g. using "=") the value of the property is changes immediately without sending it over network. You might want to use this if you are sure that all clients set the property at the same time.
Definition at line 74 of file kgame.h.
bool KGame::addPlayer |
( |
KPlayer * | newplayer | ) |
|
Note that KPlayer::save must be implemented properly, as well as KPlayer::rtti This will only send a message to all clients.
The player is not added directly! See also playerInput which will be called as soon as the player really has been added.
Note that an added player will first get into a "queue" and won't be in the game. It will be added to the game as soon as systemAddPlayer is called what will happen as soon as IdAddPlayer is received.
Note: you probably want to connect to signalPlayerJoinedGame for further initialization!
- Parameters
-
newplayer | The player you want to add. KGame will send a message to all clients and add the player using systemAddPlayer |
Definition at line 365 of file kgame.cpp.
This virtual function can be overwritten for your own player management.
It is called when a new game connects to an existing network game or to the network master. In case you do not want all players of both games to be present in the new network game, you can deactivate players here. This is of particular importance if you have a game with fixed number of player like e.g. chess. A network connect needs to disable one player of each game to make sense.
Not overwriting this function will activate a default behaviour which will deactivate players until the maxPlayers() number is reached according to the KPlayer::networkPriority() value. Players with a low value will be kicked out first. With equal priority players of the new client will leave first. This means, not setting this value and not overwriting this function will never allow a chess game to add client players!!! On the other hand setting one player of each game to a networkPriorty of say 10, already does most of the work for you.
The parameters of this function are the playerlist of the network game, which is playerList(). The second argument is the player list of the new client who wants to join and the third argument serves as return parameter. All player ID's which are written into this list will be removed from the created game. You do this by an
- Parameters
-
oldplayer | - the list of the network players |
newplayer | - the list of the client players |
inactivate | - the value list of ids to be deactivated |
Definition at line 698 of file kgame.h.