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