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.
16 Piece::Piece(Color color
, Type type
)
19 , m_promoted(false) { }
23 void Piece::setPromoted() {
27 bool Piece::promoted() const {
31 Piece::Color
Piece::color() const { return m_color
; }
33 Piece::Type
Piece::type() const { return m_type
; }
35 QString
Piece::colorName() const { return colorName(m_color
); }
37 QString
Piece::colorName(Color color
) {
48 QString
Piece::typeName() const { return typeName(m_type
); }
50 QString
Piece::typeName(Type type
) {
73 QString
Piece::name() const {
74 QString res
= colorName() + '_';
77 return res
+ typeName();
80 Piece::Color
Piece::oppositeColor(Color color
) {
81 return (color
== WHITE
) ? BLACK
:
82 (color
== BLACK
) ? WHITE
: INVALID_COLOR
;
85 bool Piece::operator==(const Piece
& other
) const {
86 return m_color
== other
.m_color
&&
87 m_type
== other
.m_type
&&
88 m_promoted
== other
.m_promoted
;
91 bool Piece::operator!=(const Piece
& other
) const {
92 return !((*this) == other
);
97 } // namespace HLVariant