All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
noEffectFilter.h
Go to the documentation of this file.
1 /* noEffectFilter.h
2  */
3 #ifndef _NO_EFFECT_FILTER_H
4 #define _NO_EFFECT_FILTER_H
5 
6 #include "osl/player.h"
8 namespace osl
9 {
10  namespace move_action
11  {
15  template<Player P,class OrigAction>
17  {
18  BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
19  const NumEffectState& state;
20  OrigAction & action;
22  public:
23  NoEffectFilter(const NumEffectState& s, OrigAction & action,Square pos) : state(s), action(action),removed(pos) {}
24  void simpleMove(Square from,Square to,Ptype ptype, bool isPromote,Player /* p */,Move m){
25  if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed))
26  action.simpleMove(from,to,ptype,isPromote,P,m);
27  }
28  void unknownMove(Square from,Square to,Piece p1,Ptype ptype,bool isPromote,Player /* p */,Move m){
29  if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed)){
30  action.unknownMove(from,to,p1,ptype,isPromote,P,m);
31  }
32  }
33  void dropMove(Square to,Ptype ptype,Player /* p */,Move m){
35  if(!state.template hasEffectByWithRemove<PlayerTraits<P>::opponent>(to,removed))
36  action.dropMove(to,ptype,P,m);
37  }
38  // old interfaces
39  void simpleMove(Square from,Square to,Ptype ptype,
40  bool isPromote,Player p)
41  {
42  simpleMove(from,to,ptype,isPromote,p,
43  Move(from,to,ptype,PTYPE_EMPTY,isPromote,p));
44  }
46  Ptype ptype,bool isPromote,Player p)
47  {
48  unknownMove(from,to,captured,ptype,isPromote,p,
49  Move(from,to,ptype,captured.ptype(),isPromote,p));
50  }
51  void dropMove(Square to,Ptype ptype,Player p)
52  {
53  dropMove(to,ptype,p,
54  Move(to,ptype,p));
55  }
56  };
57 
58  } // namespace move_action
59 } // namespace osl
60 
61 
62 #endif /* _NO_EFFECT_FILTER_H */
63 // ;;; Local Variables:
64 // ;;; mode:c++
65 // ;;; c-basic-offset:2
66 // ;;; End: