captureFrom.h
Go to the documentation of this file.
00001 /* captureFrom.h
00002  */
00003 #ifndef _MOVE_capture_from_H
00004 #define _MOVE_capture_from_H
00005 #include "osl/square.h"
00006 #include "osl/player.h"
00007 #include "osl/ptype.h"
00008 #include "osl/move_action/concept.h"
00009 #include "osl/move_generator/capture_.h"
00010 
00011 namespace osl
00012 {
00013   namespace move_action
00014   {
00015     
00019     template<Player P,class OrigAction>
00020     struct CaptureFrom
00021     {
00022       BOOST_CLASS_REQUIRE(OrigAction,osl::move_action,Concept);
00023       const NumEffectState& state;
00024       OrigAction & action;
00025 
00026     public:
00027       CaptureFrom(const NumEffectState& s, OrigAction & action)
00028         :
00029         state(s), action(action)
00030       {
00031       }
00032 
00033       template <Player PP>
00034       void doAction (Piece const& p, Square const& /*to*/)
00035       {
00036         move_generator::Capture<OrigAction>::
00037           template generate<PlayerTraits<PP>::opponent>(state, p.square(), action);
00038       
00039       }
00040 
00041       void simpleMove(Square from,Square to,Ptype ptype,
00042                       bool isPromote,Player p,Move move)
00043       {
00044         assert(p == P);
00045         move_generator::Capture<OrigAction>::
00046           generate<PlayerTraits<P>::opponent >(state, from, action);
00047       
00048       }
00049       void unknownMove(Square from,Square to,Piece p1,Ptype ptype,
00050                        bool isPromote,Player p,Move move)
00051       {
00052         assert(p == P);
00053         move_generator::Capture<OrigAction>::
00054           generate<PlayerTraits<P>::opponent >(state, from, action);
00055       }
00059       void dropMove(Square to,Ptype ptype,Player p,Move move){
00060         assert(p == P);
00061         return;
00062       }
00063       // old interfaces
00064       void simpleMove(Square from,Square to,Ptype ptype, 
00065                       bool isPromote,Player p)
00066       {
00067         simpleMove(from,to,ptype,isPromote,p,Move());
00068       }
00069       void unknownMove(Square from,Square to,Piece captured,
00070                        Ptype ptype,bool isPromote,Player p)
00071       {
00072         unknownMove(from,to,captured,ptype,isPromote,p,Move());
00073       }
00074       void dropMove(Square to,Ptype ptype,Player p)
00075       {
00076         dropMove(to,ptype,p,Move());
00077       }
00078     };
00079   } // namespace move_action
00080 } // namespace osl
00081 
00082 #endif /* _MOVE_capture_from_H */
00083 // ;;; Local Variables:
00084 // ;;; mode:c++
00085 // ;;; c-basic-offset:2
00086 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines