00001 #ifndef _SIMPLE_ALWAYS_MOVE_ACTION_H
00002 #define _SIMPLE_ALWAYS_MOVE_ACTION_H
00003 #include "osl/piece.h"
00004 #include "osl/position.h"
00005 #include "osl/move_action/concept.h"
00006
00007 namespace osl
00008 {
00009 namespace effect_action
00010 {
00014 template <class Action>
00015 class SimpleMove
00016 {
00017 BOOST_CLASS_REQUIRE(Action,osl::move_action,Concept);
00018 private:
00019 Action & ac;
00020 public:
00021 SimpleMove(Action & a) :ac(a){}
00022 template<Player P,Ptype Type>
00023 void doActionPtype(Piece p1,Position to){
00024 Position from=p1.position();
00025 if(canPromote(Type) &&
00026 !p1.isPromotedNotKingGold() &&
00027 (to.canPromote<P>() || from.canPromote<P>())){
00028 ac.simpleMove(from,to,promote(Type),true,P);
00029 }
00030 if(!canPromote(Type) ||
00031 PtypePlayerTraits<Type,P>::canDropTo(to) ||
00032 p1.isPromotedNotKingGold()){
00033 ac.simpleMove(from,to,p1.ptype(),false,P);
00034 }
00035 }
00036 template<Player P>
00037 void doAction(Piece p1,Position to){
00038 Position from=p1.position();
00039 Ptype ptype=p1.ptype();
00040 if(canPromote(ptype)){
00041 if (to.canPromote<P>()){
00042 ac.simpleMove(from,to,promote(ptype),true,P);
00043 if(Ptype_Table.canDropTo(P, ptype,to)){
00044 ac.simpleMove(from,to,ptype,false,P);
00045 }
00046 }
00047 else if (from.canPromote<P>()){
00048 ac.simpleMove(from,to,promote(ptype),true,P);
00049 ac.simpleMove(from,to,ptype,false,P);
00050 }
00051 else{
00052 ac.simpleMove(from,to,ptype,false,P);
00053 }
00054 }
00055 else{
00056 ac.simpleMove(from,to,ptype,false,P);
00057 }
00058 }
00059 bool done() const{ return false;}
00060 };
00061 }
00062 }
00063 #endif
00064
00065
00066
00067