00001 #ifndef _PROMOTE_MOVE_ACTION_H
00002 #define _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 Promote
00013 {
00014 BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
00015 private:
00016 const State& state;
00017 Action & ac;
00018 public:
00019 Promote(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 if(p1.isPromoted())
00027 ac.unknownMove(from,to,state.getPieceAt(to),promote(Type),false,P);
00028 else if(to.canPromote<P>() || from.canPromote<P>())
00029 ac.unknownMove(from,to,state.getPieceAt(to),promote(Type),true,P);
00030 }
00031 template<Player P>
00032 void doAction(Piece p1,Position to){
00033 Position from=p1.position();
00034 Ptype ptype=p1.ptype();
00035 if(p1.isPromoted())
00036 ac.unknownMove(from,to,state.getPieceAt(to),ptype,false,P);
00037 else if(to.canPromote<P>() || from.canPromote<P>())
00038 ac.unknownMove(from,to,state.getPieceAt(to),promote(ptype),true,P);
00039 }
00040 bool done() const{ return false;}
00041 };
00042 }
00043 }
00044 #endif
00045
00046
00047
00048