blob: 4b7e3ef2507ff908efbde0669c938a3fe835d444 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "tile.h"
#include <algorithm>
Tile::Tile(Tile::Type t, bool re) : type(t), red(re), rotated(false), invisible(false) {
}
Tile::Tile(Set s, int num, bool re) : red(re), rotated(false), invisible(false) {
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;
} else {
return 0;
}
}
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;
}
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;
}
|