kplayer.h
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 <qstring.h>
00025 #include <qobject.h>
00026 #include <qptrlist.h>
00027
00028 #include "kgameproperty.h"
00029
00030 class KGame;
00031 class KGameIO;
00032 class KGamePropertyBase;
00033 class KGamePropertyHandler;
00034
00035 class KPlayerPrivate;
00036
00068 class KPlayer : public QObject
00069 {
00070 Q_OBJECT
00071
00072 public:
00073 typedef QPtrList<KGameIO> KGameIOList;
00074
00075
00080 KPlayer();
00081
00087 KPlayer(KGame* game);
00088
00089 virtual ~KPlayer();
00090
00097 virtual int rtti() const {return 0;}
00098
00102 void Debug();
00103
00104
00110 KGameIOList *ioList() {return &mInputList;}
00111
00119 void setGame(KGame *game) {mGame=game;}
00120
00126 KGame *game() const {return mGame;}
00127
00135 void setAsyncInput(bool a) {mAsyncInput = a;}
00136
00143 bool asyncInput() const {return mAsyncInput.value();}
00144
00154 bool isVirtual() const;
00155
00163 void setVirtual(bool v);
00164
00172 bool isActive() const {return mActive;}
00173
00179 void setActive(bool v) {mActive=v;}
00180
00186 Q_UINT32 id() const;
00187
00188
00189
00190
00191
00192
00193 void setId(Q_UINT32 i);
00194
00206 int userId() const {return mUserId.value();}
00207
00208
00209
00210
00211
00212 void setUserId(int i) {mUserId = i;}
00213
00224 int networkPriority() const;
00225
00242 void setNetworkPriority(int b);
00243
00249 KPlayer *networkPlayer() const;
00250
00254 void setNetworkPlayer(KPlayer *p);
00255
00256
00261 void setGroup(const QString& group);
00262
00266 virtual const QString& group() const;
00267
00273 void setName(const QString& name);
00274
00278 virtual const QString& name() const;
00279
00280
00281
00290 bool addGameIO(KGameIO *input);
00291
00302 bool removeGameIO(KGameIO *input=0,bool deleteit=true);
00303
00311 KGameIO *findRttiIO(int rtti) const;
00312
00320 bool hasRtti(int rtti) const {return findRttiIO(rtti)!=0;}
00321
00322
00335 virtual bool forwardInput(QDataStream &msg,bool transmit=true, Q_UINT32 sender=0);
00336
00340 virtual bool forwardMessage(QDataStream &msg,int msgid,Q_UINT32 receiver=0,Q_UINT32 sender=0);
00341
00342
00348 bool myTurn() const {return mMyTurn.value();}
00349
00359 bool setTurn(bool b,bool exclusive=true);
00360
00361
00362
00374 virtual bool load(QDataStream &stream);
00375
00383 virtual bool save(QDataStream &stream);
00384
00392 void networkTransmission(QDataStream &stream,int msgid,Q_UINT32 sender);
00393
00399 KGamePropertyBase* findProperty(int id) const;
00400
00410 bool addProperty(KGamePropertyBase* data);
00411
00418 int calcIOValue();
00419
00423 KGamePropertyHandler* dataHandler();
00424
00425 signals:
00432 void signalNetworkData(int msgid, const QByteArray& buffer, Q_UINT32 sender, KPlayer *me);
00433
00440 void signalPropertyChanged(KGamePropertyBase *property,KPlayer *me);
00441
00442 protected slots:
00446 void sendProperty(int msgid, QDataStream& stream, bool* sent);
00450 void emitSignal(KGamePropertyBase *me);
00451
00452
00453 private:
00454 void init();
00455
00456 private:
00457 KGame *mGame;
00458 bool mActive;
00459 KGameIOList mInputList;
00460
00461
00462
00463 KGamePropertyBool mAsyncInput;
00464 KGamePropertyBool mMyTurn;
00465 KGamePropertyInt mUserId;
00466
00467 KPlayerPrivate* d;
00468 };
00469
00470 #endif
This file is part of the documentation for libkdegames Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 12 22:53:44 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003