mirror of
https://github.com/MadeBaruna/paimon-moe.git
synced 2025-03-13 11:18:28 +01:00
Add weapon total pull
This commit is contained in:
parent
c8371dc7e5
commit
0ebc67c49f
4 changed files with 52 additions and 1 deletions
|
@ -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',
|
||||
|
|
|
@ -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}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue