tile.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Copyright (C) 2005 Eliot
00003  * Authors: Olivier Teuliere  <ipkiss@via.ecp.fr>
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *****************************************************************************/
00019 
00020 #ifndef _TILE_H_
00021 #define _TILE_H_
00022 
00023 #include <list>
00024 
00025 using namespace std;
00026 
00027 /*************************
00028  * A Tile is the internal representation
00029  * used within the game library to
00030  * handle letters
00031  *************************/
00032 
00033 class Tile
00034 {
00035 public:
00036 
00037   // a lowercase character always a joker
00038   // - this permits to detect joker in already played games
00039   // - we need to pay attention when inserting character taken
00040   //   from user input
00041 
00042     Tile(char c = 0);
00043     virtual ~Tile() {}
00044 
00045     bool isEmpty() const        { return m_dummy; }
00046     bool isJoker() const        { return m_joker; }
00047     bool isVowel() const;
00048     bool isConsonant() const;
00049     unsigned int maxNumber() const;
00050     unsigned int getPoints() const;
00051     char toChar() const;
00052     int toCode() const;
00053 
00054     static const Tile &dummy()  { return m_TheDummy; }
00055     static const Tile &Joker()  { return m_TheJoker; }
00056     static const list<Tile>& getAllTiles();
00057 
00058     bool operator <(const Tile &iOther) const;
00059     bool operator ==(const Tile &iOther) const;
00060     bool operator !=(const Tile &iOther) const;
00061 
00062 private:
00063     char m_char;
00064     bool m_joker;
00065     bool m_dummy;
00066 
00067     // Special tiles are declared static
00068     static const Tile m_TheJoker;
00069     static const Tile m_TheDummy;
00070 
00071     // List of available tiles
00072     static list<Tile> m_tilesList;
00073 };
00074 
00075 #endif
00076 
00077 /// Local Variables:
00078 /// mode: c++
00079 /// mode: hs-minor
00080 /// c-basic-offset: 4
00081 /// indent-tabs-mode: nil
00082 /// End:

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