-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmjcard.cpp
More file actions
76 lines (72 loc) · 1.26 KB
/
mjcard.cpp
File metadata and controls
76 lines (72 loc) · 1.26 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* @file mjcard.cpp
* @author YangSongxi
* @mail ysx-cpp@gmail.com
* @github https://github.com/ysx-cpp
* @date Oct 08 2020
*/
#include "mjcard.h"
namespace algorithm {
int MjCard::index() const
{
return index_;
}
int MjCard::type() const
{
return type_;
}
int MjCard::face() const
{
return face_;
}
int MjCard::color() const
{
return 0;
}
bool MjCard::empty() const
{
return false;
}
std::string MjCard::name() const
{
std::string name(std::to_string(face_));
switch (type_)
{
case MjCard::E_MYRIAD_TYPE:
name.append("万");
break;
// case MjCard::E_CYLINDER_TYPE:
// name.append("筒");
// break;
// case MjCard::E_SLIVER_TYPE:
// name.append("条");
// break;
case MjCard::E_WIND_TYPE:
{
if (face_ == E_FACE_ONE)
name = "东";
else if (face_ == E_FACE_TWO)
name = "南";
else if (face_ == E_FACE_THREE)
name = "西";
else if (face_ == E_FACE_FOUR)
name = "北";
}
break;
case MjCard::E_WORD_TYPE:
{
if (face_ == E_FACE_ONE)
name = "中";
else if (face_ == E_FACE_TWO)
name = "发";
else if (face_ == E_FACE_THREE)
name = "白";
}
break;
default:
break;
}
name.append(std::to_string(index_));
return name;
}
} //namespace by