Add weapon total pull

pull/1/head
Made Baruna 2022-07-28 21:09:11 +07:00
parent c8371dc7e5
commit 0ebc67c49f
4 changed files with 52 additions and 1 deletions

View File

@ -179,6 +179,7 @@
'wish-counter-beginners',
'wish-uid',
'characters',
'weapons',
'achievement',
'collectables-updated',
'furnishing',
@ -220,6 +221,7 @@
'wish-counter-beginners',
'wish-uid',
'characters',
'weapons',
'achievement',
'collectables-updated',
'furnishing',
@ -264,6 +266,7 @@
'wish-counter-beginners',
'wish-uid',
'characters',
'weapons',
'achievement',
'collectables-updated',
'furnishing',

View File

@ -8,11 +8,15 @@
import TableHeader from '../../components/Table/TableHeader.svelte';
import { formatStat } from '../../helper';
import Ad from '../../components/Ad.svelte';
import { getAccountPrefix } from '../../stores/account';
import { readSave } from '../../stores/saveManager';
let weaponData = data;
let weaponList = [];
let sortBy = 'name';
let sortOrder = true;
let showCount = false;
let counts = {};
const rarity = {
2: 'text-green-400',
@ -86,9 +90,24 @@
} else {
return b.secondary.localeCompare(a.secondary);
}
case 'pull':
if (sortOrder) {
return (counts[a.id]?.wish || 0) - (counts[b.id]?.wish || 0);
} else {
return (counts[b.id]?.wish || 0) - (counts[a.id]?.wish || 0);
}
}
});
async function getPullCount() {
const prefix = getAccountPrefix();
const data = await readSave(`${prefix}weapons`);
if (data !== null) {
counts = data;
showCount = true;
}
}
async function changeLocale(locale) {
const _data = await import(`../../data/weapons/${locale}.json`);
weaponData = _data.default;
@ -96,6 +115,7 @@
}
onMount(async () => {
getPullCount();
locale.subscribe((val) => {
changeLocale(val);
});
@ -133,6 +153,11 @@
<TableHeader on:click={() => sort('secondary')} sort={sortBy === 'secondary'} order={sortOrder}>
{$t('weapon.secondary')}
</TableHeader>
{#if showCount}
<TableHeader on:click={() => sort('pull')} sort={sortBy === 'pull'} order={sortOrder}>
{$t('wish.rank.totalPull')}
</TableHeader>
{/if}
</thead>
<tbody class="text-white">
{#each weapons as weapon (weapon.id)}
@ -163,6 +188,11 @@
<td class="border-gray-700 border-t py-1 pl-4">
{weapon.secondary}
</td>
{#if showCount}
<td class="border-gray-700 border-t py-1 pl-4 text-center">
{counts[weapon.id]?.wish || ''}
</td>
{/if}
</tr>
</a>
{/each}

View File

@ -93,6 +93,7 @@
// collected characters stuff
let updateCollectedCharacters = false;
let collectedCharacters = {};
let collectedWeapons = {};
const collectedCharactersData = await readSave(`${prefix}characters`);
if (collectedCharactersData !== null) {
collectedCharacters = collectedCharactersData;
@ -154,6 +155,18 @@
rarity = weaponList[pull.id].rarity;
itemName = weaponList[pull.id].name;
currentType = 'weapon';
if (updateCollectedCharacters) {
if (collectedWeapons[pull.id]) {
collectedWeapons[pull.id].wish += 1;
} else {
collectedWeapons[pull.id] = {
default: 0,
manual: 0,
wish: 1,
};
}
}
}
const time = dayjs(pull.time).format('YYYY-MM');
@ -259,6 +272,7 @@
if (updateCollectedCharacters && totalWish > 0) {
console.log('updating collectables');
await updateSave(`${prefix}characters`, collectedCharacters);
await updateSave(`${prefix}weapons`, collectedWeapons);
await updateSave(`${prefix}collectables-updated`, false);
}

View File

@ -7,7 +7,11 @@ const IMAGE_CACHE = `cacheimg${IMAGE_CACHE_VER}`;
const IMAGE_URL = `${self.location.origin}/images/`;
const changelog = ['Add commissions location to achievement tracker', 'Adjust character detail page'];
const changelog = [
'Add total pull on weapon list page',
'Adjust wish counter layout for small resolution',
'Add commissions location to achievement tracker',
];
const channel = new BroadcastChannel('paimonmoe-sw');