All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
attackToPinned.tcc
Go to the documentation of this file.
1 #ifndef _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
2 #define _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC
4 #include "osl/ptypeTable.h"
5 #include "osl/effectContent.h"
7 #include "osl/misc/loki.h"
8 
9 namespace osl
10 {
11  namespace move_generator
12  {
13  namespace {
14  template<Player P,Ptype T,class Action>
15  void generatePtype(const NumEffectState& state,Action& action)
16  {
17  Square target=state.template kingSquare<PlayerTraits<P>::opponent>();
18  for(int num=PtypeTraits<T>::indexMin;num<PtypeTraits<T>::indexLimit;num++){
19  Piece p=state.pieceOf(num);
20  if(p.template isOnBoardByOwner<P>()){
21  Square from=p.square();
22  EffectContent effect=Ptype_Table.getEffect(newPtypeO(P,T),from,target);
23  if(effect.hasEffect()){
24  Offset offset=effect.offset();
25  assert(!offset.zero());
26  Piece p1;
27  Square pos=target-offset;
28  for(;(p1=state.pieceAt(pos)).isEmpty();pos-=offset) ;
29  if(p1.canMoveOn<P>() &&
30  state.hasEffectByPiece(p,pos)){
31  AddEffectWithEffect<Action>::template generate<P,false>(state,pos,action);
32  }
33  }
34  }
35  }
36  }
37  }
38  template<Player P>
39  template<class Action>
41  generate(const NumEffectState& state,Action& action)
42  {
43  generatePtype<P,ROOK,Action>(state,action);
44  generatePtype<P,BISHOP,Action>(state,action);
45  generatePtype<P,LANCE,Action>(state,action);
46  }
47 
48  }
49 }
50 
51 #endif /* _MOVE_GENERATOR_ATTACK_TO_PINNED_TCC */
52 // ;;; Local Variables:
53 // ;;; mode:c++
54 // ;;; c-basic-offset:2
55 // ;;; End: