diff options
Diffstat (limited to 'common/tile.cpp')
-rw-r--r-- | common/tile.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/common/tile.cpp b/common/tile.cpp index 29e0c84..5a05548 100644 --- a/common/tile.cpp +++ b/common/tile.cpp @@ -6,10 +6,27 @@ Tile::Tile() { } -Tile::Tile(Tile::Type t, bool re, bool ro) : type(t), red(re), rotated(ro){ +Tile::Tile(Tile::Type t, bool re, bool ro) : type(t), red(re), rotated(ro) { } +Tile::Tile(Set s, int num, bool re, bool ro) : red(re), rotated(ro) { + switch(s) { + case Man: + type = Type(Man_1 + num - 1); + break; + case Pin: + type = Type(Pin_1 + num - 1); + break; + case Sou: + type = Type(Sou_1 + num - 1); + break; + default: + // Invalid. + break; + } +} + int Tile::get_num() const { if(type >= Man_1 && type <= Sou_9) { return (type - Man_1) % 9 + 1; @@ -18,6 +35,18 @@ int Tile::get_num() const { } } +Tile::Set Tile::get_set() const { + if(type >= Man_1 && type <= Man_9) { + return Man; + } else if(type >= Pin_1 && type <= Pin_9) { + return Pin; + } else if(type >= Sou_1 && type <= Sou_9) { + return Sou; + } else { + return Honor; + } +} + bool Tile::operator==(const Tile& other) const { return type == other.type; } |