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

libkdegames/libkdegamesprivate/kgame

Public Slots | Signals | Public Member Functions | Protected Member Functions | List of all members
KGameComputerIO Class Reference

#include <KGame/KGameIO>

Inheritance diagram for KGameComputerIO:
Inheritance graph
[legend]

Public Slots

virtual void advance ()
 

Signals

void signalReaction ()
 
- Signals inherited from KGameIO
void signalPrepareTurn (QDataStream &stream, bool turn, KGameIO *io, bool *send)
 

Public Member Functions

 KGameComputerIO ()
 
 KGameComputerIO (KPlayer *player)
 
 ~KGameComputerIO ()
 
void pause (int calls=-1)
 
int reactionPeriod () const
 
int rtti () const
 
void setAdvancePeriod (int ms)
 
void setReactionPeriod (int advanceCalls)
 
void stopAdvancePeriod ()
 
void unpause ()
 
- Public Member Functions inherited from KGameIO
 KGameIO ()
 
 KGameIO (KPlayer *)
 
virtual ~KGameIO ()
 
void Debug ()
 
KGame * game () const
 
virtual void initIO (KPlayer *p)
 
virtual void notifyTurn (bool b)
 
KPlayer * player () const
 
bool sendInput (QDataStream &stream, bool transmit=true, quint32 sender=0)
 
void setPlayer (KPlayer *p)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Protected Member Functions

virtual void reaction ()
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from KGameIO
enum  IOMode {
  GenericIO =1, KeyIO =2, MouseIO =4, ProcessIO =8,
  ComputerIO =16
}
 
- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

KGameIO variant for real-time games.

The KGameComputerIO class. It is used to create a LOCAL computer player and communicate transparently with it. Question: Is this needed or is it overwritten anyway for a real game?

You most probably don't want to use this if you want to design a turn based game/player. You'll rather use KGameIO directly, i.e. subclass it yourself. You just need to use KGameIO::signalPrepareTurn and/or KGameIO::notifyTurn there.

This is rather meant to be of use in real time games.

Author
b_man.nosp@m.n@gm.nosp@m.x.de

Definition at line 513 of file kgameio.h.

Constructor & Destructor Documentation

KGameComputerIO::KGameComputerIO ( )

Creates a LOCAL computer player.

Definition at line 499 of file kgameio.cpp.

KGameComputerIO::KGameComputerIO ( KPlayer *  player)

Definition at line 504 of file kgameio.cpp.

KGameComputerIO::~KGameComputerIO ( )

Definition at line 509 of file kgameio.cpp.

Member Function Documentation

void KGameComputerIO::advance ( )
virtualslot

Works kind of similar to QCanvas::advance.

Increase the internal advance counter. If reactionPeriod is reached the counter is set back to 0 and signalReaction is emitted. This is when the player is meant to do something (move its units or so).

This is very useful if you use QCanvas as you can use this in your QCanvas::advance call. The advantage is that if you change the speed of the game (i.e. change QCanvas::setAdvancePeriod) the computer player gets slower as well.

If you don't use QCanvas you can use setAdvancePeriod to get the same result. Alternatively you can just use a QTimer.

Definition at line 560 of file kgameio.cpp.

void KGameComputerIO::pause ( int  calls = -1)

Ignore calls number of advance calls.

if calls is -1 then all following advance calls are ignored until unpause is called.

This simply prevents the internal advance counter to be increased.

You may want to use this to emulate a "thinking" computer player. Note that this means if you increase the advance period (see setAdvancePeriod), i.e. if you change the speed of your game, your computer player thinks "faster".

Parameters
callsNumber of advance calls to be ignored

Definition at line 550 of file kgameio.cpp.

void KGameComputerIO::reaction ( )
protectedvirtual

Default implementation simply emits signalReaction.

Definition at line 579 of file kgameio.cpp.

int KGameComputerIO::reactionPeriod ( ) const

Definition at line 528 of file kgameio.cpp.

int KGameComputerIO::rtti ( ) const
virtual

Run time idendification.

Predefined values are from IOMode You MUST overwrite this in derived classes!

Returns
rtti value

Implements KGameIO.

Definition at line 518 of file kgameio.cpp.

void KGameComputerIO::setAdvancePeriod ( int  ms)

Start a QTimer which calls advance every ms milli seconds.

Definition at line 533 of file kgameio.cpp.

void KGameComputerIO::setReactionPeriod ( int  advanceCalls)

The number of advance calls until the player (or rather: the IO) does something (default: 1).

Definition at line 523 of file kgameio.cpp.

void KGameComputerIO::signalReaction ( )
signal

This signal is emitted when your computer player is meant to do something, or better is meant to be allowed to do something.

void KGameComputerIO::stopAdvancePeriod ( )

Definition at line 541 of file kgameio.cpp.

void KGameComputerIO::unpause ( )

Equivalent to pause(0).

Immediately continue to increase the internal advance counter.

Definition at line 555 of file kgameio.cpp.


The documentation for this class was generated from the following files:
  • kgameio.h
  • kgameio.cpp
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