simpleBetterToPromote.h
Go to the documentation of this file.
00001 #ifndef _SIMPLE_BETTER_TO_PROMOTE_MOVE_ACTION_H
00002 #define _SIMPLE_BETTER_TO_PROMOTE_MOVE_ACTION_H
00003 
00004 #include "osl/move_action/concept.h"
00005 namespace osl
00006 {
00007   namespace effect_action
00008   {
00012     template<class Action>
00013     class SimpleBetterToPromote
00014     {
00015       BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
00016     private:
00017       Action & ac;
00018     public:
00019       SimpleBetterToPromote(Action & a) :ac(a){}
00020       template<Player P,Ptype Type>
00021       void doActionPtype(Piece p1,Square to){
00022         Square from=p1.square();
00023         Ptype ptype=p1.ptype();
00024         if(!isPromoted(ptype) && (to.canPromote<P>() || from.canPromote<P>()))
00025           ac.simpleMove(from,to,promote(Type),true,P);
00026         else
00027           ac.simpleMove(from,to,ptype,false,P);
00028       }
00029       template<Player P>
00030       void doAction(Piece p1,Square to){
00031         Square from=p1.square();
00032         Ptype ptype=p1.ptype();
00033         if(!isPromoted(ptype) && (to.canPromote<P>() || from.canPromote<P>()))
00034           ac.simpleMove(from,to,promote(ptype),true,P);
00035         else
00036           ac.simpleMove(from,to,ptype,false,P);
00037       }
00038       bool done() const{ return false;}
00039     };
00040 
00041   } // namespace effect_action
00042 } // namespace osl
00043 #endif
00044 // ;;; Local Variables:
00045 // ;;; mode:c++
00046 // ;;; c-basic-offset:2
00047 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines