You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
10 lines
396 B
10 lines
396 B
import type { StatAggregate, StatProgressEntry } from "$lib/models/stat";
|
|
|
|
export function calculateAggregate(entries: StatProgressEntry[]): StatAggregate {
|
|
return entries.reduce<StatAggregate>((acc, entry) => {
|
|
return {
|
|
acquired: acc.acquired + (entry.acquired * entry.weight),
|
|
required: acc.required + (entry.required * entry.weight),
|
|
}
|
|
}, {acquired: 0, required: 0});
|
|
}
|