[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src/client Game.h Game.cpp
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src/client Game.h Game.cpp |
Date: |
Thu, 27 Feb 2003 14:34:08 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/02/27 14:34:08
Modified files:
src/client : Game.h Game.cpp
Log message:
- client detects activation
- client can send tiles
Patches:
Index: camino/src/client/Game.cpp
diff -u camino/src/client/Game.cpp:1.20 camino/src/client/Game.cpp:1.21
--- camino/src/client/Game.cpp:1.20 Thu Feb 27 12:54:22 2003
+++ camino/src/client/Game.cpp Thu Feb 27 14:34:07 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Game.cpp,v 1.20 2003/02/27 17:54:22 pfremy Exp $
+** Version : $Id: Game.cpp,v 1.21 2003/02/27 19:34:07 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
@@ -71,7 +71,7 @@
_actions = new ActionList( hbox );
_chat = new ChatWidget( vbox );
- connect( _chat, SIGNAL( sig_message( const QString & ) ), SLOT(
slot_chatMessage( const QString & ) ) );
+ connect( _chat, SIGNAL( sig_chatMessage( const QString & ) ), SLOT(
slot_chatMessage( const QString & ) ) );
connect( this, SIGNAL( sig_connected( bool ) ), SLOT(
slot_clientConnected( bool ) ) );
connect( _actions, SIGNAL( sig_play() ), SLOT( slot_play() ) );
@@ -112,14 +112,14 @@
void Game::slot_chatMessage( const QString & msg )
{
- if( isConnected() ) {
- sendMessage( ChatMsg, msg );
- } else {
- _chat->newMessage( "(Not connected) : " + msg );
- }
+ if( isConnected() ) {
+ sendMessage( ChatMsg, msg );
+ } else {
+ _chat->newMessage( "(Not connected) : " + msg );
+ }
}
-void Game::displayServerMessage( const QString & msg )
+void Game::displayServerMsg( const QString & msg )
{
_chat->newMessage( msg );
}
@@ -144,29 +144,6 @@
}
-void Game::slot_tileClickedInBoard( int row, int col )
-{
- qDebug("Game::tileClickedInBoard - %dx%d", row, col );
- // check if we have one tile selected in tile presentation
- if (_presentation->getSelected() == 0L) {
- return;
- }
-
- // check if it is our turn to play: check state
- if (_playerActive == false) {
- return;
- }
-
- // check if there is no tile at this place: ask board to do that
- // check if the rule allow to play here: ask board to do that
-
- // if all the check pass, send the tile to the server
- sendPlayerPlaysAMove( _presentation->getSelected() );
-
- // if the server accepts the move, he will send us a message to add the
- // tile to the board.
-}
-
void Game::slot_clientConnected( bool state )
{
if (state) {
@@ -213,8 +190,7 @@
qDebug( "Client - %s from %s : %s", typeString.latin1(),
source.latin1(), msg.latin1() );
QString text = source + " : " + msg;
- //emit sig_message( text );
- displayServerMessage( text );
+ displayServerMsg( text );
}
void Game::sendMessage( NetMsgSubtype msgLevel, const QString & msg )
@@ -251,3 +227,38 @@
{
sendUndo();
}
+
+void Game::recvActivePlayer( QString playerName )
+{
+ if (_playerName == playerName) {
+ qDebug("Game::recvActivePlayer - player activated");
+ _playerActive = true;
+ // do something
+ }
+ displayServerMsg( playerName + " is now the active player" );
+}
+
+void Game::slot_tileClickedInBoard( int row, int col )
+{
+ qDebug("Game::tileClickedInBoard - %dx%d", row, col );
+ // check if we have one tile selected in tile presentation
+ if (_presentation->getSelected() == 0L) {
+ return;
+ }
+
+ // check if it is our turn to play: check state
+ if (_playerActive == false) {
+ return;
+ }
+
+ // check if there is no tile at this place: ask board to do that
+ // check if the rule allow to play here: ask board to do that
+
+ // if all the check pass, send the tile to the server
+ qDebug("Game::tileClickedInBoard - sending to server" );
+ sendPlayerPlaysAMove( _presentation->getSelected() );
+
+ // if the server accepts the move, he will send us a message to add the
+ // tile to the board.
+}
+
Index: camino/src/client/Game.h
diff -u camino/src/client/Game.h:1.15 camino/src/client/Game.h:1.16
--- camino/src/client/Game.h:1.15 Thu Feb 27 11:59:13 2003
+++ camino/src/client/Game.h Thu Feb 27 14:34:07 2003
@@ -5,7 +5,7 @@
** Game.h
** Main widget of the game
**
-** Version : $Id: Game.h,v 1.15 2003/02/27 16:59:13 pfremy Exp $
+** Version : $Id: Game.h,v 1.16 2003/02/27 19:34:07 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 15/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -60,7 +60,7 @@
bool isConnected();
void reupdate();
- void displayServerMessage( const QString & msg );
+ void displayServerMsg( const QString & msg );
void addTile( Tile * tile );
// send messages to server
@@ -87,16 +87,15 @@
void slotConnectionClosed();
void slotDecode();
+protected:
+ virtual void recvMsg( QString source, QString msg );
+ virtual void recvTilesForYou( Tile::TileType tile );
+ virtual void recvActivePlayer( QString playerName );
+
signals:
void sig_connected( bool );
- void sig_message( const QString & msg );
- void sig_recvTile( Tile::TileType type );
-
protected:
- void recvMsg( QString source, QString msg );
- void recvTilesForYou( Tile::TileType tile );
-
ActionList * _actions;
TilePresentation * _presentation;
BoardCanvas * _board;