@ -57,6 +57,9 @@ All rights reserved.
# include "GameSettings.h"
# include "Unlock.h"
# include "Tutorial.h"
# ifndef __EMSCRIPTEN__
# include <isteamuserstats.h>
# endif
INCLUDE_MONSTER_DATA
INCLUDE_MONSTER_LIST
@ -1301,9 +1304,8 @@ void Player::AddXP(const uint32_t xpGain){
currentLevelXP + = xpGain ;
totalXPEarned + = xpGain ;
if ( Level ( ) < LevelCap ( ) ) {
uint32_t nextLevelXP = NextLevelXPRequired ( ) ;
while ( currentLevelXP > = nextLevelXP ) {
currentLevelXP - = nextLevelXP ;
while ( currentLevelXP > = NextLevelXPRequired ( ) ) {
currentLevelXP - = NextLevelXPRequired ( ) ;
SetLevel ( Level ( ) + 1 ) ;
OnLevelUp ( ) ;
}
@ -1324,6 +1326,18 @@ void Player::OnLevelUp(){
stats . SetBaseStat ( " Health " , GetBaseStat ( " Health " ) + hpGrowthRate ) ;
stats . SetBaseStat ( " Attack " , GetBaseStat ( " Attack " ) + atkGrowthRate ) ;
Heal ( GetBaseStat ( " Health " ) ) ;
if ( SteamUserStats ( ) ) {
for ( auto & [ key , size ] : DATA . GetProperty ( " Achievement.Class Unlocks " ) ) {
datafile & unlock = DATA . GetProperty ( std : : format ( " Achievement.Class Unlocks.{} " , key ) ) ;
if ( classutils : : StringToClass ( unlock [ " Class Requirement " ] . GetString ( ) ) = = GetClass ( ) & &
Level ( ) - 1 < unlock [ " Level Requirement " ] . GetInt ( ) & &
Level ( ) = = unlock [ " Level Requirement " ] . GetInt ( ) ) {
SteamUserStats ( ) - > SetAchievement ( unlock [ " API Name " ] . GetString ( ) . c_str ( ) ) ;
SteamUserStats ( ) - > StoreStats ( ) ;
}
}
}
}
const uint8_t Player : : LevelCap ( ) const {
return levelCap ;