[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src client/Theme.cpp client/Theme.h comm...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src client/Theme.cpp client/Theme.h comm... |
Date: |
Mon, 17 Mar 2003 11:10:14 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/03/17 11:10:14
Modified files:
src/client : Theme.cpp Theme.h
src/common : Tile.h TileStack.cpp TileStack.h
src/server : CaminoServer.cpp Player.cpp Player.h
Log message:
commit latents sur la gestion du premier joueur
Patches:
Index: camino/src/client/Theme.cpp
diff -u camino/src/client/Theme.cpp:1.10 camino/src/client/Theme.cpp:1.11
--- camino/src/client/Theme.cpp:1.10 Mon Mar 3 15:16:43 2003
+++ camino/src/client/Theme.cpp Mon Mar 17 11:10:12 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Theme.cpp,v 1.10 2003/03/03 20:16:43 Audoux Exp $
+** Version : $Id: Theme.cpp,v 1.11 2003/03/17 16:10:12 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 22/01/2003
@@ -151,10 +151,12 @@
QCanvasPixmapArray * array = getTileArray( num, side );
pixmap = array->image( 0 );
if( pixmap == 0L ) {
- qDebug("Theme::getTilePixmap() - null pixmap");
+ qDebug("Theme::getTilePixmap() - %s (rot = %d) is null",
+ computeTileName(num).latin1(), side );
}
if (pixmap->size() == QSize(0,0) ) {
- qDebug("Theme::getTilePixmap() - null size pixmap");
+ qDebug("Theme::getTilePixmap() - %s (rot = %d) has (0,0) size",
+ computeTileName(num).latin1(), side );
}
return *pixmap;
}
Index: camino/src/client/Theme.h
diff -u camino/src/client/Theme.h:1.9 camino/src/client/Theme.h:1.10
--- camino/src/client/Theme.h:1.9 Mon Mar 3 15:16:43 2003
+++ camino/src/client/Theme.h Mon Mar 17 11:10:14 2003
@@ -5,7 +5,7 @@
** Theme.h
** Manage theme data and pictures
**
-** Version : $Id: Theme.h,v 1.9 2003/03/03 20:16:43 Audoux Exp $
+** Version : $Id: Theme.h,v 1.10 2003/03/17 16:10:14 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 22/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -67,7 +67,6 @@
QCanvasPixmapArray * getTileArray( Tile::TileType num, int side );
void setZoomLevel( int level ) { _level = level; }
- int getZoomLevel() { return _level; }
const QPixmap & getTilePixmap( Tile::TileType num, int side );
Index: camino/src/common/Tile.h
diff -u camino/src/common/Tile.h:1.8 camino/src/common/Tile.h:1.9
--- camino/src/common/Tile.h:1.8 Mon Mar 3 17:13:49 2003
+++ camino/src/common/Tile.h Mon Mar 17 11:10:14 2003
@@ -5,7 +5,7 @@
** Tile.h
** Manage a tile on the board game
**
-** Version : $Id: Tile.h,v 1.8 2003/03/03 22:13:49 pfremy Exp $
+** Version : $Id: Tile.h,v 1.9 2003/03/17 16:10:14 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 16/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -75,11 +75,9 @@
virtual ~Tile();
TileType getType() { return _type; }
-
virtual void setType( TileType type ) { _type = type; }
int getRotation() { return _rotation; }
-
virtual void setRotation( int rotation );
void rotate();
@@ -88,16 +86,13 @@
bool isRotationKnown() { return _isRotationKnown; }
- int getRow() { return _row; }
-
- int getCol() { return _col; }
-
virtual void setPosition( int row, int col );
-
virtual void setRow( int row ) { _row = row; }
-
virtual void setCol( int col ) { _col = col; }
+ int getRow() { return _row; }
+ int getCol() { return _col; }
+ /** Check if the tile is suitable for a first tile in a corner */
bool isBeginningRoad();
protected:
Index: camino/src/common/TileStack.cpp
diff -u camino/src/common/TileStack.cpp:1.5 camino/src/common/TileStack.cpp:1.6
--- camino/src/common/TileStack.cpp:1.5 Thu Feb 27 12:00:02 2003
+++ camino/src/common/TileStack.cpp Mon Mar 17 11:10:14 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: TileStack.cpp,v 1.5 2003/02/27 17:00:02 pfremy Exp $
+** Version : $Id: TileStack.cpp,v 1.6 2003/03/17 16:10:14 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 25/01/2003
@@ -41,7 +41,7 @@
void TileStack::init()
{
- // XXX: could be "theme-defined" in the future
+ // could be "theme-defined" in the future
addTile( Tile::TILE_ROAD_STRAIGHT, 24 );
addTile( Tile::TILE_ROAD_T, 8 );
addTile( Tile::TILE_ROAD_DEADEND, 4 );
Index: camino/src/common/TileStack.h
diff -u camino/src/common/TileStack.h:1.3 camino/src/common/TileStack.h:1.4
--- camino/src/common/TileStack.h:1.3 Sun Mar 2 13:22:27 2003
+++ camino/src/common/TileStack.h Mon Mar 17 11:10:14 2003
@@ -5,7 +5,7 @@
** TileStack.h
** Manage the stack of tiles of a game
**
-** Version : $Id: TileStack.h,v 1.3 2003/03/02 18:22:27 pfremy Exp $
+** Version : $Id: TileStack.h,v 1.4 2003/03/17 16:10:14 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 25/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -53,6 +53,7 @@
/** Create a tile stack with the right number of standard tiles */
void init();
+ void addTile( Tile::TileType type, uint num=1 );
void reinit();
@@ -62,7 +63,6 @@
bool hasTileLeft() { return _stack.isEmpty() == false; }
protected:
- void addTile( Tile::TileType type, uint num );
QPtrList<Tile> _stack;
};
Index: camino/src/server/CaminoServer.cpp
diff -u camino/src/server/CaminoServer.cpp:1.20
camino/src/server/CaminoServer.cpp:1.21
--- camino/src/server/CaminoServer.cpp:1.20 Sat Mar 8 17:40:38 2003
+++ camino/src/server/CaminoServer.cpp Mon Mar 17 11:10:14 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: CaminoServer.cpp,v 1.20 2003/03/08 22:40:38 Audoux Exp $
+** Version : $Id: CaminoServer.cpp,v 1.21 2003/03/17 16:10:14 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 19/01/2003
@@ -176,22 +176,23 @@
void CaminoServer::distributeTiles()
{
qDebug( "CaminoServer::distributeTiles() " );
- int tilesPerPlayer = 0;
+ QPtrListIterator<Player> it( _playerList );
+ it.current()->distributeInitialTiles( true );
+ ++it;
+ it.current()->distributeInitialTiles( true );
+ ++it;
+ while( it.current() ) {
+ it.current()->distributeInitialTiles( false );
+ ++it;
+ }
+ int tilesPerPlayer = 0;
if ( _playerNb == 2 ) {
tilesPerPlayer = Camino::nbTiles2players;
} else {
tilesPerPlayer = Camino::nbTiles4players;
}
- for ( int i=0; i < tilesPerPlayer; i++ ) {
- QPtrListIterator<Player> it( _playerList );
- while( it.current() ) {
- it.current()->_tileList.append( _tileStack->pickTile()
);
- ++it;
- }
- }
- // check that every player can play with its tiles
sendDistributedTiles();
}
Index: camino/src/server/Player.cpp
diff -u camino/src/server/Player.cpp:1.17 camino/src/server/Player.cpp:1.18
--- camino/src/server/Player.cpp:1.17 Sun Mar 9 10:12:17 2003
+++ camino/src/server/Player.cpp Mon Mar 17 11:10:14 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Player.cpp,v 1.17 2003/03/09 15:12:17 Audoux Exp $
+** Version : $Id: Player.cpp,v 1.18 2003/03/17 16:10:14 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -30,6 +30,7 @@
// application specific include files
#include "server/CaminoServer.h"
#include "common/TileStack.h"
+#include "common/const.h"
/** add comments here */
@@ -164,6 +165,55 @@
sendTilesForYou( tile->getType() );
}
+void Player::distributeInitialTiles( bool firstPlayer )
+{
+ int tilesPerPlayer = 0;
+ if ( _server->_playerNb == 2 ) {
+ tilesPerPlayer = Camino::nbTiles2players;
+ } else {
+ tilesPerPlayer = Camino::nbTiles4players;
+ }
+
+ for ( int i=0; i < tilesPerPlayer; i++ ) {
+ _tileList.append( _server->_tileStack->pickTile() );
+ }
+
+ if (firstPlayer == false ) {
+ return;
+ }
+
+ Tile * curTile;
+ while( canBegin() == false ) {
+ qDebug( "Player::distributeInitialTiles - redistributing
tiles");
+ // put all tiles back into the stack
+ QPtrListIterator<Tile> tileIt( _tileList );
+ for( ; tileIt.current(); ++tileIt ) {
+ curTile = tileIt.current();
+ _server->_tileStack->addTile( curTile->getType() );
+ _tileList.remove( curTile );
+ }
+
+ // distribute tiles again
+ for ( int i=0; i < tilesPerPlayer; i++ ) {
+ _tileList.append( _server->_tileStack->pickTile() );
+ }
+ }
+
+}
+
+bool Player::canBegin()
+{
+ Tile * curTile;
+ QPtrListIterator<Tile> tileIt( _tileList );
+ for( ; tileIt.current(); ++tileIt ) {
+ curTile = tileIt.current();
+ if (curTile->isBeginningRoad() == true) {
+ return true;
+ }
+ }
+ return false;
+}
+
void Player::recvUndoRequest()
{
_server->undoRequested( this );
@@ -178,6 +228,5 @@
{
_server->undoRejected();
}
-
Index: camino/src/server/Player.h
diff -u camino/src/server/Player.h:1.12 camino/src/server/Player.h:1.13
--- camino/src/server/Player.h:1.12 Sun Mar 9 10:12:17 2003
+++ camino/src/server/Player.h Mon Mar 17 11:10:14 2003
@@ -5,7 +5,7 @@
** Player.h
** this is a template for all .h files
**
-** Version : $Id: Player.h,v 1.12 2003/03/09 15:12:17 Audoux Exp $
+** Version : $Id: Player.h,v 1.13 2003/03/17 16:10:14 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -58,7 +58,9 @@
const QString & getPlayerName() { return _playerName; }
void removeTile( Tile * tile );
+ void distributeInitialTiles( bool firstPlayer );
void distributeAndSendOneTile();
+ bool canBegin();
bool isUndoAccepted() { return _undo; }
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Camino-devel] camino/src client/Theme.cpp client/Theme.h comm...,
Philippe Fremy <=