• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames/libkdegamesprivate/kgame

  • sources
  • kde-4.14
  • kdegames
  • libkdegames
  • libkdegamesprivate
  • kgame
kplayer.h
Go to the documentation of this file.
1 /*
2  This file is part of the KDE games library
3  Copyright (C) 2001 Martin Heni (kde at heni-online.de)
4  Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef __KPLAYER_H_
22 #define __KPLAYER_H_
23 
24 #include <QtCore/QObject>
25 #include <QtCore/QList>
26 
27 #include "../libkdegamesprivate_export.h"
28 
29 class KGame;
30 class KGameIO;
31 class KGamePropertyBase;
32 class KGamePropertyHandler;
33 
34 class KPlayerPrivate;
35 
69 class KDEGAMESPRIVATE_EXPORT KPlayer : public QObject
70 {
71  Q_OBJECT
72 
73 public:
74  typedef QList<KGameIO*> KGameIOList;
75 
76  // KPlayer(KGame *,KGameIO * input=0);
81  explicit KPlayer();
82 
83  virtual ~KPlayer();
84 
91  virtual int rtti() const;
92 
96  void Debug();
97 
98  // properties
104  KGameIOList *ioList();
105 
113  void setGame(KGame *game);
114 
120  KGame *game() const;
121 
129  void setAsyncInput(bool a);
130 
137  bool asyncInput() const;
138 
148  bool isVirtual() const;
149 
157  void setVirtual(bool v);
158 
166  bool isActive() const;
167 
173  void setActive(bool v);
174 
180  quint32 id() const;
181 
182  /* Set the players id. This is done automatically by
183  * the game object when adding a new player!
184  *
185  * @param i the player id
186  */
187  void setId(quint32 i);
188 
200  int userId() const;
201 
202  /* Set the user defined players id.
203  *
204  * @param i the user defined player id
205  */
206  void setUserId(int i);
207 
218  int networkPriority() const;
219 
236  void setNetworkPriority(int b);
237 
243  KPlayer *networkPlayer() const;
244 
248  void setNetworkPlayer(KPlayer *p);
249 
250  // A name and group the player belongs to
255  void setGroup(const QString& group);
256 
260  virtual const QString& group() const;
261 
267  void setName(const QString& name);
268 
272  virtual const QString& name() const;
273 
274 
275  // set devices
284  bool addGameIO(KGameIO *input);
285 
296  bool removeGameIO(KGameIO *input=0,bool deleteit=true);
297 
305  KGameIO *findRttiIO(int rtti) const;
306 
314  bool hasRtti(int rtti) const;
315 
316  // Message exchange
329  virtual bool forwardInput(QDataStream &msg,bool transmit=true, quint32 sender=0);
330 
334  virtual bool forwardMessage(QDataStream &msg,int msgid,quint32 receiver=0,quint32 sender=0);
335 
336  // Game logic
342  bool myTurn() const;
343 
353  bool setTurn(bool b,bool exclusive=true);
354 
355 
356  // load/save
368  virtual bool load(QDataStream &stream);
369 
377  virtual bool save(QDataStream &stream);
378 
386  void networkTransmission(QDataStream &stream,int msgid,quint32 sender);
387 
393  KGamePropertyBase* findProperty(int id) const;
394 
404  bool addProperty(KGamePropertyBase* data);
405 
412  int calcIOValue();
413 
417  KGamePropertyHandler* dataHandler();
418 
419 Q_SIGNALS:
426  void signalNetworkData(int msgid, const QByteArray& buffer, quint32 sender, KPlayer *me);
427 
434  void signalPropertyChanged(KGamePropertyBase *property,KPlayer *me);
435 
436 protected Q_SLOTS:
440  void sendProperty(int msgid, QDataStream& stream, bool* sent);
444  void emitSignal(KGamePropertyBase *me);
445 
446 
447 private:
448  void init();
449 
450 private:
451  friend class KPlayerPrivate;
452  KPlayerPrivate *const d;
453 
454  Q_DISABLE_COPY(KPlayer)
455 };
456 
457 #endif
QByteArray
QDataStream
KGamePropertyHandler
A collection class for KGameProperty objects.
Definition: kgamepropertyhandler.h:73
KPlayer::KGameIOList
QList< KGameIO * > KGameIOList
Definition: kplayer.h:74
QObject::name
const char * name() const
QObject
QString
QList< KGameIO * >
KPlayer
Base class for a game player.
Definition: kplayer.h:69
QObject::setName
void setName(const char *name)
KGamePropertyBase
Base class of KGameProperty.
Definition: kgameproperty.h:45
KGame
The main KDE game object.
Definition: kgame.h:60
KGameIO
Base class for IO devices for games.
Definition: kgameio.h:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:54 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames/libkdegamesprivate/kgame

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

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal