virtualPin.h
Go to the documentation of this file.
00001 /* virtualPin.h
00002  */
00003 #ifndef _VIRTUALPIN_H
00004 #define _VIRTUALPIN_H
00005 
00006 #include "osl/state/numEffectState.h"
00007 namespace osl
00008 {
00009   namespace effect_util
00010   {
00011     class VirtualPin
00012     {
00013     private:
00014       template <Direction DIR>
00015       static bool findDirection(const SimpleState& state, Square target,
00016                                 Player defense, const PieceMask& remove)
00017       {
00018         const Offset diff = Board_Table.getOffset(defense, DIR);
00019         Piece p;
00020         for (p=state.nextPiece(target, diff);;p=state.nextPiece(p.square(), diff)) {
00021           if (! p.isPiece())
00022             return false;
00023           if (! remove.test(p.number()))
00024             break;
00025         }
00026         assert(p.isPiece());
00027         if (p.owner() == defense)
00028           return false;
00029         return (Ptype_Table.getMoveMask(p.ptype())
00030                 & DirectionTraits<DirectionTraits<DIR>::longDir>::mask);
00031       }
00032     public:
00034       static bool find(const NumEffectState& state, Player defense, const PieceMask& remove);
00035       static bool find(const NumEffectState& state, Player defense, Square target)
00036       {
00037         return find(state, defense, state.effectSetAt(target));
00038       }
00039     };
00040   }
00041   using effect_util::VirtualPin;
00042 }
00043 
00044 #endif /* _VIRTUALPIN_H */
00045 // ;;; Local Variables:
00046 // ;;; mode:c++
00047 // ;;; c-basic-offset:2
00048 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines