GNUShogi engine.
[tagua/yd.git] / src / variants / xchess / move.cpp
blob9be91dbdeb089dc052c4c2f5a1cfb888b7c4098e
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include "move.h"
12 #include "piece.h"
13 #include "usermove.h"
16 ChessMove::ChessMove(Point from, Point to, PieceType promotionType)
17 : m_type(Invalid)
18 , from(from), to(to)
19 , promotionType(promotionType)
20 , status(Untested) {}
22 ChessMove::ChessMove()
23 : m_type(Invalid)
24 , promotionType(INVALID_TYPE)
25 , status(Untested) {}
27 QString ChessMove::promotionSymbol() const {
28 return ChessPiece::typeSymbol(promotionType);
31 QString ChessMove::toString(int xsize, int ysize) const {
32 QString res = from.toString(ysize) + to.toString(ysize);
33 if (m_type == Promotion)
34 res = res + "=" + promotionSymbol();
36 return res;
39 bool ChessMove::operator==(const ChessMove& other) const {
40 return from == other.from
41 && to == other.to
42 && promotionType == other.promotionType;
45 bool ChessMove::operator!=(const ChessMove& other) const {
46 return !operator==(other);
49 ChessMove ChessMove::createDropMove(int pool, int piece_index, const Point&) {
50 return ChessMove();