00001
00002
00003 #ifndef _PROGRESS_EFFECT5X3_TABLE_H
00004 #define _PROGRESS_EFFECT5X3_TABLE_H
00005
00006 #include "osl/ptype.h"
00007 #include "osl/ptypeTraits.h"
00008 #include "osl/misc/carray3d.h"
00009 #include "osl/misc/carray2d.h"
00010 #include "osl/misc/carray.h"
00011 #include "osl/offset32.h"
00012
00013 #include <iosfwd>
00014
00015 namespace osl
00016 {
00017 namespace progress
00018 {
00025 struct LongEffect
00026 {
00027 Offset offset;
00028 unsigned short minIndex;
00029 unsigned short maxIndex;
00030 };
00034 typedef CArray<LongEffect,4> LongEffect4;
00035
00039 class Effect5x3Table
00040 {
00041 public:
00042 enum {
00043 StandPAWN=1,
00044 StandLANCE=4,
00045 StandKNIGHT=8,
00046 StandSILVER=8,
00047 StandGOLD=8,
00048 StandBISHOP=12,
00049 StandROOK=12,
00050 };
00051 private:
00052 CArray<unsigned int,PTYPE_SIZE> onStand;
00053 CArray2d<unsigned int,PTYPEO_SIZE,Offset32::SIZE> shortEffect;
00054 CArray2d<LongEffect4,PTYPEO_SIZE,Offset32::SIZE> longEffect;
00055 CArray2d<LongEffect,8,Offset32::SIZE> blockEffect;
00056 CArray3d<unsigned int,2,Position::SIZE,5*3> attackEffect;
00057 CArray3d<unsigned int,2,Position::SIZE,5*3> defenseEffect;
00058 void setupOnStand();
00059 void setupShortEffect();
00060 void setupLongEffect();
00061 void setupBlockEffect();
00062 void setupAttackEffect();
00063 void setupDefenseEffect();
00064 public:
00065 Effect5x3Table();
00075 unsigned int piecesOnStand(Ptype ptype) const
00076 {
00077 return onStand[ptype];
00078 }
00085 unsigned int countShortEffect(PtypeO ptypeO,Offset32 offset32) const
00086 {
00087 return shortEffect[ptypeO-PTYPEO_MIN][offset32.index()];
00088 }
00095 LongEffect4 const& getLongEffect(PtypeO ptypeO,Offset32 offset32) const
00096 {
00097 return longEffect[ptypeO-PTYPEO_MIN][offset32.index()];
00098 }
00104 LongEffect const& getBlockEffect(Direction d,Offset32 offset32) const
00105 {
00106 assert(d<8);
00107 return blockEffect[d][offset32.index()];
00108 }
00109 unsigned int getAttackEffect(Player pl,Position pos,int x,int y) const
00110 {
00111 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
00112 return attackEffect[playerToIndex(pl)][pos.index()][x*3+y];
00113 }
00114 unsigned int getDefenseEffect(Player pl,Position pos,int x,int y) const
00115 {
00116 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
00117 return defenseEffect[playerToIndex(pl)][pos.index()][x*3+y];
00118 }
00119 };
00120 extern const Effect5x3Table Effect5x3_Table;
00121 std::ostream& operator<<(std::ostream& os,LongEffect const& longEffect);
00122 }
00123 }
00124 #endif
00125
00126
00127
00128