00001 #ifndef _BETTER_TO_PROMOTE_MOVE_ACTION_H
00002 #define _BETTER_TO_PROMOTE_MOVE_ACTION_H
00003 #include "osl/move_action/concept.h"
00004 namespace osl
00005 {
00006 namespace effect_action
00007 {
00011 template<class State,class Action>
00012 class BetterToPromote
00013 {
00014 BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
00015 private:
00016 const State& state;
00017 Action & ac;
00018 public:
00019 BetterToPromote(const State& s, Action& a)
00020 : state(s), ac(a)
00021 {
00022 }
00023 template<Player P,Ptype Type>
00024 void doActionPtype(Piece p1,Position to){
00025 Position from=p1.position();
00026 Ptype ptype=p1.ptype();
00027 if(!isPromoted(ptype) &&
00028 (to.canPromote<P>() || from.canPromote<P>()))
00029 ac.unknownMove(from,to,state.getPieceAt(to),promote(Type),true,P);
00030 else
00031 ac.unknownMove(from,to,state.getPieceAt(to),ptype,false,P);
00032 }
00033 template<Player P>
00034 void doAction(Piece p1,Position to){
00035 Position from=p1.position();
00036 Ptype ptype=p1.ptype();
00037 if(!isPromoted(ptype) &&
00038 (to.canPromote<P>() || from.canPromote<P>()))
00039 ac.unknownMove(from,to,state.getPieceAt(to),promote(ptype),true,P);
00040 else
00041 ac.unknownMove(from,to,state.getPieceAt(to),ptype,false,P);
00042 }
00043 bool done() const{ return false; }
00044 };
00045 }
00046 }
00047 #endif // BETTER_TO_PROMOTE_MOVE_ACTION_H
00048
00049
00050
00051