noEffectFilter.h
Go to the documentation of this file.
00001 /* noEffectFilter.h
00002  */
00003 #ifndef _NO_EFFECT_FILTER_H
00004 #define _NO_EFFECT_FILTER_H
00005 
00006 #include "osl/player.h"
00007 #include "osl/move_action/concept.h"
00008 namespace osl
00009 {
00010   namespace move_action
00011   {
00015     template<Player P,class OrigAction>
00016     class NoEffectFilter
00017     {
00018       BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00019       const NumEffectState& state;
00020       OrigAction & action;
00021       Square removed;
00022     public:
00023       NoEffectFilter(const NumEffectState& s, OrigAction & action,Square pos) : state(s), action(action),removed(pos) {}
00024       void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player /* p */,Move m){
00025         if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed))
00026           action.simpleMove(from,to,ptype,isPromote,P,m);
00027       }
00028       void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player /* p */,Move m){
00029         if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed)){
00030           action.unknownMove(from,to,p1,ptype,isPromote,P,m);
00031         }
00032       }
00033       void dropMove(Square to,Ptype ptype,Player /* p */,Move m){
00035         if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed))
00036           action.dropMove(to,ptype,P,m);
00037       }
00038       // old interfaces
00039       void simpleMove(Square from,Square to,Ptype ptype, 
00040                       bool isPromote,Player p)
00041       {
00042         simpleMove(from,to,ptype,isPromote,p,
00043                    Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
00044       }
00045       void unknownMove(Square from,Square to,Piece captured,
00046                        Ptype ptype,bool isPromote,Player p)
00047       {
00048         unknownMove(from,to,captured,ptype,isPromote,p,
00049                     Move(from,to,ptype,captured.ptype(),isPromote,p));
00050       }
00051       void dropMove(Square to,Ptype ptype,Player p)
00052       {
00053         dropMove(to,ptype,p,
00054                  Move(to,ptype,p));
00055       }
00056     };
00057 
00058   } // namespace move_action
00059 } // namespace osl
00060 
00061 
00062 #endif /* _NO_EFFECT_FILTER_H */
00063 // ;;; Local Variables:
00064 // ;;; mode:c++
00065 // ;;; c-basic-offset:2
00066 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines