31 lines
904 B
C++
31 lines
904 B
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Profession.h"
|
|
|
|
UProfession::UProfession() {
|
|
//Rounding exp so that the first 2 digits remain, the rest is rounded to 0
|
|
ExpTable.Add(100);
|
|
for (int i = 1; i < MaxProfessionLevel; i++) {
|
|
const int32 expToInsert = ExpTable[i - 1] * ScalingMultiplier;
|
|
const int32 numberOfSpaces = log10(expToInsert) + 1;
|
|
const int32 remainder = expToInsert % (int32)pow(10, numberOfSpaces - 2);
|
|
ExpTable.Add(expToInsert - remainder);
|
|
}
|
|
}
|
|
|
|
void UProfession::AddProfessionExp(int32 amount) {
|
|
if(Level == MaxProfessionLevel && CurrentExp == ExpTable[MaxProfessionLevel])
|
|
return;
|
|
|
|
CurrentExp += amount;
|
|
if(CurrentExp >= ExpTable[Level]) {
|
|
CurrentExp -= ExpTable[Level];
|
|
Level++;
|
|
}
|
|
if(Level > MaxProfessionLevel)
|
|
Level = MaxProfessionLevel;
|
|
if(CurrentExp > ExpTable[Level])
|
|
CurrentExp = ExpTable[Level];
|
|
}
|