-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathStone.cpp
More file actions
executable file
·66 lines (60 loc) · 1.28 KB
/
Copy pathStone.cpp
File metadata and controls
executable file
·66 lines (60 loc) · 1.28 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
#include "Stone.h"
struct {
int row;
int col;
Stone::TYPE type;
} pos[16] = {
{0, 0, Stone::CHE},
{0, 1, Stone::MA},
{0, 2, Stone::XIANG},
{0, 3, Stone::SI},
{0, 4, Stone::JIANG},
{0, 5, Stone::SI},
{0, 6, Stone::XIANG},
{0, 7, Stone::MA},
{0, 8, Stone::CHE},
{2, 1, Stone::PAO},
{2, 7, Stone::PAO},
{3, 0, Stone::BING},
{3, 2, Stone::BING},
{3, 4, Stone::BING},
{3, 6, Stone::BING},
{3, 8, Stone::BING} };
Stone::Stone()
{
}
QString Stone::name()
{
switch(this->type) {
case Stone::PAO:
return "炮";
case Stone::BING:
return "兵";
case Stone::CHE:
return "车";
case Stone::JIANG:
return "将";
case Stone::MA:
return "马";
case Stone::SI:
return "士";
case Stone::XIANG:
return "相";
}
return "错误";
}
void Stone::init(int ID)
{
if (ID < 16) {
this->row = pos[ID].row;
this->col = pos[ID].col;
this->type = pos[ID].type;
} else {
this->col = 8 - pos[ID-16].col;
this->row = 9 - pos[ID-16].row;
this->type = pos[ID-16].type;
}
this->ID = ID;
this->isDead = false;
this->isRed = (ID >= 16);
}