24 |
|
|
25 |
#include <list> |
#include <list> |
26 |
|
|
|
using namespace std; |
|
|
|
|
27 |
/************************* |
/************************* |
28 |
* A Tile is the internal representation |
* A Tile is the internal representation |
29 |
* used within the game library to |
* used within the game library to |
32 |
|
|
33 |
class Tile |
class Tile |
34 |
{ |
{ |
35 |
public: |
public: |
|
|
|
|
// a lowercase character always a joker |
|
|
// - this permits to detect joker in already played games |
|
|
// - we need to pay attention when inserting character taken |
|
|
// from user input |
|
36 |
|
|
37 |
|
// a lowercase character always a joker |
38 |
|
// - this permits to detect joker in already played games |
39 |
|
// - we need to pay attention when inserting character taken |
40 |
|
// from user input |
41 |
|
|
42 |
Tile(char c = 0); |
Tile(char c = 0); |
43 |
virtual ~Tile() {} |
virtual ~Tile() {} |
44 |
|
|
45 |
bool isEmpty() const { return m_dummy; } |
bool isEmpty() const { return m_dummy; } |
46 |
bool isJoker() const { return m_joker; } |
bool isJoker() const { return m_joker; } |
47 |
bool isVowel() const; |
bool isVowel() const; |
48 |
bool isConsonant() const; |
bool isConsonant() const; |
49 |
|
|
50 |
unsigned int maxNumber() const; |
unsigned int maxNumber() const; |
51 |
unsigned int getPoints() const; |
unsigned int getPoints() const; |
52 |
|
|
53 |
char toChar() const; |
char toChar() const; |
54 |
int toCode() const; |
int toCode() const; |
55 |
|
|
56 |
static const Tile &dummy() { return m_TheDummy; } |
static const Tile& dummy() { return m_TheDummy; } |
57 |
static const Tile &Joker() { return m_TheJoker; } |
static const Tile& Joker() { return m_TheJoker; } |
58 |
static const list<Tile>& getAllTiles(); |
static const std::list<Tile>& getAllTiles(); |
59 |
|
|
60 |
bool operator <(const Tile &iOther) const; |
bool operator <(const Tile &iOther) const; |
61 |
bool operator ==(const Tile &iOther) const; |
bool operator ==(const Tile &iOther) const; |
62 |
bool operator !=(const Tile &iOther) const; |
bool operator !=(const Tile &iOther) const; |
63 |
|
|
64 |
private: |
private: |
65 |
char m_char; |
char m_char; |
66 |
bool m_joker; |
bool m_joker; |
67 |
bool m_dummy; |
bool m_dummy; |
68 |
|
|
69 |
// Special tiles are declared static |
// Special tiles are declared static |
70 |
static const Tile m_TheJoker; |
static const Tile m_TheJoker; |
71 |
static const Tile m_TheDummy; |
static const Tile m_TheDummy; |
72 |
|
|
73 |
// List of available tiles |
// List of available tiles |
74 |
static list<Tile> m_tilesList; |
static std::list<Tile> m_tilesList; |
75 |
}; |
}; |
76 |
|
|
77 |
#endif |
#endif |
78 |
|
|
79 |
|
|
80 |
|
/// Local Variables: |
81 |
|
/// mode: hs-minor |
82 |
|
/// c-basic-offset: 4 |
83 |
|
/// End: |