camino-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Camino-devel] camino/src/common Board.h Board.cpp


From: Pascal Audoux
Subject: [Camino-devel] camino/src/common Board.h Board.cpp
Date: Tue, 18 Feb 2003 17:15:12 -0500

CVSROOT:        /cvsroot/camino
Module name:    camino
Changes by:     Pascal Audoux <address@hidden>  03/02/18 17:15:12

Modified files:
        src/common     : Board.h Board.cpp 

Log message:
        add methods for managing 'undo'

Patches:
Index: camino/src/common/Board.cpp
diff -u camino/src/common/Board.cpp:1.4 camino/src/common/Board.cpp:1.5
--- camino/src/common/Board.cpp:1.4     Tue Jan 28 16:54:27 2003
+++ camino/src/common/Board.cpp Tue Feb 18 17:15:12 2003
@@ -2,7 +2,7 @@
 **
 ** Camino
 **
-** Version : $Id: Board.cpp,v 1.4 2003/01/28 21:54:27 pfremy Exp $
+** Version : $Id: Board.cpp,v 1.5 2003/02/18 22:15:12 Audoux Exp $
 **
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 16/01/2003
@@ -34,6 +34,12 @@
 Board::Board()
 {
        init();
+       _moves.setAutoDelete( false );
+}
+
+Board::~Board()
+{
+
 }
 
 void Board::clear()
@@ -81,6 +87,7 @@
        if( isPossible( row, col, tile ) ) {
                tile->setRotation( computeRotation( row, col, tile ) );
                _tiles[row][col] = tile;
+               _moves.push( tile );
        } else {
                ret = false;
        }
@@ -136,6 +143,21 @@
 int Board::computeRotation( int /* row */, int /* col */, Tile * /* tile */ )
 {
        int ret = 0;
+
+       return ret;
+}
+
+Tile * Board::getLastPlayedTile()
+{
+       Tile * ret = _moves.current();
+
+       return ret;
+}
+
+Tile * Board::removeLastPlayedTile()
+{
+       Tile * ret = _moves.current();
+       _moves.remove();
 
        return ret;
 }
Index: camino/src/common/Board.h
diff -u camino/src/common/Board.h:1.3 camino/src/common/Board.h:1.4
--- camino/src/common/Board.h:1.3       Sun Jan 26 04:50:00 2003
+++ camino/src/common/Board.h   Tue Feb 18 17:15:12 2003
@@ -5,7 +5,7 @@
 ** Board.h
 ** Handles the game's board
 **
-** Version : $Id: Board.h,v 1.3 2003/01/26 09:50:00 Audoux Exp $
+** Version : $Id: Board.h,v 1.4 2003/02/18 22:15:12 Audoux Exp $
 ** Author(s) : Philippe Fremy, Pascal Audoux
 ** Creation : 16/01/2003
 ** Copyright: Pascal Audoux, Philippe Fremy 2003
@@ -30,6 +30,7 @@
 
 // generic include files
 // include files for QT
+#include <qptrstack.h>
 // application specific include files
 
 class Tile;
@@ -48,6 +49,9 @@
        /** Constructor */
        Board();
 
+       /** destructor */
+       virtual ~Board();
+
        void clear();
 
        void init();
@@ -61,10 +65,15 @@
        bool isPossible( int row, int col, Tile  * tile );
 
        int computeRotation( int row, int col, Tile * tile );
+
+       Tile * getLastPlayedTile();
+
+       Tile * removeLastPlayedTile();
 protected:
        bool hasNeighbour( int row, int col );
-       
+
        Tile * _tiles[10][14];
+       QPtrStack<Tile> _moves;
 };
 
 #endif // BOARD_H




reply via email to

[Prev in Thread] Current Thread [Next in Thread]