All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
captureFrom.h
Go to the documentation of this file.
1 /* captureFrom.h
2  */
3 #ifndef _MOVE_capture_from_H
4 #define _MOVE_capture_from_H
5 #include "osl/square.h"
6 #include "osl/player.h"
7 #include "osl/ptype.h"
10 
11 namespace osl
12 {
13  namespace move_action
14  {
15 
19  template<Player P,class OrigAction>
20  struct CaptureFrom
21  {
22  BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
23  const NumEffectState& state;
24  OrigAction & action;
25 
26  public:
27  CaptureFrom(const NumEffectState& s, OrigAction & action)
28  :
29  state(s), action(action)
30  {
31  }
32 
33  template <Player PP>
34  void doAction (Piece const& p, Square const& /*to*/)
35  {
37  template generate<PlayerTraits<PP>::opponent>(state, p.square(), action);
38 
39  }
40 
41  void simpleMove(Square from,Square to,Ptype ptype,
42  bool isPromote,Player p,Move move)
43  {
44  assert(p == P);
46  generate<PlayerTraits<P>::opponent >(state, from, action);
47 
48  }
49  void unknownMove(Square from,Square to,Piece p1,Ptype ptype,
50  bool isPromote,Player p,Move move)
51  {
52  assert(p == P);
54  generate<PlayerTraits<P>::opponent >(state, from, action);
55  }
59  void dropMove(Square to,Ptype ptype,Player p,Move move){
60  assert(p == P);
61  return;
62  }
63  // old interfaces
64  void simpleMove(Square from,Square to,Ptype ptype,
65  bool isPromote,Player p)
66  {
67  simpleMove(from,to,ptype,isPromote,p,Move());
68  }
70  Ptype ptype,bool isPromote,Player p)
71  {
72  unknownMove(from,to,captured,ptype,isPromote,p,Move());
73  }
74  void dropMove(Square to,Ptype ptype,Player p)
75  {
76  dropMove(to,ptype,p,Move());
77  }
78  };
79  } // namespace move_action
80 } // namespace osl
81 
82 #endif /* _MOVE_capture_from_H */
83 // ;;; Local Variables:
84 // ;;; mode:c++
85 // ;;; c-basic-offset:2
86 // ;;; End: