Files
mir_server/server/LogicServer/config/SkillProvider.h

123 lines
3.0 KiB
C
Raw Normal View History

2025-01-09 17:45:40 +08:00
#pragma once
class CSkillProvider :
public CVector<OneSkillData>,
protected CCustomLogicLuaConfig
{
public:
typedef CVector<OneSkillData> Inherited;
typedef CCustomLogicLuaConfig Inherited2;
typedef CObjectAllocator<char> CDataAllocator;
public:
CSkillProvider();
~CSkillProvider();
//转换为OneSkillData数组的类型转换函数
inline operator const OneSkillData* () const
{
CSkillProvider *pProvider = (CSkillProvider*)this;
return pProvider->Inherited::operator OneSkillData*();
}
/*
* Comments:ID返回技能数据
* Param const INT_PTR nSkillId:ID
* @Return const OneSkillData*:
*/
inline const OneSkillData* GetSkillData(const INT_PTR nSkillId) const
{
//ID为0的
if ( nSkillId <= 0 || nSkillId >= Inherited::count() )
return NULL;
else return &(this->operator const OneSkillData*()[nSkillId]);
}
inline LPCSTR GetSkillNameById(const INT_PTR nSkillId) const
{
const OneSkillData* pSkill = GetSkillData(nSkillId);
return pSkill ? pSkill->sSkillName:"";
}
/*
* Comments:
* Param const INT_PTR nSkillId:ID
* Param const INT_PTR nLevel:
* @Return const SKILLONELEVEL *:
*/
inline SKILLONELEVEL * GetSkillLevelData( INT_PTR nSkillId, INT_PTR nLevel)
{
const OneSkillData * pSkill = GetSkillData(nSkillId);
if(pSkill ==NULL) return NULL;
if ( nLevel <= 0 || nLevel >= pSkill->levels.count )
return NULL;
else return &(pSkill->levels.pData[nLevel]);
}
/*
* Comments:
* @Return INT_PTR:
*/
inline INT_PTR count() const{ return Inherited::count(); }
/*
* Comments:id
* Param char * pSkillName:
* @Return INT_PTR:id-1
*/
inline INT_PTR GetSkillIdByName(char * pSkillName)
{
for(INT_PTR i=0 ;i <Inherited::count(); i++ )
{
const OneSkillData * pData = &(this->operator const OneSkillData*()[i]);
if( 0== strcmp( pData->sSkillName, pSkillName) )
{
return pData->nSkillID ;
};
}
return -1;
}
/*
* Comments:
* Param LPCTSTR sFilePath:
* @Return bool: false
*/
bool LoadSkills(LPCTSTR sFilePath);
std::vector<OneSkillData*>& GetVocationSKills(int nVocation)
{
switch (nVocation)
{
case enVocWarrior:
return m_Warrior;
case enVocMagician:
return m_Magician;
case enVocWizard:
return m_Wizard;
default:
return m_None;
}
}
protected:
//以下函数为覆盖父类的相关数据处理函数
void showError(LPCTSTR sError);
private:
/*
* Comments:
* @Return bool: false
*/
bool ReadAllSkills();
private:
CDataAllocator m_DataAllocator;
std::vector<OneSkillData*> m_None;// 无职业技能
std::vector<OneSkillData*> m_Warrior;// 道士技能
std::vector<OneSkillData*> m_Magician;// 法师技能
std::vector<OneSkillData*> m_Wizard; //道士技能
};