square.cc
Go to the documentation of this file.
00001 /* square.cc
00002  */
00003 #include "osl/square.h"
00004 #include <boost/static_assert.hpp>
00005 #include <iostream>
00006 
00007 BOOST_STATIC_ASSERT(sizeof(osl::Square) == 4);
00008 
00009 bool osl::Square::isOnBoardSlow() const 
00010 {
00011     return (1<=x() && x() <=9 
00012             && 1<=y() && y() <=9);
00013 }
00014 
00015 bool osl::Square::isValid() const
00016 {
00017   return isPieceStand() || isOnBoard();
00018 }
00019 
00020 const osl::Square osl::
00021 Square::squareForBlackSlow(Player player) const
00022 {
00023   if (player == BLACK) 
00024     return *this;
00025   return Square(reverseX(x()),reverseY(y()));
00026 }
00027 
00028 std::ostream& osl::operator<<(std::ostream& os, Square square)
00029 {
00030   if (square.isPieceStand())
00031     return os << "OFF";
00032   return os << "Square(" << square.x() << square.y() << ")";
00033 }
00034 
00035 /* ------------------------------------------------------------------------- */
00036 // ;;; Local Variables:
00037 // ;;; mode:c++
00038 // ;;; c-basic-offset:2
00039 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines