00001 #ifndef _SIMPLE_PROMOTE_MOVE_ACTION_H
00002 #define _SIMPLE_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 SimplePromote
00014 {
00015 BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
00016 private:
00017 Action & ac;
00018 public:
00019 explicit SimplePromote(Action & a) :ac(a){}
00020 template<Player P,Ptype Type>
00021 void doActionPtype(Piece p1,Position to)
00022 {
00023 Position from=p1.position();
00024 if (p1.isPromoted())
00025 ac.simpleMove(from,to,promote(Type),false,P);
00026 else if (canPromote(Type)
00027 && (to.canPromote<P>() || from.canPromote<P>()))
00028 ac.simpleMove(from,to,promote(Type),true,P);
00029 }
00030 template<Player P>
00031 void doAction(Piece p1,Position to){
00032 Position from=p1.position();
00033 Ptype ptype=p1.ptype();
00034 if (ptype.isPromoted())
00035 ac.simpleMove(from,to,ptype,false,P);
00036 else if (canPromote(ptype)
00037 && (to.canPromote<P>() || from.canPromote<P>()))
00038 ac.simpleMove(from,to,promote(ptype),true,P);
00039 }
00040 bool done() const{ return false;}
00041 };
00042
00043 }
00044 }
00045 #endif
00046
00047
00048
00049