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 
26 namespace Chess {
27 
34 class LIB_EXPORT Result
35 {
36  Q_DECLARE_TR_FUNCTIONS(Result)
37 
38  public:
40  enum Type
41  {
43  Win,
63  ResultError
64  };
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 
120 Q_DECLARE_METATYPE(Chess::Result)
121 
122 #endif // RESULT_H
Draw by any means.
Definition: result.h:45
Loser disconnects, or terminates (if it&#39;s an engine).
Definition: result.h:55
Loser&#39;s connection stalls (doesn&#39;t respond to ping).
Definition: result.h:57
Win by any means.
Definition: result.h:43
Definition: boardscene.h:29
Both players agree to a result.
Definition: result.h:59
The side or color of a chess player.
Definition: side.h:35
No result. The game may continue.
Definition: result.h:61
A player&#39;s time flag falls.
Definition: result.h:49
The result of a chess game.
Definition: result.h:34
Type
Definition: result.h:40
Loser resigns.
Definition: result.h:47
Loser tries to make an illegal move.
Definition: result.h:53
Adjudication by the GUI.
Definition: result.h:51