Add furnishing set material calculation
1
src/data/furnishing/materials/de.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Brocken Eisen","fragrant_cedar_wood":"Duftendes Zedernholz","white_iron_chunk":"Brocken weißes Eisen","fir_wood":"Tannenholz","red_dye":"Rote Farbe","blue_dye":"Blaue Farbe","birch_wood":"Birkenholz","sandbearer_wood":"Dürrsandholz","fabric":"Stoff","yellow_dye":"Gelbe Farbe","pine_wood":"Kiefernholz","cuihua_wood":"Exquisitholz","bamboo_segment":"Bambussegment","yumemiru_wood":"Yumemiru-Holz","maple_wood":"Ahornholz","otogi_wood":"Otogi-Holz","aralia_wood":"Aralia-Holz","realm_currency":"Kannentaler"}
|
1
src/data/furnishing/materials/en.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Iron Chunk","fragrant_cedar_wood":"Fragrant Cedar Wood","white_iron_chunk":"White Iron Chunk","fir_wood":"Fir Wood","red_dye":"Red Dye","blue_dye":"Blue Dye","birch_wood":"Birch Wood","sandbearer_wood":"Sandbearer Wood","fabric":"Fabric","yellow_dye":"Yellow Dye","pine_wood":"Pine Wood","cuihua_wood":"Cuihua Wood","bamboo_segment":"Bamboo Segment","yumemiru_wood":"Yumemiru Wood","maple_wood":"Maple Wood","otogi_wood":"Otogi Wood","aralia_wood":"Aralia Wood","realm_currency":"Realm Currency"}
|
1
src/data/furnishing/materials/es.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Pedazo de hierro","fragrant_cedar_wood":"Madera de cedro fragante","white_iron_chunk":"Pedazo de hierro blanco","fir_wood":"Madera de abeto","red_dye":"Tinte rojo","blue_dye":"Tinte azul","birch_wood":"Madera de abedul","sandbearer_wood":"Madera de avellano","fabric":"Tela","yellow_dye":"Tinte amarillo","pine_wood":"Madera de pino","cuihua_wood":"Madera de liquidámbar","bamboo_segment":"Segmento de bambú","yumemiru_wood":"Madera onírica","maple_wood":"Madera de arce","otogi_wood":"Madera de murmurador","aralia_wood":"Madera de criptomeria","realm_currency":"Intramora"}
|
1
src/data/furnishing/materials/fr.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Morceau de fer","fragrant_cedar_wood":"Bois de cèdre parfumé","white_iron_chunk":"Morceau de fer blanc","fir_wood":"Bois d'épicéa","red_dye":"Teinture rouge","blue_dye":"Teinture bleue","birch_wood":"Bois de bouleau","sandbearer_wood":"Bois d'haréna","fabric":"Tissu","yellow_dye":"Teinture jaune","pine_wood":"Bois de pin","cuihua_wood":"Bois d'exquisetier","bamboo_segment":"Tige de bambou","yumemiru_wood":"Bois de rêve","maple_wood":"Bois d'érable","otogi_wood":"Bois de dulcinier","aralia_wood":"Bois de cèdre inazumien","realm_currency":"Pièces du royaume"}
|
1
src/data/furnishing/materials/id.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Iron Chunk","fragrant_cedar_wood":"Fragrant Cedar Wood","white_iron_chunk":"White Iron Chunk","fir_wood":"Fir Wood","red_dye":"Red Dye","blue_dye":"Blue Dye","birch_wood":"Birch Wood","sandbearer_wood":"Sandbearer Wood","fabric":"Fabric","yellow_dye":"Yellow Dye","pine_wood":"Pine Wood","cuihua_wood":"Cuihua Wood","bamboo_segment":"Bamboo Segment","yumemiru_wood":"Yumemiru Wood","maple_wood":"Maple Wood","otogi_wood":"Otogi Wood","aralia_wood":"Aralia Wood","realm_currency":"Realm Currency"}
|
1
src/data/furnishing/materials/ja.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"鉄の塊","fragrant_cedar_wood":"垂香材","white_iron_chunk":"白鉄の塊","fir_wood":"杉材","red_dye":"赤色の染料","blue_dye":"青色の染料","birch_wood":"樺材","sandbearer_wood":"却砂材","fabric":"布材","yellow_dye":"黄色の染料","pine_wood":"松材","cuihua_wood":"萃華材","bamboo_segment":"竹材","yumemiru_wood":"夢見材","maple_wood":"楓材","otogi_wood":"御伽材","aralia_wood":"孔雀材","realm_currency":"洞天宝銭"}
|
1
src/data/furnishing/materials/ko.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"철광","fragrant_cedar_wood":"수향나무","white_iron_chunk":"백철","fir_wood":"삼나무","red_dye":"붉은색 염료","blue_dye":"파란색 염료","birch_wood":"자작나무","sandbearer_wood":"각사나무","fabric":"직물","yellow_dye":"노란색 염료","pine_wood":"소나무","cuihua_wood":"췌화나무","bamboo_segment":"죽절","yumemiru_wood":"꿈의 나무","maple_wood":"단풍나무","otogi_wood":"오토기나무 원목","aralia_wood":"공작나무 원목","realm_currency":"선계 화폐"}
|
1
src/data/furnishing/materials/pt.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Pedaço de Ferro","fragrant_cedar_wood":"Madeira de Cedro Fragrante","white_iron_chunk":"Pedaço de Ferro Branco","fir_wood":"Madeira de Abeto","red_dye":"Tinta Vermelha","blue_dye":"Tinta Azul","birch_wood":"Vidoeiro","sandbearer_wood":"Madeira de Areia","fabric":"Tecido","yellow_dye":"Tinta Amarela","pine_wood":"Pinheiro","cuihua_wood":"Madeira de Cuihua","bamboo_segment":"Segmento de Bambu","yumemiru_wood":"Madeira Yumemiru","maple_wood":"Bordo","otogi_wood":"Madeira Otogi","aralia_wood":"Madeira de Arália","realm_currency":"Moeda do Paraíso"}
|
1
src/data/furnishing/materials/ru.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Обломок железа","fragrant_cedar_wood":"Ароматный кедр","white_iron_chunk":"Обломок белого железа","fir_wood":"Пихта","red_dye":"Красная краска","blue_dye":"Синяя краска","birch_wood":"Берёза","sandbearer_wood":"Песчаное дерево","fabric":"Ткань","yellow_dye":"Жёлтая краска","pine_wood":"Сосна","cuihua_wood":"Цуйхуа","bamboo_segment":"Бамбук","yumemiru_wood":"Юмэмиру","maple_wood":"Клён","otogi_wood":"Отоги","aralia_wood":"Аралия","realm_currency":"Сокровища обители"}
|
1
src/data/furnishing/materials/th.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Iron Chunk","fragrant_cedar_wood":"ไม้หอม","white_iron_chunk":"White Iron Chunk","fir_wood":"ไม้สนหนาม","red_dye":"สีย้อมสีแดง","blue_dye":"สีย้อมสีฟ้า","birch_wood":"ไม้เบิร์ช","sandbearer_wood":"ไม้เนื้อทราย","fabric":"ผ้า","yellow_dye":"สีย้อมสีเหลือง","pine_wood":"ไม้สน","cuihua_wood":"ไม้ Cuihua","bamboo_segment":"ท่อนไม้ไผ่","yumemiru_wood":"ไม้ Yumemiru","maple_wood":"ไม้ Maple","otogi_wood":"ไม้ Otogi","aralia_wood":"ไม้ Aralia","realm_currency":"Realm Currency"}
|
1
src/data/furnishing/materials/tw.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"鐵塊","fragrant_cedar_wood":"垂香木","white_iron_chunk":"白鐵塊","fir_wood":"杉木","red_dye":"紅色染料","blue_dye":"藍色染料","birch_wood":"樺木","sandbearer_wood":"卻砂木","fabric":"布匹","yellow_dye":"黃色染料","pine_wood":"松木","cuihua_wood":"萃華木","bamboo_segment":"竹節","yumemiru_wood":"夢見木","maple_wood":"楓木","otogi_wood":"御伽木","aralia_wood":"孔雀木","realm_currency":"洞天寶錢"}
|
1
src/data/furnishing/materials/vi.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"Mảnh Sắt","fragrant_cedar_wood":"Gỗ Thùy Hương","white_iron_chunk":"Mảnh Sắt Trắng","fir_wood":"Gỗ Sam","red_dye":"Thuốc Nhuộm Đỏ","blue_dye":"Thuốc Nhuộm Lam","birch_wood":"Gỗ Hoa","sandbearer_wood":"Gỗ Khước Sa","fabric":"Vải Vóc","yellow_dye":"Thuốc Nhuộm Vàng","pine_wood":"Gỗ Thông","cuihua_wood":"Gỗ Tụy Hoa","bamboo_segment":"Đốt Trúc","yumemiru_wood":"Gỗ Mơ Mộng","maple_wood":"Gỗ Phong","otogi_wood":"Gỗ Otogi","aralia_wood":"Gỗ Khổng Tước","realm_currency":"Tiền Động Tiên"}
|
1
src/data/furnishing/materials/zh.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"iron_chunk":"铁块","fragrant_cedar_wood":"垂香木","white_iron_chunk":"白铁块","fir_wood":"杉木","red_dye":"红色染料","blue_dye":"蓝色染料","birch_wood":"桦木","sandbearer_wood":"却砂木","fabric":"布匹","yellow_dye":"黄色染料","pine_wood":"松木","cuihua_wood":"萃华木","bamboo_segment":"竹节","yumemiru_wood":"梦见木","maple_wood":"枫木","otogi_wood":"御伽木","aralia_wood":"孔雀木","realm_currency":"洞天宝钱"}
|
|
@ -857,7 +857,9 @@
|
|||
"setUnplaced": "Set as unplaced",
|
||||
"inInventory": "In inventory",
|
||||
"available": "Available",
|
||||
"used": "Used in other set"
|
||||
"used": "Used in other set",
|
||||
"calculate": "Calculate Materials",
|
||||
"exludeOwned": "Exclude owned furniture"
|
||||
}
|
||||
},
|
||||
"weapon": {
|
||||
|
|
108
src/routes/furnishing/_calculateModal.svelte
Normal file
|
@ -0,0 +1,108 @@
|
|||
<script>
|
||||
import { mdiClose } from '@mdi/js';
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
import { locale, t } from 'svelte-i18n';
|
||||
import Checkbox from '../../components/Checkbox.svelte';
|
||||
import Icon from '../../components/Icon.svelte';
|
||||
|
||||
export let set;
|
||||
export let furnishing;
|
||||
let materials;
|
||||
let result = [];
|
||||
let coins = 0;
|
||||
let exludeAll = true;
|
||||
|
||||
console.log(set);
|
||||
|
||||
function calculate() {
|
||||
if (materials === undefined) return;
|
||||
|
||||
const items = Object.entries(set.items);
|
||||
const needed = set.needed;
|
||||
|
||||
result = [];
|
||||
coins = 0;
|
||||
|
||||
const final = {};
|
||||
for (const [item, amount] of items) {
|
||||
const needs = exludeAll ? needed[item] : amount;
|
||||
if (needs <= 0) continue;
|
||||
|
||||
const furn = furnishing[item];
|
||||
if (furn.recipe !== undefined) {
|
||||
for (const f of furn.recipe) {
|
||||
if (final[f.id] === undefined) {
|
||||
final[f.id] = 0;
|
||||
}
|
||||
|
||||
final[f.id] += f.amount * needs;
|
||||
}
|
||||
} else if (furn.cost !== undefined) {
|
||||
coins += furn.cost;
|
||||
}
|
||||
}
|
||||
|
||||
result = Object.entries(final);
|
||||
}
|
||||
|
||||
async function start() {
|
||||
materials = (await import(`../../data/furnishing/materials/${$locale}.json`)).default;
|
||||
calculate();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
start();
|
||||
});
|
||||
|
||||
$: exludeAll, calculate();
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<p class="text-white font-bold mb-4 text-lg">{set.name}</p>
|
||||
<table class="mb-2 w-full">
|
||||
{#each result as [item, amount], i}
|
||||
<tr>
|
||||
<td class="text-right border-gray-700 py-1 {i === 0 ? '' : 'border-t'}">
|
||||
<span class="text-white mr-2 whitespace-no-wrap">
|
||||
{amount}
|
||||
<Icon size={0.5} path={mdiClose} />
|
||||
</span>
|
||||
</td>
|
||||
<td class="border-gray-700 py-1 {i === 0 ? '' : 'border-t'}">
|
||||
<span class="text-white">
|
||||
<span class="w-6 inline-block">
|
||||
<img class="h-6 inline-block mr-1" src="/images/items/{item}.png" alt={materials[item]} />
|
||||
</span>
|
||||
{materials[item]}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{/each}
|
||||
{#if coins > 0}
|
||||
<tr>
|
||||
<td class="text-right border-t border-gray-700 py-1">
|
||||
<span class="text-white mr-2 whitespace-no-wrap">
|
||||
{coins}
|
||||
<Icon size={0.5} path={mdiClose} />
|
||||
</span>
|
||||
</td>
|
||||
<td class="border-t border-gray-700 py-1">
|
||||
<span class="text-white">
|
||||
<span class="w-6 inline-block">
|
||||
<img
|
||||
class="h-6 inline-block mr-1"
|
||||
src="/images/items/realm_currency.png"
|
||||
alt={materials['realm_currency']}
|
||||
/>
|
||||
</span>
|
||||
{materials['realm_currency']}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</table>
|
||||
<Checkbox bind:checked={exludeAll}>
|
||||
<p class="text-white">{$t('furnishing.sets.exludeOwned')}</p>
|
||||
</Checkbox>
|
||||
</div>
|
|
@ -9,14 +9,17 @@
|
|||
<script>
|
||||
import { locale, t } from 'svelte-i18n';
|
||||
import debounce from 'lodash/debounce';
|
||||
import { mdiCheckCircleOutline, mdiClose } from '@mdi/js';
|
||||
|
||||
import Button from '../../components/Button.svelte';
|
||||
import CharacterSelect from '../../components/CharacterSelect.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import { getContext, onMount } from 'svelte';
|
||||
import Icon from '../../components/Icon.svelte';
|
||||
import { mdiCheckCircleOutline, mdiClose } from '@mdi/js';
|
||||
import { getAccountPrefix } from '../../stores/account';
|
||||
import { readSave, updateSave } from '../../stores/saveManager';
|
||||
import CalculateModal from './_calculateModal.svelte';
|
||||
|
||||
const { open: openModal } = getContext('simple-modal');
|
||||
|
||||
export let data;
|
||||
export let setsData;
|
||||
|
@ -51,6 +54,7 @@
|
|||
|
||||
for (const set of setsData.sort((a, b) => b.gift - a.gift)) {
|
||||
set.enough = {};
|
||||
set.needed = {};
|
||||
set.canBePlaced = true;
|
||||
|
||||
for (const [item, amount] of Object.entries(set.items)) {
|
||||
|
@ -59,6 +63,7 @@
|
|||
enough = saved[item] >= amount;
|
||||
}
|
||||
|
||||
set.needed[item] = amount - (saved[item] || 0);
|
||||
set.enough[item] = enough;
|
||||
if (!enough) set.canBePlaced = false;
|
||||
}
|
||||
|
@ -103,6 +108,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
function calculate(index) {
|
||||
openModal(
|
||||
CalculateModal,
|
||||
{
|
||||
set: sets[index],
|
||||
furnishing: data,
|
||||
},
|
||||
{
|
||||
closeButton: false,
|
||||
styleWindow: { background: '#25294A', width: '400px' },
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async function changeLocale(locale) {
|
||||
data = (await import(`../../data/furnishing/${locale}.json`)).default;
|
||||
setsData = (await import(`../../data/furnishing/sets/${locale}.json`)).default;
|
||||
|
@ -156,16 +175,13 @@
|
|||
※ {$t('furnishing.sets.subtitle')}
|
||||
</p>
|
||||
<div class="w-full md:w-64">
|
||||
<CharacterSelect
|
||||
bind:selected={charFilter}
|
||||
placeholder={$t('furnishing.selectCharacter')}
|
||||
/>
|
||||
<CharacterSelect bind:selected={charFilter} placeholder={$t('furnishing.selectCharacter')} />
|
||||
</div>
|
||||
<div
|
||||
class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-2 xl:grid-cols-4 gap-2 flex-1 mt-2"
|
||||
style="height: fit-content;"
|
||||
>
|
||||
{#each sets as set (set.id)}
|
||||
{#each sets as set, i (set.id)}
|
||||
{#if charFilter === null || (charFilter !== null && set.characters && set.characters.includes(charFilter.id))}
|
||||
<div class="text-white p-2 rounded-xl flex flex-col bg-item">
|
||||
<div class="w-full flex items-center justify-center relative">
|
||||
|
@ -247,6 +263,9 @@
|
|||
{/each}
|
||||
</div>
|
||||
<div class="flex-1" />
|
||||
<Button className="mt-2" on:click={() => calculate(i)}>
|
||||
{$t('furnishing.sets.calculate')}
|
||||
</Button>
|
||||
<Button className="mt-2" disabled={!set.canBePlaced} on:click={() => place(set.id)}>
|
||||
{placed[set.id] ? $t('furnishing.sets.setUnplaced') : $t('furnishing.sets.setPlaced')}
|
||||
</Button>
|
||||
|
|
BIN
static/images/items/aralia_wood.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
static/images/items/bamboo_segment.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
static/images/items/birch_wood.png
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
static/images/items/blue_dye.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
static/images/items/cuihua_wood.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
static/images/items/fabric.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
static/images/items/fir_wood.png
Normal file
After Width: | Height: | Size: 62 KiB |
BIN
static/images/items/fragrant_cedar_wood.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
static/images/items/iron_chunk.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
static/images/items/maple_wood.png
Normal file
After Width: | Height: | Size: 58 KiB |
BIN
static/images/items/otogi_wood.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
static/images/items/pine_wood.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
static/images/items/realm_currency.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
static/images/items/red_dye.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
static/images/items/sandbearer_wood.png
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
static/images/items/white_iron_chunk.png
Normal file
After Width: | Height: | Size: 50 KiB |
BIN
static/images/items/yellow_dye.png
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
static/images/items/yumemiru_wood.png
Normal file
After Width: | Height: | Size: 62 KiB |