00001
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 Position removed;
00022 public:
00023 NoEffectFilter(const NumEffectState& s, OrigAction & action,Position pos) : state(s), action(action),removed(pos) {}
00024 void simpleMove(Position from,Position to,Ptype ptype, bool isPromote,Player ,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(Position from,Position to,Piece p1,Ptype ptype,bool isPromote,Player ,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(Position to,Ptype ptype,Player ,Move m){
00035 if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed))
00036 action.dropMove(to,ptype,P,m);
00037 }
00038
00039 void simpleMove(Position from,Position 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(Position from,Position 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(Position to,Ptype ptype,Player p)
00052 {
00053 dropMove(to,ptype,p,
00054 Move(to,ptype,p));
00055 }
00056 };
00057
00058 }
00059 }
00060
00061
00062 #endif
00063
00064
00065
00066