summaryrefslogtreecommitdiff
path: root/common/tile.cpp
blob: 29e0c84a973bbbbc066979fe72737d8ab1a079fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "tile.h"

#include <algorithm>

Tile::Tile() {
	
}

Tile::Tile(Tile::Type t, bool re, bool ro) : type(t), red(re), rotated(ro){
	
}

int Tile::get_num() const {
	if(type >= Man_1 && type <= Sou_9) {
		return (type - Man_1) % 9 + 1;
	} else {
		return 0;
	}
}

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;
}

void Tiles::sort() {
	std::sort(begin(), end());
}