Sort calculation result

pull/1/head
Made Baruna 2022-08-24 00:12:41 +07:00
parent 3a6907e377
commit 929d0a6668
2 changed files with 12 additions and 4 deletions

View File

@ -70,6 +70,8 @@
let moraNeeded = 0;
let changed = false;
let calcResult = [];
let currentTalentLevel = {
first: 1,
second: 1,
@ -223,7 +225,7 @@
}
if (items[item.item.id] === undefined) {
items[item.item.id] = { ...item.item, amount: 0 };
items[item.item.id] = { ...item.item, amount: 0, order: i };
}
items[item.item.id].amount += item.amount;
}
@ -424,6 +426,8 @@
}
}
calcResult = Object.entries(ascensionResouce).sort((a, b) => a[1].order - b[1].order);
changed = false;
}
@ -650,7 +654,7 @@
</tr>
{/if}
{/each}
{#each Object.entries(ascensionResouce) as [id, item]}
{#each calcResult as [id, item]}
{#if item.amount > 0}
<tr>
<td class="text-right border-b border-gray-700 py-1">

View File

@ -96,6 +96,8 @@
let moraNeeded = 0;
let changed = false;
let calcResult = [];
let numberFormat = Intl.NumberFormat();
$: usedResource = resources.filter((e) => e.selected).sort((a, b) => b.value - a.value);
@ -198,7 +200,7 @@
}
if (items[item.item.id] === undefined) {
items[item.item.id] = { ...item.item, amount: 0 };
items[item.item.id] = { ...item.item, amount: 0, order: i };
}
items[item.item.id].amount += item.amount;
}
@ -287,6 +289,8 @@
calculateAscension();
}
calcResult = Object.entries(ascensionResouce).sort((a, b) => a[1].order - b[1].order);
changed = false;
}
@ -459,7 +463,7 @@
</tr>
{/if}
{/each}
{#each Object.entries(ascensionResouce) as [id, item]}
{#each calcResult as [id, item]}
{#if item.amount > 0}
<tr>
<td class="text-right border-b border-gray-700 py-1">