rolebase.cpp
来自「MUD文字游戏开发」· C++ 代码 · 共 50 行
CPP
50 行
#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 + =
减小字号Ctrl + -
显示快捷键?