2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 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.
14 : m_src(Point::invalid())
15 , m_dst(Point::invalid())
20 Move::Move(const Point
& src
, const Point
& dst
, IType
* promotion
)
23 , m_promotion(promotion
)
27 Move::Move(const IColor
* pool
, int index
, const Point
& dst
)
28 : m_src(Point::invalid())
34 Point
Move::src() const { return m_src
; }
36 Point
Move::dst() const { return m_dst
; }
38 Point
Move::delta() const { return dst() - src(); }
40 Piece
Move::drop() const { return m_drop
; }
42 void Move::setDrop(const Piece
& piece
) { m_drop
= piece
; }
44 bool Move::isDrop() const { return m_pool
!= 0 && m_index
!= -1; }
46 const IColor
* Move::pool() const { return m_pool
; }
48 int Move::index() const { return m_index
; }
50 QString
Move::type() const { return m_type
; }
52 void Move::setType(const QString
& type
) { m_type
= type
; }
54 const IType
* Move::promotion() const { return m_promotion
; }
56 void Move::setPromotion(const IType
* prom
) { m_promotion
= prom
; }
58 bool Move::operator==(const Move
& mv
) const {
59 if (!TaguaObject::operator==(mv
)) return false;
60 if (m_type
!= mv
.m_type
) return false;
63 return m_pool
== mv
.m_pool
&&
64 m_index
== mv
.m_index
&&
66 m_promotion
== mv
.m_promotion
;
69 return m_src
== mv
.m_src
&&
71 m_promotion
== mv
.m_promotion
;
75 bool Move::operator!=(const Move
& mv
) const {
76 return !(operator==(mv
));