diff options
Diffstat (limited to 'common/tile.cpp')
-rw-r--r-- | common/tile.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/common/tile.cpp b/common/tile.cpp index 15d0d9d..29e0c84 100644 --- a/common/tile.cpp +++ b/common/tile.cpp @@ -1,5 +1,7 @@ #include "tile.h" +#include <algorithm> + Tile::Tile() { } @@ -8,7 +10,7 @@ Tile::Tile(Tile::Type t, bool re, bool ro) : type(t), red(re), rotated(ro){ } -int Tile::get_num() { +int Tile::get_num() const { if(type >= Man_1 && type <= Sou_9) { return (type - Man_1) % 9 + 1; } else { @@ -16,11 +18,19 @@ int Tile::get_num() { } } -bool Tile::operator==(const Tile& other) { +bool Tile::operator==(const Tile& other) const { return type == other.type; } +bool Tile::operator<(const Tile& other) const { + return type == other.type ? red : type < other.type; +} + Tile Tile::operator++(int) { type = Type(type + 1); return *this; -}
\ No newline at end of file +} + +void Tiles::sort() { + std::sort(begin(), end()); +} |