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