summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/tile.cpp17
-rw-r--r--common/tile.h9
2 files changed, 26 insertions, 0 deletions
diff --git a/common/tile.cpp b/common/tile.cpp
index 1b3dcd7..15d0d9d 100644
--- a/common/tile.cpp
+++ b/common/tile.cpp
@@ -7,3 +7,20 @@ Tile::Tile() {
Tile::Tile(Tile::Type t, bool re, bool ro) : type(t), red(re), rotated(ro){
}
+
+int Tile::get_num() {
+ if(type >= Man_1 && type <= Sou_9) {
+ return (type - Man_1) % 9 + 1;
+ } else {
+ return 0;
+ }
+}
+
+bool Tile::operator==(const Tile& other) {
+ return type == other.type;
+}
+
+Tile Tile::operator++(int) {
+ type = Type(type + 1);
+ return *this;
+} \ No newline at end of file
diff --git a/common/tile.h b/common/tile.h
index 6f83632..93bdb8d 100644
--- a/common/tile.h
+++ b/common/tile.h
@@ -59,6 +59,15 @@ class Tile {
virtual ~Tile(){};
+ //! Get the numeric value of the tile (if one of the man/pin/sou-sets).
+ int get_num();
+
+ //! Compare two tiles. Equal if type matches; flags are not compared.
+ bool operator==(const Tile& other);
+
+ //! Increment type. Useful for iterating over all possible types.
+ Tile operator++(int);
+
template<class Archive>
void serialize(Archive & ar, const unsigned int version) {
ar & type;