Cute Chess  0.1
result.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef RESULT_H
19 #define RESULT_H
20 
21 #include "side.h"
22 #include <QMetaType>
23 #include <QCoreApplication>
24 
25 namespace Chess {
26 
33 class LIB_EXPORT Result
34 {
35  Q_DECLARE_TR_FUNCTIONS(Result)
36 
37  public:
39  enum Type
40  {
42  Win,
62  ResultError
63  };
64 
74  explicit Result(Type type = NoResult,
75  Side winner = Side(),
76  const QString& description = QString());
78  explicit Result(const QString& str);
79 
81  bool operator==(const Result& other) const;
83  bool operator!=(const Result& other) const;
85  bool isNone() const;
87  bool isDraw() const;
88 
90  Side winner() const;
92  Side loser() const;
93 
95  Type type() const;
97  QString description() const;
102  QString toShortString() const;
109  QString toVerboseString() const;
110 
111  private:
112  Type m_type;
113  Side m_winner;
114  QString m_description;
115 };
116 
117 } // namespace Chess
118 
119 Q_DECLARE_METATYPE(Chess::Result)
120 
121 #endif // RESULT_H
Draw by any means.
Definition: result.h:44
Loser disconnects, or terminates (if it&#39;s an engine).
Definition: result.h:54
Loser&#39;s connection stalls (doesn&#39;t respond to ping).
Definition: result.h:56
Win by any means.
Definition: result.h:42
Definition: boardscene.h:28
Both players agree to a result.
Definition: result.h:58
The side or color of a chess player.
Definition: side.h:34
No result. The game may continue.
Definition: result.h:60
A player&#39;s time flag falls.
Definition: result.h:48
The result of a chess game.
Definition: result.h:33
Type
Definition: result.h:39
Loser resigns.
Definition: result.h:46
Loser tries to make an illegal move.
Definition: result.h:52
Adjudication by the GUI.
Definition: result.h:50