Cute Chess 0.1
result.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess 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 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef RESULT_H
20#define RESULT_H
21
22#include "side.h"
23#include <QMetaType>
24#include <QCoreApplication>
25
26namespace Chess {
27
34class LIB_EXPORT Result
35{
36 Q_DECLARE_TR_FUNCTIONS(Result)
37
38 public:
65
75 explicit Result(Type type = NoResult,
76 Side winner = Side(),
77 const QString& description = QString());
79 explicit Result(const QString& str);
80
82 bool operator==(const Result& other) const;
84 bool operator!=(const Result& other) const;
86 bool isNone() const;
88 bool isDraw() const;
89
91 Side winner() const;
93 Side loser() const;
94
96 Type type() const;
98 QString description() const;
103 QString toShortString() const;
110 QString toVerboseString() const;
111
112 private:
113 Type m_type;
114 Side m_winner;
115 QString m_description;
116};
117
118} // namespace Chess
119
120Q_DECLARE_METATYPE(Chess::Result)
121
122#endif // RESULT_H
The result of a chess game.
Definition result.h:35
Type
Definition result.h:41
@ Disconnection
Loser disconnects, or terminates (if it's an engine).
Definition result.h:55
@ NoResult
No result. The game may continue.
Definition result.h:61
@ Agreement
Both players agree to a result.
Definition result.h:59
@ Win
Win by any means.
Definition result.h:43
@ Draw
Draw by any means.
Definition result.h:45
@ Adjudication
Adjudication by the GUI.
Definition result.h:51
@ ResultError
Result error, caused by an invalid result string.
Definition result.h:63
@ Resignation
Loser resigns.
Definition result.h:47
@ Timeout
A player's time flag falls.
Definition result.h:49
@ StalledConnection
Loser's connection stalls (doesn't respond to ping).
Definition result.h:57
@ IllegalMove
Loser tries to make an illegal move.
Definition result.h:53
Result(Type type=NoResult, Side winner=Side(), const QString &description=QString())
Definition result.cpp:24
The side or color of a chess player.
Definition side.h:36