void Character::UpdateStats()
{
this->CalculateStats();
PacketBuilder reply(PACKET_STATSKILL, PACKET_PLAYER, 32);
reply.AddShort(this->statpoints);
reply.AddShort(this->display_str);
reply.AddShort(this->display_intl);
reply.AddShort(this->display_wis);
reply.AddShort(this->display_agi);
reply.AddShort(this->display_con);
reply.AddShort(this->display_cha);
reply.AddShort(this->maxhp);
reply.AddShort(this->maxtp);
reply.AddShort(this->maxsp);
reply.AddShort(this->maxweight);
reply.AddShort(this->mindam);
reply.AddShort(this->maxdam);
reply.AddShort(this->accuracy);
reply.AddShort(this->evade);
reply.AddShort(this->armor);
this->Send(reply);
}
bool Character::Buff(std::string statname, int amount, int time, std::string label)
{
int buffstr = 0, buffint = 0, buffwis = 0, buffagi = 0, buffcon = 0, buffcha = 0;
if(!statname.empty())
{
if(int(statname.find("str")) != -1) buffstr = amount;
if(int(statname.find("int")) != -1) buffint = amount;
if(int(statname.find("wis")) != -1) buffwis = amount;
if(int(statname.find("agi")) != -1) buffagi = amount;
if(int(statname.find("con")) != -1) buffcon = amount;
if(int(statname.find("cha")) != -1) buffcha = amount;
if(int(statname.find("exp")) != -1) exprate = amount;
if(buffstr > 0 || buffint > 0 || buffwis > 0 || buffagi > 0 || buffcon > 0 || buffcha > 0)
{
Character_StatBuff *buff = new Character_StatBuff;
buff->time = time;
buff->label = label;
buff->str = buffstr;
buff->intl = buffint;
buff->wis = buffwis;
buff->agi = buffagi;
buff->con = buffcon;
buff->cha = buffcha;
this->statbuffs.push_back(buff);
this->UpdateStats();
return true;
}
}
return false;
}
void Character::ClearBuffsLabeled(std::string label)
{
std::list<Character_StatBuff *> toremove;
UTIL_FOREACH(this->statbuffs, buff)
{
if(buff->label != label)
continue;
toremove.push_back(buff);
}
UTIL_FOREACH(toremove, remove)
{
this->RemoveBuff(remove);
}
}
void Character::RemoveBuff(Character_StatBuff *thebuff)
{
this->statbuffs.erase(std::remove(UTIL_RANGE(this->statbuffs), thebuff),this->statbuffs.end());
this->UpdateStats();
}
void Character::ClearBuffs()
{
this->statbuffs.clear();
this->UpdateStats();
}