📄 rolebase.cpp
字号:
#include "RoleBase.h"
CRoleBase::CRoleBase(void)
{
}
CRoleBase::CRoleBase(string name,
int nHP,
int nMP,
int nCurrentHP,
int nCurrentMP,
int nAttack,
int nDefence,
int nMoney,
unsigned unExperience)
{
m_name = name;
m_nHP = nHP;
m_nMP = nMP;
m_nCurrentHP = nCurrentHP;
m_nCurrentMP = nCurrentMP;
m_nAttack = nAttack;
m_nDefence = nDefence;
m_nMoney = nMoney;
m_unExperience = unExperience;
}
CRoleBase::~CRoleBase(void)
{
}
int CRoleBase::CalculatorHP(int nAttack)//HP计算函数
{
int nAttackValue=nAttack-m_nDefence;//攻击值的运算
if (nAttackValue<0)
{
nAttackValue = 1;
}
if(m_nCurrentHP>nAttackValue)
{
m_nCurrentHP-=nAttackValue;//得到下血量
}
else
{
nAttackValue=m_nCurrentHP;//判断是否血量为零 计算死亡
m_nCurrentHP=0;
}
return nAttackValue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -