Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

movements.h

00001 /*
00002  *   EasySok --- A(nother) sokoban game for KDE.
00003  *
00004  *   Copyright (C) 2001 by Ralf Schmelter (ralfs@pc2a.chemie.uni-dortmund.de).
00005  *
00006  *   This program is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License version 2 as
00008  *   published by the Free Software Foundation.
00009  *
00010  *   This program is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with this program; if not, write to the Free Software
00017  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  */
00019 
00020 
00021 #ifndef EASYSOK_MOVEMENTS_INC_GUARD_H
00022 #define EASYSOK_MOVEMENTS_INC_GUARD_H
00023 
00024 
00025 #include <vector>
00026 
00027 #include <qpoint.h>
00028 #include <qregexp.h>
00029 
00030 #include "move.h"
00031 
00032 
00033 class QDataStream;
00034 class QStringList;
00035 
00036 
00037 
00038 
00049 class Movements
00050 {
00051 
00052 public:
00053 
00058     Movements();
00059 
00060 
00069     Movements(std::vector<Move> const & moves);
00070 
00071 
00080     Movements(QDataStream & stream);
00081 
00082 
00092     Movements(QPoint keeper_start, QStringList & lines);
00093 
00094 
00099     bool isEmpty() const;
00100 
00101 
00106     int numberOfMoves() const;
00107 
00108 
00115     void setToFirstPosition();
00116 
00117 
00124     void setToLastPosition();
00125 
00126 
00131     bool hasNextMove() const;
00132 
00133 
00139     Move peekNextMove() const;
00140 
00141 
00148     Move nextMove();
00149 
00150 
00155     bool hasPrevMove() const;
00156 
00157 
00163     Move peekPrevMove() const;
00164 
00165 
00172     Move prevMove();
00173 
00174 
00181     Move const & move(int index) const;
00182 
00183 
00194     void addMove(Move const & move);
00195 
00196 
00205     void addMovements(Movements const & moves);
00206 
00207 
00214     void truncateToCurrent();
00215 
00216 
00221     int movePointer() const;
00222 
00223 
00232     void setMovePointer(int move_pointer);
00233 
00234 
00244     void reverse();
00245 
00246 
00259     Movements gemMovesToKeeperMoves(QPoint const & keeper, bool retro_mode = false) const;
00260 
00261 
00268     QString toText() const;
00269 
00270 
00277     void writeToStream(QDataStream & stream) const;
00278 
00279 
00284     int moves() const;
00285 
00286 
00291     int pushes() const;
00292 
00293 
00298     int linearPushes() const;
00299 
00300 
00305     int gemChanges() const;
00306 
00307 
00312     bool operator == (Movements const & other_moves) const;
00313 
00314 
00319     bool operator != (Movements const & other_moves) const;
00320 
00321 
00322 private:
00323 
00328     std::vector<Move> m_moves;
00329 
00330 
00335     size_t m_pos;
00336 
00337 
00342     static QRegExp s_moves_regexp;
00343 };
00344 
00345 
00346 #endif

Generated at Sun Jan 6 18:49:09 2002 for EasySok by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001