pldrack.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 1999-2005 Eliot
00003  * Authors: Antoine Fraboulet <antoine.fraboulet@free.fr>
00004  *          Olivier Teuliere  <ipkiss@via.ecp.fr>
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 as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019  *****************************************************************************/
00020 
00021 /**
00022  *  \file   pldrack.h
00023  *  \brief  Improved Rack class with old and new tiles
00024  *  \author Antoine Fraboulet & Olivier Teuliere
00025  *  \date   2002 - 2005
00026  */
00027 
00028 #ifndef _PLAYEDRACK_H_
00029 #define _PLAYEDRACK_H_
00030 
00031 #include <vector>
00032 #include <string>
00033 #include "tile.h"
00034 
00035 class Rack;
00036 
00037 using namespace std;
00038 
00039 
00040 /**
00041  * A Playedrack is an "improved" rack, allowing to differentiate new letters
00042  * from letters that are left from the previous rack.
00043  * This is useful, to be able to write a rack on the form ABC+DEFG, where
00044  * A, B, C are the "old" letters and D, E, F, G are the "new" ones.
00045  */
00046 class PlayedRack
00047 {
00048 public:
00049     PlayedRack();
00050     virtual ~PlayedRack() {}
00051 
00052     void reset();
00053     void resetNew();
00054 
00055     void getOld(Rack &oRack) const;
00056     void getNew(Rack &oRack) const;
00057     void getRack(Rack &oRack) const;
00058 
00059     void setOld(const Rack &iRack);
00060     void setNew(const Rack &iRack);
00061 
00062     int nTiles() const  { return nNew() + nOld(); }
00063     int nNew() const    { return m_newTiles.size(); }
00064     int nOld() const    { return m_oldTiles.size(); }
00065 
00066     void addNew(const Tile &t);
00067     void addOld(const Tile &t);
00068     void getNewTiles(vector<Tile> &oTiles) const;
00069     void getOldTiles(vector<Tile> &oTiles) const;
00070     void getAllTiles(vector<Tile> &oTiles) const;
00071 
00072     bool checkRack(int iMin) const;
00073 
00074     void operator=(const PlayedRack &iOther);
00075 
00076     typedef enum {
00077       RACK_SIMPLE,
00078       RACK_EXTRA,
00079       RACK_DEBUG
00080     } display_mode;
00081     string toString(display_mode iShowExtraSigns = RACK_EXTRA) const;
00082 
00083 private:
00084     bool reject;
00085     vector<Tile> m_oldTiles;
00086     vector<Tile> m_newTiles;
00087 };
00088 
00089 #endif
00090 
00091 /// Local Variables:
00092 /// mode: c++
00093 /// mode: hs-minor
00094 /// c-basic-offset: 4
00095 /// indent-tabs-mode: nil
00096 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5