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