8
Move::Move(int board_size)
14
stoneColor = stoneNone;
16
gameMode = modeNormal;
19
capturesBlack = capturesWhite = 0;
21
fastLoadMarkDict = NULL;
23
scoreWhite = scoreBlack = 0;
26
matrix = new Matrix(board_size);
29
Move::Move(StoneColor c, int mx, int my, int n, GameMode mode, const Matrix &mat, const QString &s)
30
: stoneColor(c), x(mx), y(my), moveNum(n), gameMode(mode), comment(s)
36
capturesBlack = capturesWhite = 0;
39
fastLoadMarkDict = NULL;
41
scoreWhite = scoreBlack = 0;
44
matrix = new Matrix(mat);
45
// Make all matrix values positive
49
Move::Move(StoneColor c, int mx, int my, int n, GameMode mode, const QString &s)
50
: stoneColor(c), x(mx), y(my), moveNum(n), gameMode(mode), comment(s)
56
capturesBlack = capturesWhite = 0;
60
fastLoadMarkDict = NULL;
62
scoreWhite = scoreBlack = 0;
69
delete fastLoadMarkDict;
72
// We do not overwrite the operator == as well, as this is used to compare the
73
// pointers for faster operation.
74
bool Move::equals(Move *m)
79
if (x == m->getX() && y == m->getY() &&
80
stoneColor == m->getColor() &&
81
moveNum == m->getMoveNumber() &&
82
gameMode == m->getGameMode())
88
const QString Move::saveMove(bool isRoot)
95
if (x != -1 && y != -1 && gameMode != modeEdit)
97
// Write something like 'B[aa]'
98
str += stoneColor == stoneBlack ? "B" : "W";
99
str += "[" + Matrix::coordsToString(x-1, y-1) + "]";
103
str += matrix->saveEditedMoves(parent != NULL ? parent->getMatrix() : 0);
106
str += matrix->saveMarks();
108
// Add nodename, if we have one
109
if (!nodeName.isNull() && !nodeName.isEmpty())
117
// Add next move's color
120
if (PLnextMove == stoneBlack)
126
// Add comment, if we have one
127
if (!comment.isNull() && !comment.isEmpty())
130
QString tmp = comment;
132
while ((pos = tmp.find("]", pos)) != -1 && static_cast<unsigned int>(pos) < tmp.length())
134
tmp.replace(pos, 1, "\\]");
143
if (timeinfo && !isRoot && (int) timeLeft)
145
if (stoneColor == stoneBlack)
149
str += QString::number(timeLeft);
155
if (stoneColor == stoneBlack)
159
str += QString::number(openMoves);
164
// Add unknown properties, if we have some
165
if (!unknownProperty.isNull() && !unknownProperty.isEmpty())
168
str += unknownProperty;
174
void Move::insertFastLoadMark(int x, int y, MarkType markType, const QString &txt)
176
if (fastLoadMarkDict == NULL)
178
fastLoadMarkDict = new QIntDict<FastLoadMark>;
179
fastLoadMarkDict->setAutoDelete(TRUE);
182
FastLoadMark *flm = new FastLoadMark;
188
fastLoadMarkDict->insert(Matrix::coordsToKey(x, y), flm);
191
bool Move::isPassMove()
193
if ((x==20) && (y==20))