All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
promote.h
Go to the documentation of this file.
1 #ifndef _PROMOTE_MOVE_ACTION_H
2 #define _PROMOTE_MOVE_ACTION_H
4 namespace osl
5 {
6  namespace effect_action
7  {
11  template<class Action>
12  class Promote
13  {
14  BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
15  private:
16  const NumEffectState& state;
17  Action & ac;
18  public:
19  Promote(const NumEffectState& s, Action& a)
20  : state(s), ac(a)
21  {
22  }
23  template<Player P,Ptype Type>
24  void doActionPtype(Piece p1,Square to){
25  Square from=p1.square();
26  if(p1.isPromoted())
27  ac.unknownMove(from,to,state.pieceAt(to),promote(Type),false,P);
28  else if(to.canPromote<P>() || from.canPromote<P>())
29  ac.unknownMove(from,to,state.pieceAt(to),promote(Type),true,P);
30  }
31  template<Player P>
32  void doAction(Piece p1,Square to){
33  Square from=p1.square();
34  Ptype ptype=p1.ptype();
35  if(p1.isPromoted())
36  ac.unknownMove(from,to,state.pieceAt(to),ptype,false,P);
37  else if(to.canPromote<P>() || from.canPromote<P>())
38  ac.unknownMove(from,to,state.pieceAt(to),promote(ptype),true,P);
39  }
40  bool done() const{ return false;}
41  };
42  } // namespace effect_action
43 } // namespace osl
44 #endif
45 // ;;; Local Variables:
46 // ;;; mode:c++
47 // ;;; c-basic-offset:2
48 // ;;; End: