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.
19 Piece::Piece(Color color
, Type type
)
23 Piece::Color
Piece::color() const { return m_color
; }
25 Piece::Type
Piece::type() const { return m_type
; }
27 QString
Piece::colorName() const { return colorName(m_color
); }
29 QString
Piece::colorName(Color color
) {
40 QString
Piece::typeName() const { return typeName(m_type
); }
42 QString
Piece::typeName(Type type
) {
61 QString
Piece::name() const {
62 return colorName() + '_' + typeName();
65 Piece::Color
Piece::oppositeColor(Color color
) {
76 bool Piece::operator==(const Piece
& other
) const {
77 return m_color
== other
.m_color
&&
78 m_type
== other
.m_type
;
81 bool Piece::operator!=(const Piece
& other
) const {
82 return !((*this) == other
);
85 Piece
Piece::fromDescription(const QString
& description
) {
86 if (description
.size() == 1) {
87 QChar c
= description
[0];
90 if (c
.category() == QChar::Letter_Uppercase
) {
93 else if (c
.category() == QChar::Letter_Lowercase
) {
100 Type type
= static_cast<Type
>(SAN::getType(c
));
102 if (type
!= INVALID_TYPE
) {
103 return Piece(color
, type
);
110 } // namespace HLVariant