Ejemplo n.º 1
0
void CFighter::GainHp(int value)
{
	if(value == 0) {
		return;
	}

	int curHp = GetFieldInt(Role_Attrib_Hp);
	int maxHp = GetFieldInt(Role_Attrib_HpMax);

	if(curHp + value <= 0) {
		SetFieldInt(Role_Attrib_Hp, 0);
	}
	else if(curHp + value >= maxHp) {
		SetFieldInt(Role_Attrib_Hp, maxHp);
	}
	else {
		ChangeFieldInt(Role_Attrib_Hp, value);
	}
}
Ejemplo n.º 2
0
void IBaseObj::_SerializeFieldInt(int i, rapidjson::Value& json, rapidjson::Document& root)
{
	rapidjson::Value jsonName;
	rapidjson::Value jsonValue;

	jsonName.SetString(GetFieldName(i).c_str(), root.GetAllocator());
	jsonValue.SetInt(GetFieldInt(i));

	json.AddMember(jsonName, jsonValue, root.GetAllocator());
}
Ejemplo n.º 3
0
void CFighter::OnLevelup(int up)
{
	ChangeFieldInt(Role_Attrib_Level, up, true);
	InitBaseAttr(true);
	//SyncFieldToData("attr");

	if( this->IsPlayer() )
	{
		CEvent* ev = MakeEvent(Event_Player_Levelup, GetID(), (int64)GetFieldInt(Role_Attrib_Level), NULL, true);
		OnEvent(ev);
	}
	else
	{
		CPlayer* player = this->GetPlayer();
		if( player )
		{
			CEvent* ev = MakeEvent(Event_Hero_Levelup, player->GetID(), GetID(), (int64)GetFieldInt(Role_Attrib_Level), NULL, true);
			player->OnEvent(ev);
		}
	}
}
Ejemplo n.º 4
0
void CPlayer::_PackageMsgAttr32(Message::PlayerAttrSync& msg, int i)
{
	Message::PlayerAttrSync::Attr * attr = msg.add_attr();
	attr->set_type(i);
	attr->set_val32(GetFieldInt(i));
}
Ejemplo n.º 5
0
bool CXmlUtil::GetFieldBool(const XMLDOMElementPtr& ele,
                            const wchar_t* filename,
                            BOOL defValue)
{
    return GetFieldInt(ele, filename, defValue) != 0;
}