additionalOrShadow.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
additionalOrShadow.h
Go to the documentation of this file.
1 /* additionalOrShadow.h
2 */
3 #ifndef OSL_ADDITIONALORSHADOW_H
4 #define OSL_ADDITIONALORSHADOW_H
5
6 #include "osl/state/numEffectState.h"
7 #include "osl/boardTable.h"
8 #include "osl/container/pieceVector.h"
9 #include <boost/foreach.hpp>
10 namespace osl
11 {
12 namespace effect_util
13 {
14 struct AdditionalOrShadow
15 {
16 template <int count_max>
17 static int count(const PieceVector& direct_pieces,
18 const NumEffectState& state,
19 Square target, Player attack)
20 {
21 int result=0;
22 BOOST_FOREACH(Piece p, direct_pieces)
23 {
24 const Square from = p.square();
25 int num = p.number();
26 const Direction long_d=Board_Table.getLongDirection<BLACK>(Offset32(target,from));
27 if(!isLong(long_d)) continue; // unpromoted Knightを除いておくのとどちらが得か?
28 Direction d=longToShort(long_d);
29 for(;;){
30 num=state.longEffectNumTable()[num][d];
31 if(Piece::isEmptyNum(num) || state.pieceOf(num).owner()!=attack)
32 break;
33 if (++result >= count_max)
34 return result;
35 }
36 }
37 return result;
38 }
39
40 };
41 }
42 } // namespace osl
43
44 #endif /* OSL_ADDITIONALORSHADOW_H */
45 // ;;; Local Variables:
46 // ;;; mode:c++
47 // ;;; c-basic-offset:2
48 // ;;; coding:utf-8
49 // ;;; End: