Allow lowering constellation count with auto import wishes

This commit is contained in:
nicospz 2021-07-24 01:26:54 +09:00
parent 0ec40e02eb
commit b7c6659e04

View file

@ -77,7 +77,7 @@
let chars = {}; let chars = {};
let constellationCount = -1; let constellationCount = -1;
let manualCount = 0; let manualCount = 0;
let editConstallation = false; let editConstellation = false;
const showedIndex = [1, 20, 21, 41, 42, 52, 53, 63, 64, 74, 75, 85, 86, 96]; const showedIndex = [1, 20, 21, 41, 42, 52, 53, 63, 64, 74, 75, 85, 86, 96];
const level = [1, 20, 20, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90]; const level = [1, 20, 20, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90];
@ -99,11 +99,11 @@
} }
function editConstellationCount(val) { function editConstellationCount(val) {
manualCount = Math.max(0, manualCount + val); manualCount = Math.max(manualCount + val);
} }
async function saveConstellationCount() { async function saveConstellationCount() {
editConstallation = false; editConstellation = false;
if (chars[id]) { if (chars[id]) {
chars[id].manual = manualCount; chars[id].manual = manualCount;
} else if (defaultChars[id]) { } else if (defaultChars[id]) {
@ -135,7 +135,7 @@
await getConstellationCount(); await getConstellationCount();
}); });
$: constellationCountTotal = constellationCount + manualCount; $: constellationCountTotal = Math.max(0, constellationCount + manualCount);
</script> </script>
<svelte:head> <svelte:head>
@ -164,13 +164,13 @@
src="/images/elements/{character.element.id}.png" src="/images/elements/{character.element.id}.png"
alt={character.element.name} alt={character.element.name}
/> />
<div class="flex space-y-1 lg:space-y-0 lg:space-x-1 {editConstallation ? 'flex-col' : ''} md:flex-row items-center"> <div class="flex space-y-1 lg:space-y-0 lg:space-x-1 {editConstellation ? 'flex-col' : ''} md:flex-row items-center">
{#if constellationCountTotal > -1} {#if constellationCountTotal > -1}
<p class="text-3xl text-gray-200 bg-black bg-opacity-50 rounded-xl px-2 font-semibold"> <p class="text-3xl text-gray-200 bg-black bg-opacity-50 rounded-xl px-2 font-semibold">
C{constellationCountTotal} C{constellationCountTotal}
</p> </p>
{/if} {/if}
{#if editConstallation} {#if editConstellation}
<div class="flex flex-wrap space-x-1"> <div class="flex flex-wrap space-x-1">
<Button size="sm" on:click={() => editConstellationCount(1)}> <Button size="sm" on:click={() => editConstellationCount(1)}>
<Icon path={mdiPlus} /> <Icon path={mdiPlus} />
@ -186,7 +186,7 @@
<div <div
class="ml-2 rounded-xl hover:bg-black hover:bg-opacity-25 cursor-pointer p-2" class="ml-2 rounded-xl hover:bg-black hover:bg-opacity-25 cursor-pointer p-2"
on:click={() => { on:click={() => {
editConstallation = true; editConstellation = true;
}} }}
> >
<Icon path={mdiPencil} className="text-gray-400" /> <Icon path={mdiPencil} className="text-gray-400" />