KGameComputerIO
#include <KGame/KGameIO>
Signals | |
void | signalReaction () |
Signals inherited from KGameIO | |
void | signalPrepareTurn (QDataStream &stream, bool turn, KGameIO *io, bool *send) |
Public Slots | |
virtual void | advance () |
Public Member Functions | |
KGameComputerIO () | |
KGameComputerIO (KPlayer *player) | |
void | pause (int calls=-1) |
int | reactionPeriod () const |
int | rtti () const override |
void | setAdvancePeriod (int ms) |
void | setReactionPeriod (int advanceCalls) |
void | stopAdvancePeriod () |
void | unpause () |
Public Member Functions inherited from KGameIO | |
KGameIO () | |
KGameIO (KPlayer *) | |
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) | |
QBindable< QString > | bindableObjectName () |
bool | blockSignals (bool block) |
const QObjectList & | children () const const |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectInfo () const const |
void | dumpObjectTree () const const |
QList< QByteArray > | dynamicPropertyNames () const const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (Qt::FindChildOptions options) const const |
bool | inherits (const char *className) const const |
void | installEventFilter (QObject *filterObj) |
bool | isQuickItemType () const const |
bool | isWidgetType () const const |
bool | isWindowType () const const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const const |
void | moveToThread (QThread *targetThread) |
QString | objectName () const const |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
QVariant | property (const char *name) const const |
Q_CLASSINFO (Name, Value) | |
Q_EMIT Q_EMIT | |
Q_ENUM (...) | |
Q_ENUM_NS (...) | |
Q_ENUMS (...) | |
Q_FLAG (...) | |
Q_FLAG_NS (...) | |
Q_FLAGS (...) | |
Q_GADGET Q_GADGET | |
Q_GADGET_EXPORT (EXPORT_MACRO) | |
Q_INTERFACES (...) | |
Q_INVOKABLE Q_INVOKABLE | |
Q_MOC_INCLUDE Q_MOC_INCLUDE | |
Q_NAMESPACE Q_NAMESPACE | |
Q_NAMESPACE_EXPORT (EXPORT_MACRO) | |
Q_OBJECT Q_OBJECT | |
Q_PROPERTY (...) | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
Q_SIGNAL Q_SIGNAL | |
Q_SIGNALS Q_SIGNALS | |
Q_SLOT Q_SLOT | |
Q_SLOTS Q_SLOTS | |
T | qobject_cast (const QObject *object) |
T | qobject_cast (QObject *object) |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
void | removeEventFilter (QObject *obj) |
void | setObjectName (const QString &name) |
void | setObjectName (QAnyStringView name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | setProperty (const char *name, QVariant &&value) |
bool | signalsBlocked () const const |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType) |
QThread * | thread () const const |
Protected Member Functions | |
virtual void | reaction () |
Protected Member Functions inherited from KGameIO | |
KGameIO (KGameIOPrivate &dd, KPlayer *player=nullptr) | |
Protected Member Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
bool | isSignalConnected (const QMetaMethod &signal) const const |
int | receivers (const char *signal) const const |
QObject * | sender () const const |
int | senderSignalIndex () const 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 } |
Public Types inherited from QObject | |
typedef | QObjectList |
Properties inherited from QObject | |
objectName | |
Static Public Member Functions inherited from QObject | |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
bool | disconnect (const QMetaObject::Connection &connection) |
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) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
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.
Constructor & Destructor Documentation
◆ KGameComputerIO() [1/2]
KGameComputerIO::KGameComputerIO | ( | ) |
Creates a LOCAL computer player.
Definition at line 436 of file kgameio.cpp.
◆ KGameComputerIO() [2/2]
|
explicit |
Definition at line 441 of file kgameio.cpp.
◆ ~KGameComputerIO()
|
override |
Definition at line 446 of file kgameio.cpp.
Member Function Documentation
◆ 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 506 of file kgameio.cpp.
◆ pause()
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
-
calls Number of advance calls to be ignored
Definition at line 494 of file kgameio.cpp.
◆ reaction()
|
protectedvirtual |
Default implementation simply emits signalReaction.
Definition at line 523 of file kgameio.cpp.
◆ reactionPeriod()
int KGameComputerIO::reactionPeriod | ( | ) | const |
Definition at line 467 of file kgameio.cpp.
◆ rtti()
|
overridevirtual |
Run time identification.
Predefined values are from IOMode You MUST overwrite this in derived classes!
- Returns
- rtti value
Implements KGameIO.
Definition at line 455 of file kgameio.cpp.
◆ setAdvancePeriod()
void KGameComputerIO::setAdvancePeriod | ( | int | ms | ) |
Start a QTimer which calls advance every ms
milli seconds.
Definition at line 474 of file kgameio.cpp.
◆ setReactionPeriod()
void KGameComputerIO::setReactionPeriod | ( | int | advanceCalls | ) |
The number of advance calls until the player (or rather: the IO) does something (default: 1).
Definition at line 460 of file kgameio.cpp.
◆ 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.
◆ stopAdvancePeriod()
void KGameComputerIO::stopAdvancePeriod | ( | ) |
Definition at line 484 of file kgameio.cpp.
◆ unpause()
void KGameComputerIO::unpause | ( | ) |
Equivalent to pause(0).
Immediately continue to increase the internal advance counter.
Definition at line 501 of file kgameio.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:13:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.