|
|
@ -5,26 +5,41 @@ import Amount from "../common/Amount.svelte"; |
|
|
|
import { getScopeContext } from "../contexts/ScopeContext.svelte"; |
|
|
|
|
|
|
|
export let items: Item[]; |
|
|
|
export let totalAcquired: number; |
|
|
|
export let aggregateRequired: number; |
|
|
|
export let totalAcquired: number = null; |
|
|
|
export let aggregateRequired: number = null; |
|
|
|
|
|
|
|
const {scope} = getScopeContext(); |
|
|
|
|
|
|
|
let amounts: {name: string, amount: number}[] = []; |
|
|
|
let total; |
|
|
|
let required; |
|
|
|
|
|
|
|
$: { |
|
|
|
const statMap: Record<number, number> = {}; |
|
|
|
|
|
|
|
total = 0; |
|
|
|
required = 0; |
|
|
|
|
|
|
|
for (const item of items) { |
|
|
|
for (const stat of item.stats) { |
|
|
|
statMap[stat.id] = (statMap[stat.id] || 0) + stat.acquired |
|
|
|
statMap[stat.id] = (statMap[stat.id] || 0) + stat.acquired; |
|
|
|
required += stat.required * stat.weight; |
|
|
|
total += stat.acquired * stat.weight; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (totalAcquired != null) { |
|
|
|
total = totalAcquired; |
|
|
|
} |
|
|
|
if (aggregateRequired != null) { |
|
|
|
required = aggregateRequired; |
|
|
|
} |
|
|
|
|
|
|
|
amounts = []; |
|
|
|
for (const stat of $scope.stats) { |
|
|
|
if (!!statMap[stat.id]) { |
|
|
|
amounts.push({name: stat.name, amount: statMap[stat.id]}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -34,5 +49,5 @@ import Amount from "../common/Amount.svelte"; |
|
|
|
{#each amounts as {name, amount} (name)} |
|
|
|
<Amount label={name} value={amount} /> |
|
|
|
{/each} |
|
|
|
<Amount weighted right label="" dark value={totalAcquired} target={aggregateRequired} /> |
|
|
|
<Amount weighted right label="" dark value={total} target={required} /> |
|
|
|
</AmountRow> |