00001
00002
00003 #ifndef MOBILITY_LANCE_MOBILITY_H
00004 #define MOBILITY_LANCE_MOBILITY_H
00005 #include "osl/mobility/countMobility.h"
00006
00007 namespace osl
00008 {
00009 namespace mobility
00010 {
00014 struct LanceMobility
00015 {
00016 public:
00024 template<Player P>
00025 static void countBoth(const NumEffectState& state,Piece p,int& countAll,int& countSafe){
00026 assert(p.ptype()==LANCE);
00027 assert(p.isOnBoard());
00028 assert(p.owner()==P);
00029 const Position pos=p.position();
00030 countMobilityBoth(P,state,pos,DirectionPlayerTraits<U,P>::offset(),countAll,countSafe);
00031 }
00032 static void countBoth(Player pl,const NumEffectState& state,Piece p,int& countAll,int &countSafe){
00033 if(pl==BLACK)
00034 countBoth<BLACK>(state,p,countAll,countSafe);
00035 else
00036 countBoth<WHITE>(state,p,countAll,countSafe);
00037 }
00041 template<Player P>
00042 static int countAll(const NumEffectState& state,Piece p){
00043 assert(p.ptype()==LANCE);
00044 assert(p.isOnBoard());
00045 assert(p.owner()==P);
00046 const Position pos=p.position();
00047 return
00048 countMobilityAll(P,state,pos,DirectionPlayerTraits<U,P>::offset());
00049 }
00050 static int countAll(Player pl,const NumEffectState& state,Piece p){
00051 if(pl==BLACK)
00052 return countAll<BLACK>(state,p);
00053 else
00054 return countAll<WHITE>(state,p);
00055 }
00059 template<Player P>
00060 static int countSafe(const NumEffectState& state,Piece p){
00061 assert(p.ptype()==LANCE);
00062 assert(p.isOnBoard());
00063 assert(p.owner()==P);
00064 const Position pos=p.position();
00065 return
00066 countMobilitySafe(P,state,pos,DirectionPlayerTraits<U,P>::offset());
00067 }
00068 static int countSafe(Player pl,const NumEffectState& state,Piece p){
00069 if(pl==BLACK)
00070 return countSafe<BLACK>(state,p);
00071 else
00072 return countSafe<WHITE>(state,p);
00073 }
00074 };
00075 }
00076 }
00077 #endif
00078
00079
00080
00081