effect5x3Table.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
effect5x3Table.h
Go to the documentation of this file.
1 /* effect5x3Table.h
2 */
3 #ifndef _PROGRESS_EFFECT5X3_TABLE_H
4 #define _PROGRESS_EFFECT5X3_TABLE_H
5
6 #include "osl/ptype.h"
7 #include "osl/ptypeTraits.h"
8 #include "osl/misc/carray3d.h"
9 #include "osl/misc/carray2d.h"
10 #include "osl/misc/carray.h"
11 #include "osl/offset32.h"
12
13 #include <iosfwd>
14
15 namespace osl
16 {
17 namespace progress
18 {
25 struct LongEffect
26 {
27 Offset offset;
28 unsigned short minIndex;
29 unsigned short maxIndex;
30 };
34 typedef CArray<LongEffect,4> LongEffect4;
35
39 class Effect5x3Table
40 {
41 public:
42 enum {
43 StandPAWN=1,
44 StandLANCE=4,
45 StandKNIGHT=8,
46 StandSILVER=8,
47 StandGOLD=8,
48 StandBISHOP=12,
49 StandROOK=12,
50 };
51 private:
52 CArray<unsigned int,PTYPE_SIZE> onStand;
53 CArray2d<unsigned int,PTYPEO_SIZE,Offset32::SIZE> shortEffect;
54 CArray2d<LongEffect4,PTYPEO_SIZE,Offset32::SIZE> longEffect;
55 CArray2d<LongEffect,8,Offset32::SIZE> blockEffect;
56 CArray3d<unsigned int,2,Square::SIZE,5*3> attackEffect;
57 CArray3d<unsigned int,2,Square::SIZE,5*3> defenseEffect;
58 void setupOnStand();
59 void setupShortEffect();
60 void setupLongEffect();
61 void setupBlockEffect();
62 void setupAttackEffect();
63 void setupDefenseEffect();
64 public:
65 Effect5x3Table();
75 unsigned int piecesOnStand(Ptype ptype) const
76 {
77 return onStand[ptype];
78 }
85 unsigned int countShortEffect(PtypeO ptypeO,Offset32 offset32) const
86 {
87 return shortEffect[ptypeO-PTYPEO_MIN][offset32.index()];
88 }
95 LongEffect4 const& getLongEffect(PtypeO ptypeO,Offset32 offset32) const
96 {
97 return longEffect[ptypeO-PTYPEO_MIN][offset32.index()];
98 }
104 LongEffect const& getBlockEffect(Direction d,Offset32 offset32) const
105 {
106 assert(d<8);
107 return blockEffect[d][offset32.index()];
108 }
109 unsigned int getAttackEffect(Player pl,Square pos,int x,int y) const
110 {
111 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
112 return attackEffect[pl][pos.index()][x*3+y];
113 }
114 unsigned int getDefenseEffect(Player pl,Square pos,int x,int y) const
115 {
116 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
117 return defenseEffect[pl][pos.index()][x*3+y];
118 }
119 };
120 extern const Effect5x3Table Effect5x3_Table;
121 std::ostream& operator<<(std::ostream& os,LongEffect const& longEffect);
122 }
123 }
124 #endif /* _PROGRESS_EFFECT5X3_TABLE_H */
125 // ;;; Local Variables:
126 // ;;; mode:c++
127 // ;;; c-basic-offset:2
128 // ;;; End: