class Server{
private:
int acNum;
int naNum;
const static int MAX_AC_NUM = 50;
const static int MAX_NA_NUM = 16;
Account* ac[MAX_AC_NUM];
Nation* na[MAX_NA_NUM];
const int searchEmptyAcIndex();
const int searchEmptyNaIndex();
template <class T> const static bool typeIsAc(T arg){
return (typeid(arg)) == (typeid(Account));
}
template <class T> const static bool typeIsNa(T arg){
return (typeid(arg)) == (typeid(Nation));
}
const static bool isHit(const int myHIT, const int enemySP);
public:
Server():acNum(0), naNum(0), ac(), na(){}
~Server(){
for(int i=0;i<acNum;i++){
delete ac[i];
ac[i] = NULL;
}
for(int i=0;i<naNum;i++){
delete na[i];
na[i] = NULL;
}
}
int makeAc(){
const int index = searchEmptyAcIndex();
makeAc(index);
return index;
}
void makeAc(const int index);
void delAc(const int index);
Account& getAc(int index){
Account& ac = *Server::ac[index];
return ac;
}
int makeNa(const char * const name){
const int index = searchEmptyNaIndex();
makeNa(index, name);
return index;
}
void makeNa(const int index, const char * const name);
void delNa(const int index);
Nation* getNation(const int i){
if((0<=i)&&(i<naNum)){
return na[i];
}else{
std::cout << "not alloc na[" << i << ']' <<std::endl;
return NULL;
}
}
const int getNationNum(){return naNum;}
const int getAccountNum(){return acNum;}
const int getMaxNationNum(){return MAX_NA_NUM;}
const static int getWeaponCost(const Weapon w);
const static int getProtectCost(const Protect p);
const static int getWeaponAT(const Weapon w);
const static int getProtectGU(const Protect p);
const static int getProtectSP(const Protect p);
const static int getWeaponHIT(const Weapon w);
const static int getWeaponAttackNum(const Weapon w);
const static int getWeaponEN(const Weapon w);
const static int calcDamage(const int myAT, const int rivalGU, const int rivalSP, const int myHIT, const int myAttackNum);
};
PR