00001 /* additionalOrShadow.h 00002 */ 00003 #ifndef OSL_ADDITIONALORSHADOW_H 00004 #define OSL_ADDITIONALORSHADOW_H 00005 00006 #include "osl/numEffectState.h" 00007 #include "osl/bits/boardTable.h" 00008 00009 namespace osl 00010 { 00011 namespace effect_util 00012 { 00013 struct AdditionalOrShadow 00014 { 00015 template <int count_max> 00016 static int count(const PieceVector& direct_pieces, 00017 const NumEffectState& state, 00018 Square target, Player attack) 00019 { 00020 int result=0; 00021 for (Piece p: direct_pieces) 00022 { 00023 const Square from = p.square(); 00024 int num = p.number(); 00025 const Direction long_d=Board_Table.getLongDirection<BLACK>(Offset32(target,from)); 00026 if(!isLong(long_d)) continue; // unpromoted Knightを除いておくのとどちらが得か? 00027 Direction d=longToShort(long_d); 00028 for(;;){ 00029 num=state.longEffectNumTable()[num][d]; 00030 if(Piece::isEmptyNum(num) || state.pieceOf(num).owner()!=attack) 00031 break; 00032 if (++result >= count_max) 00033 return result; 00034 } 00035 } 00036 return result; 00037 } 00038 00039 }; 00040 } 00041 } // namespace osl 00042 00043 #endif /* OSL_ADDITIONALORSHADOW_H */ 00044 // ;;; Local Variables: 00045 // ;;; mode:c++ 00046 // ;;; c-basic-offset:2 00047 // ;;; coding:utf-8 00048 // ;;; End: