void QiPan::setCurrentMark(int x, int y)
{
int xIndex, yIndex;
if(findIndex(x, y, xIndex, yIndex))
current_mark = Mark(points[xIndex][yIndex].getX()-18, points[xIndex][yIndex].getY()-18);
else
current_mark = Mark(-50, -50);
}
bool QiPan::setStep(int x, int y, int round, Step & step)
{
int xIndex, yIndex;
if(findIndex(x, y, xIndex, yIndex))
{
step = Step(round, xIndex, yIndex, (round-1)&1);
return true;
}
else
return false;
}
void QiPan::eraseMark(HWND hwnd, const COLORREF & col)
{
prev_mark.erase(hwnd, col);
}
void QiPan::paintMark(HWND hwnd)
{
current_mark.paintMark(hwnd);
}
bool QiPan::isSetable(int x, int y)
{
int xI, yI;
int state;
findIndex(x, y, xI, yI);
state = points[xI][yI].getState();
if(state == -1) // noChessman, so in this position is still setable
return true;
else
return false;
}
void QiPan::addAStep(Step & step)
{
int xI, yI, player;
step.getStepInfo(xI, yI, player);
if(player == 0) // black
points[xI][yI].setBlack();
else // otherwise white
points[xI][yI].setWhite();
vcSteps.push_back(step);
}
Point & QiPan::getPoint(int xIndex, int yIndex)
{
return points[xIndex][yIndex];
}
void QiPan::paint(HWND hwnd)
{
HDC hdc = GetDC(hwnd);
HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 125));
SelectObject(hdc, hPen);
for(int i = 0; i<SIZE; i++)
{
MoveToEx(hdc, points[i][0].getX(), points[i][0].getY(), NULL);
LineTo(hdc, points[i][14].getX(), points[i][14].getY());
MoveToEx(hdc, points[0][i].getX(), points[0][i].getY(), NULL);
LineTo(hdc, points[14][i].getX(), points[14][i].getY());
SetBkMode(hdc, TRANSPARENT);
TextOut(hdc, points[14][i].getX() - 5, points[14][i].getY() + 5, &(zeichen1[i]), 1);
TextOut(hdc, points[i][0].getX() - 25, points[i][0].getY()-10, zeichen2[i].begin(), 2);
}
DeleteObject(hPen);
ReleaseDC(hwnd, hdc);
}
void QiPan::drawAllChessman(HWND hwnd)
{
HDC hdc = GetDC(hwnd);
HPEN hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 125));
SelectObject(hdc, hPen);
for(int i = 0; i<SIZE; i++)
{
for(int j = 0; j<SIZE; j++)
{
if(points[i][j].getState() == Point::BLACK)
drawChessman(hwnd, points[i][j], Point::BLACK);
else if(points[i][j].getState() == Point::WHITE)
drawChessman(hwnd, points[i][j], Point::WHITE);
}
}
DeleteObject(hPen);
ReleaseDC(hwnd, hdc);
}
bool QiPan::judger() // if return true, game over
{
int i, j, round = 0;
bool over = false;
// horizontal judgement
for(i = 0; i<SIZE; i++)
{
for(j = 0; j<11; j++)
{
if(points[i][j].getState() == points[i][j+1].getState() &&
points[i][j].getState()!=Point::NOCHESSMAN)
{
if(points[i][j+1].getState() ==
points[i][j+2].getState() &&
points[i][j+1].getState()!=Point::NOCHESSMAN)
{
if(points[i][j+2].getState() ==
points[i][j+3].getState() &&
points[i][j+2].getState()!=Point::NOCHESSMAN)
{
if(points[i][j+3].getState() == points[i][j+4].getState() &&
points[i][j+3].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner =
points[i][j].getState()==Point::BLACK?"Black":"White";
}
}
}
}
}
}
// vertikale judgement
for(i = 0; i<SIZE; i++)
{
for(j = 0; j<11; j++)
{
if(points[j][i].getState() == points[j+1][i].getState() &&
points[j][i].getState()!=Point::NOCHESSMAN )
{
if(points[j+1][i].getState() ==
points[j+2][i].getState() &&
points[j+1][i].getState()!=Point::NOCHESSMAN)
{
if(points[j+2][i].getState() ==
points[j+3][i].getState()&&points[j+2][i].getState()!=Point::NOCHESSMAN)
{
if(points[j+3][i].getState() ==
points[j+4][i].getState()&&points[j+3][i].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner =
points[j][i].getState()==Point::BLACK?"Black":"White";
}
}
}
}
}
}
// WS-NE
for(j = 10; j>0; j--)
{
for(i = 0; i<j; i++)
{
if(points[14-i][i+1+round].getState() ==
points[13-i][i+2+round].getState() &&
points[14-i][i+1+round].getState()!=Point::NOCHESSMAN)
{
if(points[13-i][i+2+round].getState() ==
points[12-i][i+3+round].getState() &&
points[13-i][i+2+round].getState()!=Point::NOCHESSMAN)
{
if(points[12-i][i+3+round].getState() ==
points[11-i][i+4+round].getState() &&
points[12-i][i+3+round].getState()!=Point::NOCHESSMAN)
{
if(points[11-i][i+5+round].getState() ==
points[10-i][i+6+round].getState() &&
points[11-i][i+5+round].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner = points[14-i][i+1+round].getState() ==
Point::BLACK?"Black":"White";
}
}
}
}
else
if(points[i+1+round][i].getState() == points[i+2+round][i+1].getState()
&& points[i+1+round][i].getState()!=Point::NOCHESSMAN)
{
if(points[i+2+round][i+1].getState() ==
points[i+3+round][i+2].getState() &&
points[i+2+round][i+1].getState()!=Point::NOCHESSMAN)
{
if(points[i+3+round][i+2].getState() ==
points[i+4+round][i+3].getState() &&
points[i+3+round][i+2].getState()!=Point::NOCHESSMAN)
{
if(points[i+4+round][i+3].getState() ==
points[i+5+round][i+4].getState() &&
points[i+4+round][i+3].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner = points[i+1+round][i].getState() ==
Point::BLACK?"Black":"White";
}
}
}
}
else
if(points[i][i+1+round].getState() == points[i+1][i+2+round].getState()
&& points[i][i+1+round].getState()!=Point::NOCHESSMAN)
{
if(points[i+1][i+2+round].getState() ==
points[i+2][i+3+round].getState() &&
points[i+1][i+2+round].getState()!=Point::NOCHESSMAN)
{
if(points[i+2][i+3+round].getState() ==
points[i+3][i+4+round].getState() &&
points[i+2][i+3+round].getState()!=Point::NOCHESSMAN)
{
if(points[i+3][i+4+round].getState() ==
points[i+4][i+5+round].getState() &&
points[i+3][i+4+round].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner = points[i][i+1+round].getState() ==
Point::BLACK?"Black":"White";
}
}
}
}
else
if(points[13-i-round][i].getState() ==
points[12-i-round][i+1].getState() &&
points[13-i-round][i].getState()!=Point::NOCHESSMAN)
{
if(points[12-i-round][i+1].getState() ==
points[11-i-round][i+2].getState() &&
points[12-i-round][i+1].getState()!=Point::NOCHESSMAN)
{
if(points[11-i-round][i+2].getState() ==
points[10-i-round][i+3].getState() &&
points[11-i-round][i+2].getState()!=Point::NOCHESSMAN)
{
if(points[10-i-round][i+3].getState() ==
points[9-i-round][i+4].getState() &&
points[10-i-round][i+3].getState()!=Point::NOCHESSMAN)
{
//found the winner, game over, send Message
over = gameover = true;
winner = points[13-i-round][i].getState() ==
Point::BLACK?"Black":"White";
}
}
}
}
}
round++;
}
for(i = 0; i<11; i++)
{
if(points[14-i][i].getState() ==
points[13-i][i+1].getState() &&
points[14-i][i].getState()!=Point::NOCHESSMAN)
{
if(points[13-i][i+1].getState() == points[12-i][i+2].getState()
&& points[13-i][i+1].getState()!=Point::NOCHESSMAN)
{
if(points[12-i][i+2].getState() ==
points[11-i][i+3].getState() &&
points[12-i][i+2].getState()!=Point::NOCHESSMAN)
{
if(points[11-i][i+3].getState()
== points[10-i][i+4].getState() &&
points[11-i][i+3].getState()!=Point::NOCHESSMAN)
{
//found the
winner, game over, send Message
over =
gameover = true;
winner =
points[14-i][i].getState() == Point::BLACK?"Black":"White";
}
}
}
}
else if(points[i][i].getState()
== points[i+1][i+1].getState() &&
points[i][i].getState()!=Point::NOCHESSMAN)
{
if(points[i+1][i+1].getState() ==
points[i+2][i+2].getState()&&points[i+1][i+1].getState()!=Point::NOCHESSMAN)
{
if(points[i+2][i+2].getState() ==
points[i+3][i+3].getState()&&points[i+2][i+2].getState()!=Point::NOCHESSMAN)
{
if(points[i+3][i+3].getState() ==
points[i+4][i+4].getState()&&points[i+3][i+3].getState()!=Point::NOCHESSMAN)
{
//found the
winner, game over, send Message
over =
gameover = true;
winner =
points[i][i].getState() == Point::BLACK?"Black":"White";
}
}
}
}
}
return over;
}
自由,民主,平等,博爱,进步.
中华民国,我的祖国,中华民国万岁!中华民国加油!
本人自愿加入中国国民党,为人的自由性,独立性和平等性而奋斗!