• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libkdegames/kgame

kplayer.h

Go to the documentation of this file.
00001 /*
00002     This file is part of the KDE games library
00003     Copyright (C) 2001 Martin Heni (kde at heni-online.de)
00004     Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License version 2 as published by the Free Software Foundation.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
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       // KPlayer(KGame *,KGameIO * input=0);
00081       explicit KPlayer();
00082 
00083       virtual ~KPlayer();
00084 
00091       virtual int rtti() const;
00092 
00096       void Debug();
00097 
00098       // properties
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       /* Set the players id. This is done automatically by
00183        * the game object when adding a new player!
00184        *
00185        * @param i the player id
00186        */
00187       void setId(quint32 i);
00188 
00200       int userId() const;
00201 
00202       /* Set the user defined players id.
00203        *
00204        * @param i the user defined player id
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       // A name and group the player belongs to
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       // set devices
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       // Message exchange
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       // Game logic
00342       bool myTurn() const;
00343 
00353       bool setTurn(bool b,bool exclusive=true);
00354 
00355 
00356       // load/save
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

libkdegames/kgame

Skip menu "libkdegames/kgame"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal