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,Position to){
00022 Position from=p1.position();
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,Position to){
00031 Position from=p1.position();
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 }
00042 }
00043 #endif
00044
00045
00046
00047