round.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 #ifndef _ROUND_H_
00022 #define _ROUND_H_
00023 
00024 #include <vector>
00025 #include "tile.h"
00026 #include "coord.h"
00027 
00028 using namespace std;
00029 
00030 
00031 /**
00032  * A Round is the representation of a played word (or going to be played).
00033  * It contains the word itself, of course, but also information of position
00034  * on the board, origin of letters (board for a letter already placed, rack
00035  * for a letter just being played), points, etc...
00036  */
00037 class Round
00038 {
00039 public:
00040 
00041     /*************************
00042      *
00043      *************************/
00044     Round();
00045     virtual ~Round() {}
00046     void init();
00047 
00048     /*************************
00049      *
00050      *************************/
00051     void addRightFromBoard(Tile);
00052     void removeRightToBoard(Tile);
00053     void addRightFromRack(Tile, bool);
00054     void removeRightToRack(Tile, bool);
00055 
00056     /*************************
00057      * General setters
00058      *************************/
00059     void setPoints(int iPoints)    { m_points = iPoints; }
00060     void setBonus(bool iBonus)     { m_bonus = iBonus; }
00061     void setTile(int iIndex, const Tile &iTile) { m_word[iIndex] = iTile; }
00062     void setWord(const vector<Tile> &iTiles);
00063     void setFromRack(int iIndex);
00064     void setFromBoard(int iIndex);
00065     void setJoker(int iIndex, bool value = true);
00066 
00067     /*************************
00068      * General getters
00069      *************************/
00070     bool isJoker         (int iIndex) const;
00071     bool isPlayedFromRack(int iIndex) const;
00072     const Tile& getTile  (int iIndex) const;
00073     
00074     string getWord() const;
00075     int getWordLen() const;
00076     int getPoints()  const        { return m_points; }
00077     int getBonus()   const        { return m_bonus; }
00078 
00079     /*************************
00080      * Coordinates
00081      *************************/
00082     const Coord& getCoord() const { return m_coord; }
00083     Coord& accessCoord()          { return m_coord; }
00084 
00085     string toString() const;
00086 
00087 private:
00088     vector<Tile> m_word;
00089     vector<char> m_tileOrigin;
00090     Coord m_coord;
00091     int m_points;
00092     int m_bonus;
00093 };
00094 
00095 #endif
00096 
00097 /// Local Variables:
00098 /// mode: c++
00099 /// mode: hs-minor
00100 /// c-basic-offset: 4
00101 /// indent-tabs-mode: nil
00102 /// End:

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