-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShogiPiece.cpp
111 lines (106 loc) · 1.63 KB
/
ShogiPiece.cpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "ShogiPiece.h"
ShogiPiece::ShogiPiece(PieceType pieceType, PieceColour pieceColour, bool isPromoted) : ChuShogiPiece(pieceType, pieceColour, isPromoted)
{
}
ShogiPiece::~ShogiPiece()
{
}
void ShogiPiece::Promote(PieceType pieceType)
{
_isPromoted = true;
switch (_pieceType)
{
case Rook:
_pieceType = DragonKing;
break;
case Bishop:
_pieceType = DragonHorse;
break;
case Lance:
_pieceType = Gold;
break;
case Silver:
_pieceType = Gold;
break;
case WhiteHorse:
_pieceType = Gold;
break;
case Pawn:
_pieceType = Gold;
break;
default:
break;
}
}
string ShogiPiece::StringCode()
{
switch (_pieceType)
{
case King:
return "K";
case DragonKing:
return "D";
case DragonHorse:
return "H";
case Rook:
return "R";
case Bishop:
return "B";
case Lance:
return "L";
case Silver:
return "S";
case Gold:
return "G";
case WhiteHorse:
return "N";
case Pawn:
return "P";
case Elephant:
return "E";
default:
return "";
}
}
string ShogiPiece::AsianStringCode()
{
switch (_pieceType)
{
case King:
return _basePieceType == Elephant ? "太" : _pieceColour == Black ? "王" : "玉";
case DragonKing:
return "竜";
case DragonHorse:
return "馬";
case Rook:
return "飛";
case Bishop:
return "角";
case Lance:
return "香";
case Silver:
return "銀";
case Gold:
switch (_basePieceType)
{
case Lance:
return "杏";
case Silver:
return "全";
case WhiteHorse:
return "圭";
case Pawn:
return "と";
default:
return "金";
}
case WhiteHorse:
return "桂";
case Pawn:
return "歩";
case Elephant:
return "酔";
default:
return "";
}
}