[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Camino-devel] camino/src common/TileStack.h server/Player.cpp...
From: |
Philippe Fremy |
Subject: |
[Camino-devel] camino/src common/TileStack.h server/Player.cpp... |
Date: |
Sun, 02 Mar 2003 13:22:27 -0500 |
CVSROOT: /cvsroot/camino
Module name: camino
Changes by: Philippe Fremy <address@hidden> 03/03/02 13:22:27
Modified files:
src/common : TileStack.h
src/server : Player.cpp Player.h
Log message:
handle tiles add/removal on the server side
Patches:
Index: camino/src/common/TileStack.h
diff -u camino/src/common/TileStack.h:1.2 camino/src/common/TileStack.h:1.3
--- camino/src/common/TileStack.h:1.2 Mon Feb 17 19:11:50 2003
+++ camino/src/common/TileStack.h Sun Mar 2 13:22:27 2003
@@ -5,7 +5,7 @@
** TileStack.h
** Manage the stack of tiles of a game
**
-** Version : $Id: TileStack.h,v 1.2 2003/02/18 00:11:50 pfremy Exp $
+** Version : $Id: TileStack.h,v 1.3 2003/03/02 18:22:27 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 25/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -58,6 +58,8 @@
/** Randomly picks a card in the stack and returns it */
Tile * pickTile();
+
+ bool hasTileLeft() { return _stack.isEmpty() == false; }
protected:
void addTile( Tile::TileType type, uint num );
Index: camino/src/server/Player.cpp
diff -u camino/src/server/Player.cpp:1.14 camino/src/server/Player.cpp:1.15
--- camino/src/server/Player.cpp:1.14 Sun Mar 2 12:07:19 2003
+++ camino/src/server/Player.cpp Sun Mar 2 13:22:27 2003
@@ -2,7 +2,7 @@
**
** Camino
**
-** Version : $Id: Player.cpp,v 1.14 2003/03/02 17:07:19 pfremy Exp $
+** Version : $Id: Player.cpp,v 1.15 2003/03/02 18:22:27 pfremy Exp $
**
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
@@ -29,6 +29,7 @@
#include <qsocket.h>
// application specific include files
#include "server/CaminoServer.h"
+#include "common/TileStack.h"
/** add comments here */
@@ -95,6 +96,7 @@
}
/*
+ // use that if you want to test move rejection.
static bool rejectsMove = true;
rejectsMove = ! rejectsMove;
@@ -105,8 +107,37 @@
// check that the move is valid
// remove tile from player set
+
_server->updateBoard( tile );
- // distribute new tile to previous player
+
+ if ( _server->_tileStack->hasTileLeft() ) {
+ distributeAndSendOneTile();
+ } else {
+ // continue until no player has tile
+ // then finish the game
+ }
+
// activate new player
_server->activateNextPlayer();
+}
+
+void Player::removeTile( Tile * tile )
+{
+ Tile * curTile;
+ QPtrListIterator<Tile> tileIt( _tileList );
+ for( ; tileIt.current(); ++tileIt ) {
+ curTile = tileIt.current();
+ if (curTile->getType() == tile->getType() ) {
+ _tileList.remove( curTile );
+ return;
+ }
+ }
+ qDebug("Player::removeTile - Could not remove tile %d", tile->getType()
);
+}
+
+void Player::distributeAndSendOneTile()
+{
+ Tile * tile = _server->_tileStack->pickTile();
+ _tileList.append( tile );
+ sendTilesForYou( tile->getType() );
}
Index: camino/src/server/Player.h
diff -u camino/src/server/Player.h:1.9 camino/src/server/Player.h:1.10
--- camino/src/server/Player.h:1.9 Thu Feb 27 16:44:56 2003
+++ camino/src/server/Player.h Sun Mar 2 13:22:27 2003
@@ -5,7 +5,7 @@
** Player.h
** this is a template for all .h files
**
-** Version : $Id: Player.h,v 1.9 2003/02/27 21:44:56 pfremy Exp $
+** Version : $Id: Player.h,v 1.10 2003/03/02 18:22:27 pfremy Exp $
** Author(s) : Philippe Fremy, Pascal Audoux
** Creation : 14/01/2003
** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -57,12 +57,15 @@
void setPlayerName( QString & playerName ) { _playerName = playerName; }
const QString & getPlayerName() { return _playerName; }
+ void removeTile( Tile * tile );
+ void distributeAndSendOneTile();
+
+protected:
virtual void recvPlayerInfo( QString playerName );
virtual void recvMsg( QString source, QString msg );
virtual void recvPlayerPlaysAMove( Tile * tile );
-
-public slots:
+protected slots:
virtual void slotDecode();
protected:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Camino-devel] camino/src common/TileStack.h server/Player.cpp...,
Philippe Fremy <=