00001 #ifndef _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
00002 #define _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
00003 #include "osl/move_generator/attackToPinned.h"
00004 #include "osl/ptypeTable.h"
00005 #include "osl/effectContent.h"
00006 #include "osl/move_generator/addEffect_.h"
00007 #include "osl/misc/loki.h"
00008 using namespace osl;
00009
00010 namespace osl
00011 {
00012 namespace move_generator
00013 {
00014 namespace {
00015 template<Player P,Ptype T,class Action>
00016 void generatePtype(const NumEffectState& state,Action& action)
00017 {
00018 Position target=state.template getKingPosition<PlayerTraits<P>::opponent>();
00019 for(int num=PtypeTraits<T>::indexMin;num<PtypeTraits<T>::indexLimit;num++){
00020 Piece p=state.getPieceOf(num);
00021 if(p.template isOnBoardByOwner<P>()){
00022 Position from=p.position();
00023 EffectContent effect=Ptype_Table.getEffect(newPtypeO(P,T),from,target);
00024 if(effect.hasEffect()){
00025 Offset offset=effect.offset();
00026 assert(!offset.zero());
00027 Piece p1;
00028 Position pos=target-offset;
00029 for(;(p1=state.getPieceAt(pos)).isEmpty();pos-=offset) ;
00030 if(p1.canMoveOn<P>() &&
00031 state.hasEffectByPiece(p,pos)){
00032 AddEffect<P,false>::generate(state,pos,action);
00033 }
00034 }
00035 }
00036 }
00037 }
00038 }
00039 template<Player P>
00040 template<class Action>
00041 void AttackToPinned<P>::
00042 generate(const NumEffectState& state,Action& action)
00043 {
00044 generatePtype<P,ROOK,Action>(state,action);
00045 generatePtype<P,BISHOP,Action>(state,action);
00046 generatePtype<P,LANCE,Action>(state,action);
00047 }
00048
00049 }
00050 }
00051
00052 #endif
00053
00054
00055
00056