libkdegames/kgame
kplayer.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __KPLAYER_H_
00022 #define __KPLAYER_H_
00023
00024 #include <QtCore/QObject>
00025 #include <QtCore/QList>
00026
00027 #include <libkdegames_export.h>
00028
00029 class KGame;
00030 class KGameIO;
00031 class KGamePropertyBase;
00032 class KGamePropertyHandler;
00033
00034 class KPlayerPrivate;
00035
00069 class KDEGAMES_EXPORT KPlayer : public QObject
00070 {
00071 Q_OBJECT
00072
00073 public:
00074 typedef QList<KGameIO*> KGameIOList;
00075
00076
00081 explicit KPlayer();
00082
00083 virtual ~KPlayer();
00084
00091 virtual int rtti() const;
00092
00096 void Debug();
00097
00098
00104 KGameIOList *ioList();
00105
00113 void setGame(KGame *game);
00114
00120 KGame *game() const;
00121
00129 void setAsyncInput(bool a);
00130
00137 bool asyncInput() const;
00138
00148 bool isVirtual() const;
00149
00157 void setVirtual(bool v);
00158
00166 bool isActive() const;
00167
00173 void setActive(bool v);
00174
00180 quint32 id() const;
00181
00182
00183
00184
00185
00186
00187 void setId(quint32 i);
00188
00200 int userId() const;
00201
00202
00203
00204
00205
00206 void setUserId(int i);
00207
00218 int networkPriority() const;
00219
00236 void setNetworkPriority(int b);
00237
00243 KPlayer *networkPlayer() const;
00244
00248 void setNetworkPlayer(KPlayer *p);
00249
00250
00255 void setGroup(const QString& group);
00256
00260 virtual const QString& group() const;
00261
00267 void setName(const QString& name);
00268
00272 virtual const QString& name() const;
00273
00274
00275
00284 bool addGameIO(KGameIO *input);
00285
00296 bool removeGameIO(KGameIO *input=0,bool deleteit=true);
00297
00305 KGameIO *findRttiIO(int rtti) const;
00306
00314 bool hasRtti(int rtti) const;
00315
00316
00329 virtual bool forwardInput(QDataStream &msg,bool transmit=true, quint32 sender=0);
00330
00334 virtual bool forwardMessage(QDataStream &msg,int msgid,quint32 receiver=0,quint32 sender=0);
00335
00336
00342 bool myTurn() const;
00343
00353 bool setTurn(bool b,bool exclusive=true);
00354
00355
00356
00368 virtual bool load(QDataStream &stream);
00369
00377 virtual bool save(QDataStream &stream);
00378
00386 void networkTransmission(QDataStream &stream,int msgid,quint32 sender);
00387
00393 KGamePropertyBase* findProperty(int id) const;
00394
00404 bool addProperty(KGamePropertyBase* data);
00405
00412 int calcIOValue();
00413
00417 KGamePropertyHandler* dataHandler();
00418
00419 Q_SIGNALS:
00426 void signalNetworkData(int msgid, const QByteArray& buffer, quint32 sender, KPlayer *me);
00427
00434 void signalPropertyChanged(KGamePropertyBase *property,KPlayer *me);
00435
00436 protected Q_SLOTS:
00440 void sendProperty(int msgid, QDataStream& stream, bool* sent);
00444 void emitSignal(KGamePropertyBase *me);
00445
00446
00447 private:
00448 void init();
00449
00450 private:
00451 friend class KPlayerPrivate;
00452 KPlayerPrivate *const d;
00453
00454 Q_DISABLE_COPY(KPlayer)
00455 };
00456
00457 #endif