#include <kwin4doc.h>
Collaboration diagram for KWin4Doc:

Public Slots | |
| void | moveDone (int mode) |
| Indication from the view that a move has been displayed. | |
| void | loadSettings () |
| Load the game properties from the settings. | |
Signals | |
| void | signalGameRun () |
| Emmitted if the game status changes to run. | |
| void | signalChatChanged (KWin4Player *player) |
| Emmitted if the chat origin changes. | |
| void | signalNextPlayer (int playerNumber) |
| Emmitted when the next players move is due. | |
Public Member Functions | |
| KWin4Doc (QWidget *parent) | |
| Constructor. | |
| ~KWin4Doc () | |
| The dstructor. | |
| void | setView (KWin4View *view) |
| Adds a view to the document which displays the document contents. | |
| void | initPlayers () |
| Initializes the KGame derived players. | |
| bool | loadgame (QDataStream &stream, bool network, bool reset) |
| Save the document in the datastrem. | |
| void | readConfig (KConfig *config) |
| Read the game config from the config file. | |
| void | writeConfig (KConfig *config) |
| Write the game config to the config file. | |
| void | endGame (TABLE mode) |
| End a game. | |
| void | resetStatistic () |
| Reset all the player stats. | |
| bool | redoMove () |
| Redoes a move if possible. | |
| bool | undoMove () |
| Undoes a move if possible. | |
| void | calculateHint () |
| Generate a computer AI move and show it to the player as hint. | |
| int | getStatistic (COLOUR col, TABLE mode) |
| Returns the all time statistics for player of given color The mode determins what statistics to access. | |
| QString | getName (COLOUR col) |
| Retrieve the name of the player of the given color. | |
| void | setName (COLOUR col, const QString &n) |
| Set the name of the player of the given color. | |
| KGameIO::IOMode | playedBy (int col) |
| Query the IO mode of player og the given color. | |
| void | setPlayedBy (int col, KGameIO::IOMode mode) |
| Sets the input device mode for the given player color. | |
| KWin4Player * | getPlayer (COLOUR col) |
| Retrieve the player object for the given player colour. | |
| COLOUR | switchStartPlayer () |
| Swap the start player so that the game is started alternatingly. | |
| void | setCurrentPlayer (COLOUR no) |
| Sets the current player. | |
| COLOUR | getCurrentPlayer () |
| Retrieve the player whose turn it is next. | |
| int | getCurrentMove () |
| Retrieve the current move number. | |
| int | getMaxMove () |
| Retrieve the maximum move which has been made before undos. | |
| int | getHistoryCnt () |
| Retrieve the amount of moves in the undo/redo history. | |
Protected Slots | |
| void | repeatMove () |
| Initiate a repeate of the move. | |
| void | processAIHintCommand (QDataStream &in, KGameProcessIO *io) |
| An AI command was received from the computer AI _hint_ process. | |
| void | processAICommand (QDataStream &in, KGameProcessIO *io) |
| An AI command was received from the computer AI _input device_ process. | |
| void | clientConnected (quint32 cid, KGame *me) |
| This slot is called by the signal of KGame to indicated that the network connection is done and a new client is connected. | |
| void | prepareAITurn (QDataStream &stream, bool b, KGameIO *input, bool *eatevent) |
| This slot is called by the KGame input device when we should prepare a message to the AI process. | |
| void | networkMessageUpdate (int id, quint32 sender, quint32 receiver) |
| Debug: Listen to network messages. | |
| void | playerPropertyChanged (KGamePropertyBase *prop, KPlayer *player) |
| Called by KGame when a player property has changed. | |
| void | gamePropertyChanged (KGamePropertyBase *prop, KGame *me) |
| Called by KGame when a game property has changed. | |
Protected Member Functions | |
| void | createIO (KPlayer *player, KGameIO::IOMode io) |
| Create and add an KGameIO device to an given player. | |
| KPlayer * | createPlayer (int rtti, int io, bool isvirtual) |
| Create a player of a given type (here only one type possible) and equip it with a given KGameIO device. | |
| KPlayer * | nextPlayer (KPlayer *last, bool exclusive=true) |
| KGame function to determine the next player. | |
| void | newPlayersJoin (KGamePlayerList *list, KGamePlayerList *newList, QList< int > &inactive) |
| This is also an overwritten function of KGame. | |
| void | resetGame (bool initview) |
| Reset the whole game to the beginning (clear board, . | |
| MOVESTATUS | makeMove (int x, int mode) |
| Make a game move to the given position and return a status. | |
| bool | doMove (int x, int id) |
| Perform a game move. | |
| int | checkGameOver (KPlayer *player) |
| Check whether the field has a game over situation. | |
| int | checkGameOver (int x, COLOUR col) |
| Check whether the field has a game over situation. | |
| void | prepareGameMessage (QDataStream &stream, qint32 pl) |
| Pack the current game into a data stream so that it can be send to the computer AI. | |
| bool | playerInput (QDataStream &msg, KPlayer *player) |
| Main function to handle player input. | |
| void | recalcIO () |
| Set the IO devices new. | |
| void | activateCurrentPlayer () |
| Set the turn of the current player to true so that he can move. | |
| QString | findProcessName () |
| Find the name of the AI process executable file. | |
| void | setScore (long value) |
| Set the score value of the AI. | |
| void | setColour (int x, int y, COLOUR c) |
| Set the colour of a position on the game board. | |
| COLOUR | getColour (int x, int y) |
| Retrieve the colour of a position on the game board. | |
| COLOUR | getPlayerColour (int player) |
| Retrieve the color of the i-th player. | |
It is derived from the KGame framework.
Definition at line 44 of file kwin4doc.h.
|
|
Constructor.
Definition at line 50 of file kwin4doc.cpp. References clientConnected(), gamePropertyChanged(), global_debug, networkMessageUpdate(), Red, resetGame(), setCurrentPlayer(), and Yellow. Here is the call graph for this function: ![]() |
|
|
The dstructor.
Definition at line 121 of file kwin4doc.cpp. References writeConfig(). Here is the call graph for this function: ![]() |
|
|
Set the turn of the current player to true so that he can move.
Definition at line 210 of file kwin4doc.cpp. References getCurrentPlayer(), getPlayer(), and global_debug. Referenced by loadgame(). Here is the call graph for this function: ![]() |
|
|
Generate a computer AI move and show it to the player as hint.
Definition at line 1121 of file kwin4doc.cpp. References findProcessName(), getCurrentPlayer(), global_debug, prepareGameMessage(), and processAIHintCommand(). Referenced by KWin4App::askForHint(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Check whether the field has a game over situation. Called by above standard KGame function but with more suitable parameters.
Definition at line 474 of file kwin4doc.cpp. References getColour(), and Nobody. Here is the call graph for this function: ![]() |
|
|
Check whether the field has a game over situation. KGame stanard function.
Definition at line 464 of file kwin4doc.cpp. References global_debug. |
|
||||||||||||
|
This slot is called by the signal of KGame to indicated that the network connection is done and a new client is connected.
Definition at line 1056 of file kwin4doc.cpp. References global_debug, and signalChatChanged(). Referenced by KWin4Doc(). |
|
||||||||||||
|
Create and add an KGameIO device to an given player. The old ones have to be removed manually before.
Definition at line 919 of file kwin4doc.cpp. References findProcessName(), global_debug, prepareAITurn(), and processAICommand(). Referenced by createPlayer(), and setPlayedBy(). Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Create a player of a given type (here only one type possible) and equip it with a given KGameIO device. Virtual players are remote network players.
Definition at line 843 of file kwin4doc.cpp. References createIO(), and playerPropertyChanged(). Referenced by initPlayers(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Perform a game move. Calls makeMove().
Definition at line 285 of file kwin4doc.cpp. References global_debug, GNormal, and makeMove(). Referenced by playerInput(). Here is the call graph for this function: ![]() |
|
|
End a game. Update statistic and forward end game to view.
Definition at line 219 of file kwin4doc.cpp. References KWin4View::endGame(), getPlayer(), KWin4Player::incBrk(), KWin4Player::incLost(), KWin4Player::incRemis(), KWin4Player::incWin(), Red, TLost, TRemis, TWin, and Yellow. Referenced by KWin4App::EndGame(). Here is the call graph for this function: ![]() |
|
|
Find the name of the AI process executable file.
Definition at line 798 of file kwin4doc.cpp. References global_debug, and SRC_DIR. Referenced by calculateHint(), and createIO(). |
|
||||||||||||
|
Called by KGame when a game property has changed. We update the game status etc.
Definition at line 1196 of file kwin4doc.cpp. Referenced by KWin4Doc(). |
|
||||||||||||
|
Retrieve the colour of a position on the game board.
Definition at line 158 of file kwin4doc.cpp. References FIELD_SIZE_X. Referenced by checkGameOver(), and prepareGameMessage(). |
|
|
Retrieve the current move number.
Definition at line 777 of file kwin4doc.cpp. Referenced by KWin4App::checkMenus(), and prepareGameMessage(). |
|
|
Retrieve the player whose turn it is next.
Definition at line 751 of file kwin4doc.cpp. Referenced by activateCurrentPlayer(), calculateHint(), makeMove(), moveDone(), KWin4App::networkBroken(), nextPlayer(), prepareGameMessage(), redoMove(), KWin4App::redoMove(), repeatMove(), undoMove(), KWin4App::undoMove(), and KWin4App::updateStatusNames(). |
|
|
Retrieve the amount of moves in the undo/redo history.
Definition at line 791 of file kwin4doc.cpp. Referenced by KWin4App::checkMenus(), makeMove(), redoMove(), and undoMove(). |
|
|
Retrieve the maximum move which has been made before undos.
Definition at line 784 of file kwin4doc.cpp. |
|
|
Retrieve the name of the player of the given color.
Definition at line 420 of file kwin4doc.cpp. References getPlayer(). Referenced by KWin4App::showStatistics(), KWin4App::slotGameOver(), and KWin4App::updateStatusNames(). Here is the call graph for this function: ![]() |
|
|
Retrieve the player object for the given player colour.
Definition at line 1107 of file kwin4doc.cpp. Referenced by activateCurrentPlayer(), KWin4App::configureChat(), endGame(), getName(), getStatistic(), moveDone(), KWin4App::networkBroken(), newPlayersJoin(), nextPlayer(), readConfig(), recalcIO(), KWin4App::remoteChanged(), repeatMove(), resetStatistic(), setName(), setPlayedBy(), and writeConfig(). |
|
|
Retrieve the color of the i-th player. Player 0 is the start player and player 1 the follow up player.
Definition at line 451 of file kwin4doc.cpp. Referenced by loadSettings(), and prepareGameMessage(). |
|
||||||||||||
|
Returns the all time statistics for player of given color The mode determins what statistics to access.
Definition at line 428 of file kwin4doc.cpp. References KWin4Player::brk(), getPlayer(), KWin4Player::lost(), KWin4Player::remis(), TBrk, TLost, TRemis, TSum, TWin, and KWin4Player::win(). Referenced by KWin4App::showStatistics(). Here is the call graph for this function: ![]() |
|
|
Initializes the KGame derived players.
Definition at line 131 of file kwin4doc.cpp. References createPlayer(), Prefs::name1(), Red, setPlayedBy(), and Yellow. Referenced by KWin4App::KWin4App(). Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Save the document in the datastrem. This is a KGame function.
Definition at line 1257 of file kwin4doc.cpp. References activateCurrentPlayer(), global_debug, recalcIO(), redoMove(), resetGame(), and undoMove(). Here is the call graph for this function: ![]() |
|
|
Load the game properties from the settings. Either the config file or the config dialog call this. Definition at line 680 of file kwin4doc.cpp. References Prefs::colour1(), getPlayerColour(), Prefs::input1(), Prefs::input2(), Prefs::level(), Prefs::name1(), Prefs::name2(), Red, Score::setLevel(), setName(), setPlayedBy(), switchStartPlayer(), and Yellow. Referenced by readConfig(). |
|
||||||||||||
|
Make a game move to the given position and return a status. Also displays it in the view.
Definition at line 296 of file kwin4doc.cpp. References KWin4View::displayMove(), FIELD_SIZE_X, FIELD_SIZE_Y, getCurrentPlayer(), getHistoryCnt(), GIllMove, GNormal, GNotAllowed, GTip, Nobody, setColour(), and Tip. Referenced by doMove(), and redoMove(). Here is the call graph for this function: ![]() |
|
|
Indication from the view that a move has been displayed. Now The next player can be switched.
Definition at line 252 of file kwin4doc.cpp. References getCurrentPlayer(), and getPlayer(). Referenced by setView(). |
|
||||||||||||||||
|
Debug: Listen to network messages.
Definition at line 836 of file kwin4doc.cpp. Referenced by KWin4Doc(). |
|
||||||||||||||||
|
This is also an overwritten function of KGame. It is called in the game negotiation upon connect. Here the games have to determine what player is remote and what is local.
Definition at line 1306 of file kwin4doc.cpp. References getPlayer(), global_debug, Red, and Yellow. Here is the call graph for this function: ![]() |
|
||||||||||||
|
KGame function to determine the next player. In KWin4 players alternate.
Definition at line 264 of file kwin4doc.cpp. References getCurrentPlayer(), getPlayer(), global_debug, Red, setCurrentPlayer(), signalNextPlayer(), and Yellow. Here is the call graph for this function: ![]() |
|
|
Query the IO mode of player og the given color.
Definition at line 883 of file kwin4doc.cpp. Referenced by KWin4App::networkBroken(), KWin4App::redoMove(), and KWin4App::undoMove(). |
|
||||||||||||
|
Main function to handle player input. This function is the central input for all player inputs. Mouse, Keyboard AI or network end here in the same format. A move is initiated here.
Definition at line 858 of file kwin4doc.cpp. References doMove(), and repeatMove(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Called by KGame when a player property has changed. We check whether the name changed and then update the score widget.
Definition at line 1181 of file kwin4doc.cpp. References global_debug, and Score::setPlayerName(). Referenced by createPlayer(). |
|
||||||||||||||||||||
|
This slot is called by the KGame input device when we should prepare a message to the AI process.
Definition at line 970 of file kwin4doc.cpp. References global_debug, and prepareGameMessage(). Referenced by createIO(). |
|
||||||||||||
|
Pack the current game into a data stream so that it can be send to the computer AI.
Definition at line 997 of file kwin4doc.cpp. References FIELD_SIZE_X, FIELD_SIZE_Y, getColour(), getCurrentMove(), getCurrentPlayer(), getPlayerColour(), global_debug, and Prefs::level(). Referenced by calculateHint(), and prepareAITurn(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
An AI command was received from the computer AI _input device_ process. Process it. Currently this is only the move score value.
Definition at line 1031 of file kwin4doc.cpp. References global_debug, and setScore(). Referenced by createIO(). |
|
||||||||||||
|
An AI command was received from the computer AI _hint_ process. Process it. Currently this is only the hint move.
Definition at line 1147 of file kwin4doc.cpp. References KWin4View::displayHint(), and global_debug. Referenced by calculateHint(). |
|
|
Read the game config from the config file.
Definition at line 724 of file kwin4doc.cpp. References getPlayer(), loadSettings(), KWin4Player::readConfig(), Red, and Yellow. Referenced by KWin4App::KWin4App(). Here is the call graph for this function: ![]() |
|
|
Set the IO devices new.
Definition at line 911 of file kwin4doc.cpp. References getPlayer(), Red, and Yellow. Referenced by loadgame(). Here is the call graph for this function: ![]() |
|
|
Redoes a move if possible.
Definition at line 396 of file kwin4doc.cpp. References getCurrentPlayer(), getHistoryCnt(), makeMove(), Red, setCurrentPlayer(), setScore(), and Yellow. Referenced by loadgame(), and KWin4App::redoMove(). Here is the call graph for this function: ![]() |
|
|
Initiate a repeate of the move. This happens if somehow the player input created an invalid move. The the same player has to input again. Definition at line 876 of file kwin4doc.cpp. References getCurrentPlayer(), and getPlayer(). Referenced by playerInput(). |
|
|
Reset the whole game to the beginning (clear board, . ..)
Definition at line 177 of file kwin4doc.cpp. References FIELD_SIZE_X, FIELD_SIZE_Y, Nobody, and setColour(). Referenced by KWin4Doc(), and loadgame(). Here is the call graph for this function: ![]() |
|
|
Reset all the player stats.
Definition at line 664 of file kwin4doc.cpp. References getPlayer(), Red, KWin4Player::resetStats(), and Yellow. Referenced by KWin4App::showStatistics(). Here is the call graph for this function: ![]() |
|
||||||||||||||||
|
Set the colour of a position on the game board.
Definition at line 165 of file kwin4doc.cpp. References FIELD_SIZE_X, and FIELD_SIZE_Y. Referenced by makeMove(), resetGame(), and undoMove(). |
|
|
Sets the current player.
Definition at line 758 of file kwin4doc.cpp. Referenced by KWin4Doc(), nextPlayer(), redoMove(), and undoMove(). |
|
||||||||||||
|
Set the name of the player of the given color.
Definition at line 413 of file kwin4doc.cpp. References getPlayer(). Referenced by loadSettings(). Here is the call graph for this function: ![]() |
|
||||||||||||
|
Sets the input device mode for the given player color.
Definition at line 890 of file kwin4doc.cpp. References createIO(), getPlayer(), global_debug, Score::setPlayedBy(), and KWin4Player::status(). Referenced by initPlayers(), loadSettings(), and KWin4App::networkBroken(). Here is the call graph for this function: ![]() |
|
|
Set the score value of the AI.
Definition at line 672 of file kwin4doc.cpp. Referenced by processAICommand(), redoMove(), and undoMove(). |
|
|
Adds a view to the document which displays the document contents.
Definition at line 150 of file kwin4doc.cpp. References moveDone(). Referenced by KWin4App::KWin4App(). |
|
|
Emmitted if the chat origin changes.
Referenced by clientConnected(). |
|
|
Emmitted if the game status changes to run.
|
|
|
Emmitted when the next players move is due.
Referenced by nextPlayer(). |
|
|
Swap the start player so that the game is started alternatingly.
Definition at line 765 of file kwin4doc.cpp. Referenced by KWin4App::EndGame(), and loadSettings(). |
|
|
Undoes a move if possible.
Definition at line 349 of file kwin4doc.cpp. References KWin4View::displayMove(), getCurrentPlayer(), getHistoryCnt(), Nobody, Red, setColour(), setCurrentPlayer(), setScore(), and Yellow. Referenced by loadgame(), and KWin4App::undoMove(). Here is the call graph for this function: ![]() |
|
|
Write the game config to the config file.
Definition at line 738 of file kwin4doc.cpp. References getPlayer(), Red, KWin4Player::writeConfig(), and Yellow. Referenced by ~KWin4Doc(). Here is the call graph for this function: ![]() |
1.4.6