sennichite.h
Go to the documentation of this file.
00001 /* sennichite.h
00002  */
00003 #ifndef OSL_SENNICHITE_H
00004 #define OSL_SENNICHITE_H
00005 
00006 #include "osl/player.h"
00007 #include <iosfwd>
00008 
00009 namespace osl
00010 {
00011   class Sennichite 
00012   {
00013     friend bool operator==(const Sennichite&, const Sennichite&);
00014     struct Result
00015     {
00016       enum Values { NORMAL, DRAW, BLACK_LOSE, WHITE_LOSE };
00017     };
00018     Result::Values value;
00019     Sennichite(Result::Values v) : value(v) {}
00020   public:
00021     static Sennichite NORMAL() { return Result::NORMAL; }
00022     static Sennichite DRAW()   { return Result::DRAW; }
00023     static Sennichite BLACK_LOSE() { return Result::BLACK_LOSE; }
00024     static Sennichite WHITE_LOSE() { return Result::WHITE_LOSE; }
00025 
00026     bool isNormal() const { return value == Result::NORMAL; }
00027     bool isDraw() const { return value == Result::DRAW; }
00028     bool hasWinner() const 
00029     {
00030       return (value == Result::BLACK_LOSE) || (value == Result::WHITE_LOSE); 
00031     }
00032     Player winner() const;
00033   };
00034 
00035   inline bool operator==(const Sennichite& l, const Sennichite& r)
00036   {
00037     return l.value == r.value;
00038   }
00039   std::ostream& operator<<(std::ostream&, const Sennichite&);
00040 } // namespace osl
00041 
00042 #endif /* OSL_SENNICHITE_H */
00043 // ;;; Local Variables:
00044 // ;;; mode:c++
00045 // ;;; c-basic-offset:2
00046 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines