sennichite.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
sennichite.h
Go to the documentation of this file.
1 /* sennichite.h
2 */
3 #ifndef OSL_SENNICHITE_H
4 #define OSL_SENNICHITE_H
5
6 #include "osl/player.h"
7 #include <iosfwd>
8
9 namespace osl
10 {
11 class Sennichite
12 {
13 friend bool operator==(const Sennichite&, const Sennichite&);
14 struct Result
15 {
16 enum Values { NORMAL, DRAW, BLACK_LOSE, WHITE_LOSE };
17 };
18 Result::Values value;
19 Sennichite(Result::Values v) : value(v) {}
20 public:
21 static Sennichite NORMAL() { return Result::NORMAL; }
22 static Sennichite DRAW() { return Result::DRAW; }
23 static Sennichite BLACK_LOSE() { return Result::BLACK_LOSE; }
24 static Sennichite WHITE_LOSE() { return Result::WHITE_LOSE; }
25
26 bool isNormal() const { return value == Result::NORMAL; }
27 bool isDraw() const { return value == Result::DRAW; }
28 bool hasWinner() const
29 {
30 return (value == Result::BLACK_LOSE) || (value == Result::WHITE_LOSE);
31 }
32 Player winner() const;
33 };
34
35 inline bool operator==(const Sennichite& l, const Sennichite& r)
36 {
37 return l.value == r.value;
38 }
39 std::ostream& operator<<(std::ostream&, const Sennichite&);
40 } // namespace osl
41
42 #endif /* OSL_SENNICHITE_H */
43 // ;;; Local Variables:
44 // ;;; mode:c++
45 // ;;; c-basic-offset:2
46 // ;;; End: