Fix stats tab bugs, fixes #807

This commit is contained in:
SpectralFlame 2019-08-29 02:57:15 -05:00
parent 28f9053dd6
commit 792e847b3e
2 changed files with 24 additions and 16 deletions

View File

@ -191,8 +191,9 @@ EventHub.registerStateCollectionEvents(
);
class AchievementTimer {
constructor() {
constructor(isRealTime) {
this.time = 0;
this.realTime = isRealTime;
}
reset() {
@ -200,7 +201,10 @@ class AchievementTimer {
}
advance() {
this.time += Time.deltaTime;
const addedTime = this.realTime
? Time.unscaledDeltaTime.milliseconds / 1000
: Time.deltaTime;
this.time += addedTime;
}
check(condition, duration) {
@ -214,8 +218,8 @@ class AchievementTimer {
}
const AchievementTimers = {
marathon1: new AchievementTimer(),
marathon2: new AchievementTimer(),
pain: new AchievementTimer(),
stats: new AchievementTimer()
marathon1: new AchievementTimer(false),
marathon2: new AchievementTimer(false),
pain: new AchievementTimer(true),
stats: new AchievementTimer(true)
};

View File

@ -226,16 +226,20 @@ function ratePerMinute(amount, time) {
}
function averageRun(runs) {
let totalTime = runs
.map(run => run[0])
.reduce(Number.sumReducer);
let totalAmount = runs
.map(run => run[1])
.reduce(Decimal.sumReducer);
return [
totalTime / runs.length,
totalAmount.dividedBy(runs.length)
];
const totalTime = runs
.map(run => run[0])
.reduce(Number.sumReducer);
const totalAmount = runs
.map(run => run[1])
.reduce(Decimal.sumReducer);
const realTime = runs
.map(run => run[2])
.reduce(Number.sumReducer);
return [
totalTime / runs.length,
totalAmount.dividedBy(runs.length),
realTime / runs.length
];
}
function addInfinityTime(time, realTime, ip, infinities) {