説明を見る。00001
00002
00003 #ifndef _PROGRESS_EFFECT5X3_TABLE_H
00004 #define _PROGRESS_EFFECT5X3_TABLE_H
00005
00006 #include "osl/basic_type.h"
00007 #include "osl/container.h"
00008 #include "osl/bits/offset32.h"
00009 #include <iosfwd>
00010
00011 namespace osl
00012 {
00013 namespace progress
00014 {
00021 struct LongEffect
00022 {
00023 Offset offset;
00024 unsigned short minIndex;
00025 unsigned short maxIndex;
00026 };
00030 typedef CArray<LongEffect,4> LongEffect4;
00031
00035 class Effect5x3Table
00036 {
00037 public:
00038 enum {
00039 StandPAWN=1,
00040 StandLANCE=4,
00041 StandKNIGHT=8,
00042 StandSILVER=8,
00043 StandGOLD=8,
00044 StandBISHOP=12,
00045 StandROOK=12,
00046 };
00047 private:
00048 CArray<unsigned int,PTYPE_SIZE> onStand;
00049 CArray2d<unsigned int,PTYPEO_SIZE,Offset32::SIZE> shortEffect;
00050 CArray2d<LongEffect4,PTYPEO_SIZE,Offset32::SIZE> longEffect;
00051 CArray2d<LongEffect,8,Offset32::SIZE> blockEffect;
00052 CArray3d<unsigned int,2,Square::SIZE,5*3> attackEffect;
00053 CArray3d<unsigned int,2,Square::SIZE,5*3> defenseEffect;
00054 void setupOnStand();
00055 void setupShortEffect();
00056 void setupLongEffect();
00057 void setupBlockEffect();
00058 void setupAttackEffect();
00059 void setupDefenseEffect();
00060 public:
00061 void init();
00071 unsigned int piecesOnStand(Ptype ptype) const
00072 {
00073 return onStand[ptype];
00074 }
00081 unsigned int countShortEffect(PtypeO ptypeO,Offset32 offset32) const
00082 {
00083 return shortEffect[ptypeO-PTYPEO_MIN][offset32.index()];
00084 }
00091 LongEffect4 const& getLongEffect(PtypeO ptypeO,Offset32 offset32) const
00092 {
00093 return longEffect[ptypeO-PTYPEO_MIN][offset32.index()];
00094 }
00100 LongEffect const& getBlockEffect(Direction d,Offset32 offset32) const
00101 {
00102 assert(d<8);
00103 return blockEffect[d][offset32.index()];
00104 }
00105 unsigned int getAttackEffect(Player pl,Square pos,int x,int y) const
00106 {
00107 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
00108 return attackEffect[pl][pos.index()][x*3+y];
00109 }
00110 unsigned int getDefenseEffect(Player pl,Square pos,int x,int y) const
00111 {
00112 assert(pos.isOnBoard() && 0<=x && x<5 && 0<= y && y<3);
00113 return defenseEffect[pl][pos.index()][x*3+y];
00114 }
00115 };
00116 extern Effect5x3Table Effect5x3_Table;
00117 std::ostream& operator<<(std::ostream& os,LongEffect const& longEffect);
00118 }
00119 }
00120 #endif
00121
00122
00123
00124