void Player::Update() { //LevelUpHandling if (xpForNextLevel <= xp) { xpForNextLevel = GetXPForLevel(level + 1); level++; OnLevelUp(); } AnimatedTileset::Update(); }
void LevelTable::CheckForLevelUp(Player* p) { int level = p->GetLevel(); int required = GetXPForLevel(level + 1); if(p->GetXP() >= required) { p->SetLevel(level + 1); UpdatePlayerStats(p); stringstream s; s << "You are now level " << (level + 1); string status = s.str(); DataManager::Instance()->AppendStatusString(status); } }
int Player::GetXPForLevel(int l) const { if (l <= 1) return 0; return (int)floor(100.0*std::pow(1.3, (double)l)) + GetXPForLevel(l - 1); }