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.
20 lines
582 B
20 lines
582 B
import type { StatValueInput } from "$lib/models/stat";
|
|
|
|
export function statDiff(before: StatValueInput[], after: StatValueInput[], deleteValue = 0): StatValueInput[] {
|
|
let res: StatValueInput[] = [];
|
|
|
|
for (const s of before) {
|
|
if (!after.find(s2 => s2.statId === s.statId)) {
|
|
res.push({statId: s.statId, acquired: 0, required: deleteValue})
|
|
}
|
|
}
|
|
|
|
for (const s of after) {
|
|
const old = before.find(s2 => s2.statId === s.statId);
|
|
if (old == null || old.required != s.required || old.acquired != s.acquired) {
|
|
res.push(s);
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|