parent
086ed376eb
commit
d14fe3f972
|
@ -1,38 +0,0 @@
|
||||||
import { getAccountPrefix } from "../stores/account";
|
|
||||||
import { readSave, updateSave } from "../stores/saveManager";
|
|
||||||
|
|
||||||
const bannerCategories = ['beginners', 'standard', 'character-event', 'weapon-event'];
|
|
||||||
|
|
||||||
function readLocalData(path) {
|
|
||||||
const prefix = getAccountPrefix();
|
|
||||||
const data = readSave(`${prefix}${path}`);
|
|
||||||
if (data !== null) {
|
|
||||||
const counterData = JSON.parse(data);
|
|
||||||
const pullData = counterData.pulls || [];
|
|
||||||
|
|
||||||
return pullData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function processCharacters() {
|
|
||||||
const characters = {};
|
|
||||||
for (const id of bannerCategories) {
|
|
||||||
const data = readLocalData(`wish-counter-${id}`);
|
|
||||||
if (data === null) continue;
|
|
||||||
|
|
||||||
for (const item of data) {
|
|
||||||
if (item.type === 'character') {
|
|
||||||
if (characters[item.id] === undefined) {
|
|
||||||
characters[item.id] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
characters[item.id]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const prefix = getAccountPrefix();
|
|
||||||
updateSave(`${prefix}characters`, JSON.stringify(characters));
|
|
||||||
}
|
|
|
@ -17,7 +17,7 @@
|
||||||
import Icon from '../../components/Icon.svelte';
|
import Icon from '../../components/Icon.svelte';
|
||||||
import Button from '../../components/Button.svelte';
|
import Button from '../../components/Button.svelte';
|
||||||
import { getAccountPrefix } from '../../stores/account';
|
import { getAccountPrefix } from '../../stores/account';
|
||||||
import { readSave } from '../../stores/saveManager';
|
import { readSave, updateSave } from '../../stores/saveManager';
|
||||||
import { characters } from '../../data/characters';
|
import { characters } from '../../data/characters';
|
||||||
import { itemGroup } from '../../data/itemGroup';
|
import { itemGroup } from '../../data/itemGroup';
|
||||||
|
|
||||||
|
@ -26,6 +26,44 @@
|
||||||
|
|
||||||
let constellationDiv;
|
let constellationDiv;
|
||||||
|
|
||||||
|
const defaultChars = {
|
||||||
|
amber: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
kaeya: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
lisa: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
traveler_geo: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
traveler_anemo: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
barbara: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
xiangling: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const numberFormat = Intl.NumberFormat('en', {
|
const numberFormat = Intl.NumberFormat('en', {
|
||||||
maximumFractionDigits: 2,
|
maximumFractionDigits: 2,
|
||||||
minimumFractionDigits: 0,
|
minimumFractionDigits: 0,
|
||||||
|
@ -36,6 +74,7 @@
|
||||||
const book = itemGroup[bookId];
|
const book = itemGroup[bookId];
|
||||||
const materials = character.ascension[1].items;
|
const materials = character.ascension[1].items;
|
||||||
|
|
||||||
|
let chars = {};
|
||||||
let constellationCount = -1;
|
let constellationCount = -1;
|
||||||
let manualCount = 0;
|
let manualCount = 0;
|
||||||
let editConstallation = false;
|
let editConstallation = false;
|
||||||
|
@ -49,11 +88,12 @@
|
||||||
const data = readSave(`${prefix}characters`);
|
const data = readSave(`${prefix}characters`);
|
||||||
if (data !== null) {
|
if (data !== null) {
|
||||||
const constellation = JSON.parse(data);
|
const constellation = JSON.parse(data);
|
||||||
|
chars = constellation;
|
||||||
if (constellation[id]) {
|
if (constellation[id]) {
|
||||||
constellationCount = constellationCount[id].default + constellationCount[id].wish - 1;
|
constellationCount = constellation[id].default + constellation[id].wish - 1;
|
||||||
manualCount = constellationCount[id].manual;
|
manualCount = constellation[id].manual;
|
||||||
} else {
|
} else {
|
||||||
constellationCount = 0;
|
constellationCount = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +104,27 @@
|
||||||
|
|
||||||
function saveConstellationCount() {
|
function saveConstellationCount() {
|
||||||
editConstallation = false;
|
editConstallation = false;
|
||||||
|
if (chars[id]) {
|
||||||
|
chars[id].manual = manualCount;
|
||||||
|
} else if (defaultChars[id]) {
|
||||||
|
chars[id] = {
|
||||||
|
...defaultChars[id],
|
||||||
|
manual: manualCount,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
chars[id] = {
|
||||||
|
default: 0,
|
||||||
|
wish: 0,
|
||||||
|
manual: manualCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chars[id].default + chars[id].wish + chars[id].manual === 0) {
|
||||||
|
delete chars[id];
|
||||||
|
}
|
||||||
|
|
||||||
|
const prefix = getAccountPrefix();
|
||||||
|
updateSave(`${prefix}characters`, JSON.stringify(chars));
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollToView(view) {
|
function scrollToView(view) {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import { characters } from '../../data/characters';
|
import { characters } from '../../data/characters';
|
||||||
import { getAccountPrefix } from '../../stores/account';
|
import { getAccountPrefix } from '../../stores/account';
|
||||||
import { readSave } from '../../stores/saveManager';
|
import { readSave, updateSave } from '../../stores/saveManager';
|
||||||
|
|
||||||
let sortBy = '';
|
let sortBy = '';
|
||||||
let sortOrder = false;
|
let sortOrder = false;
|
||||||
|
@ -71,12 +71,82 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function processWishes() {
|
||||||
|
const chars = {
|
||||||
|
amber: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
kaeya: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
lisa: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
traveler_geo: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
traveler_anemo: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
barbara: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
xiangling: {
|
||||||
|
default: 1,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const bannerCategories = ['beginners', 'standard', 'character-event', 'weapon-event'];
|
||||||
|
const prefix = getAccountPrefix();
|
||||||
|
for (const id of bannerCategories) {
|
||||||
|
const data = readSave(`${prefix}wish-counter-${id}`);
|
||||||
|
if (data !== null) {
|
||||||
|
showConstellation = true;
|
||||||
|
const counterData = JSON.parse(data);
|
||||||
|
const pullData = counterData.pulls || [];
|
||||||
|
for (const pull of pullData) {
|
||||||
|
if (pull.type === 'character') {
|
||||||
|
if (chars[pull.id] === undefined) {
|
||||||
|
chars[pull.id] = {
|
||||||
|
default: 0,
|
||||||
|
wish: 0,
|
||||||
|
manual: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
chars[pull.id].wish++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showConstellation) {
|
||||||
|
constellation = chars;
|
||||||
|
updateSave(`${prefix}characters`, JSON.stringify(chars));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getConstellation() {
|
function getConstellation() {
|
||||||
const prefix = getAccountPrefix();
|
const prefix = getAccountPrefix();
|
||||||
const data = readSave(`${prefix}characters`);
|
const data = readSave(`${prefix}characters`);
|
||||||
if (data !== null) {
|
if (data !== null) {
|
||||||
constellation = JSON.parse(data);
|
constellation = JSON.parse(data);
|
||||||
showConstellation = true;
|
showConstellation = true;
|
||||||
|
} else {
|
||||||
|
processWishes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +214,7 @@
|
||||||
>
|
>
|
||||||
{#if constellation[id]}
|
{#if constellation[id]}
|
||||||
<span class="mx-1 text-white text-xs font-semibold">
|
<span class="mx-1 text-white text-xs font-semibold">
|
||||||
C{Math.min(constellation[id] - 1, 6)}
|
C{Math.max(0, (constellation[id].default + constellation[id].wish + constellation[id].manual) - 1)}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
<img class="w-4 h-4" src={`/images/elements/${char.element.id}.png`} alt={char.element.name} />
|
<img class="w-4 h-4" src={`/images/elements/${char.element.id}.png`} alt={char.element.name} />
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import { bannerTypes } from '../../data/bannerTypes';
|
import { bannerTypes } from '../../data/bannerTypes';
|
||||||
|
|
||||||
import { getAccountPrefix } from '../../stores/account';
|
import { getAccountPrefix } from '../../stores/account';
|
||||||
import { readSave, updateTime, fromRemote } from '../../stores/saveManager';
|
import { readSave, updateTime, fromRemote, updateSave } from '../../stores/saveManager';
|
||||||
import SummaryItem from './_summaryItem.svelte';
|
import SummaryItem from './_summaryItem.svelte';
|
||||||
import Icon from '../../components/Icon.svelte';
|
import Icon from '../../components/Icon.svelte';
|
||||||
import { mdiEarth } from '@mdi/js';
|
import { mdiEarth } from '@mdi/js';
|
||||||
|
@ -43,6 +43,18 @@
|
||||||
|
|
||||||
monthlyData = {};
|
monthlyData = {};
|
||||||
|
|
||||||
|
// collected characters stuff
|
||||||
|
let updateCollectedCharacters = false;
|
||||||
|
let collectedCharacters = {};
|
||||||
|
const collectedCharactersData = readSave(`${prefix}characters`);
|
||||||
|
if (collectedCharactersData !== null) {
|
||||||
|
collectedCharacters = JSON.parse(collectedCharactersData);
|
||||||
|
for (const collectedId of Object.keys(collectedCharacters)) {
|
||||||
|
collectedCharacters[collectedId].wish = 0;
|
||||||
|
}
|
||||||
|
updateCollectedCharacters = true;
|
||||||
|
}
|
||||||
|
|
||||||
for (let type of types) {
|
for (let type of types) {
|
||||||
const path = `wish-counter-${type.id}`;
|
const path = `wish-counter-${type.id}`;
|
||||||
const data = readSave(`${prefix}${path}`);
|
const data = readSave(`${prefix}${path}`);
|
||||||
|
@ -70,6 +82,19 @@
|
||||||
rarity = characters[pull.id].rarity;
|
rarity = characters[pull.id].rarity;
|
||||||
itemName = characters[pull.id].name;
|
itemName = characters[pull.id].name;
|
||||||
currentType = 'character';
|
currentType = 'character';
|
||||||
|
|
||||||
|
// collected characters stuff
|
||||||
|
if (updateCollectedCharacters) {
|
||||||
|
if (collectedCharacters[pull.id]) {
|
||||||
|
collectedCharacters[pull.id].wish += 1;
|
||||||
|
} else {
|
||||||
|
collectedCharacters[pull.id] = {
|
||||||
|
default: 0,
|
||||||
|
manual: 0,
|
||||||
|
wish: 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (pull.type === 'weapon') {
|
} else if (pull.type === 'weapon') {
|
||||||
rarity = weaponList[pull.id].rarity;
|
rarity = weaponList[pull.id].rarity;
|
||||||
itemName = weaponList[pull.id].name;
|
itemName = weaponList[pull.id].name;
|
||||||
|
@ -134,6 +159,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updateCollectedCharacters) {
|
||||||
|
updateSave(`${prefix}characters`, JSON.stringify(collectedCharacters));
|
||||||
|
}
|
||||||
|
|
||||||
console.log(avg);
|
console.log(avg);
|
||||||
loading = false;
|
loading = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue