update mine 4
This commit is contained in:
parent
c961711408
commit
401c16ddab
@ -4,7 +4,7 @@
|
|||||||
Produktionsanzeige + Abholen-Button
|
Produktionsanzeige + Abholen-Button
|
||||||
================================ */
|
================================ */
|
||||||
|
|
||||||
/* showNotification() kommt aus dem globalen Scope (launcher.ejs) */
|
/* window.showNotification() kommt aus dem globalen Scope (launcher.ejs) */
|
||||||
|
|
||||||
export async function loadMine(buildingId) {
|
export async function loadMine(buildingId) {
|
||||||
const actionsTab = document.getElementById("tab-actions");
|
const actionsTab = document.getElementById("tab-actions");
|
||||||
@ -34,18 +34,7 @@ async function renderMineStatus(buildingId) {
|
|||||||
const minutesLeft = Math.floor(data.next_cycle_in_seconds / 60);
|
const minutesLeft = Math.floor(data.next_cycle_in_seconds / 60);
|
||||||
const secondsLeft = data.next_cycle_in_seconds % 60;
|
const secondsLeft = data.next_cycle_in_seconds % 60;
|
||||||
|
|
||||||
/* Produktion pro Zyklus */
|
/* Ressourcen-Zeilen */
|
||||||
const cycleMinutes = Math.floor((data.cycle_seconds ?? 3600) / 60);
|
|
||||||
const productionRows = (data.production ?? [])
|
|
||||||
.map((r) => `
|
|
||||||
<div class="mine-resource-row">
|
|
||||||
<span class="mine-resource-icon">${resourceIcon(r.resource)}</span>
|
|
||||||
<span class="mine-resource-label">${resourceLabel(r.resource)}</span>
|
|
||||||
<span class="mine-resource-amount">+${r.amount} / ${cycleMinutes}min</span>
|
|
||||||
</div>`)
|
|
||||||
.join("");
|
|
||||||
|
|
||||||
/* Abgebaut (bereit zum Abholen) */
|
|
||||||
const resourceRows = data.available
|
const resourceRows = data.available
|
||||||
.map((r) => {
|
.map((r) => {
|
||||||
const icon = resourceIcon(r.resource);
|
const icon = resourceIcon(r.resource);
|
||||||
@ -70,13 +59,6 @@ async function renderMineStatus(buildingId) {
|
|||||||
|
|
||||||
<div class="mine-divider"></div>
|
<div class="mine-divider"></div>
|
||||||
|
|
||||||
<p class="mine-section-title">Produktion pro Zyklus</p>
|
|
||||||
<div class="mine-resources">
|
|
||||||
${productionRows}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mine-divider"></div>
|
|
||||||
|
|
||||||
<p class="mine-section-title">Abgebaut</p>
|
<p class="mine-section-title">Abgebaut</p>
|
||||||
<div class="mine-resources">
|
<div class="mine-resources">
|
||||||
${resourceRows}
|
${resourceRows}
|
||||||
@ -131,7 +113,7 @@ document.addEventListener("click", async (e) => {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
||||||
if (data.error) {
|
if (data.error) {
|
||||||
showNotification(
|
window.showNotification(
|
||||||
data.ready_in_display
|
data.ready_in_display
|
||||||
? `Die Mine ist noch nicht bereit.\nBereit in: ${data.ready_in_display}`
|
? `Die Mine ist noch nicht bereit.\nBereit in: ${data.ready_in_display}`
|
||||||
: data.error,
|
: data.error,
|
||||||
@ -147,7 +129,7 @@ document.addEventListener("click", async (e) => {
|
|||||||
.map((c) => `${resourceIcon(c.resource)} ${resourceLabel(c.resource)}: +${c.amount}`)
|
.map((c) => `${resourceIcon(c.resource)} ${resourceLabel(c.resource)}: +${c.amount}`)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
showNotification(
|
window.showNotification(
|
||||||
`Erfolgreich abgeholt!\n\n${lines}`,
|
`Erfolgreich abgeholt!\n\n${lines}`,
|
||||||
"Mine",
|
"Mine",
|
||||||
"⛏️"
|
"⛏️"
|
||||||
@ -157,7 +139,7 @@ document.addEventListener("click", async (e) => {
|
|||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Abholen Fehler:", err);
|
console.error("Abholen Fehler:", err);
|
||||||
showNotification(
|
window.showNotification(
|
||||||
"Fehler beim Abholen. Bitte erneut versuchen.",
|
"Fehler beim Abholen. Bitte erneut versuchen.",
|
||||||
"Fehler",
|
"Fehler",
|
||||||
"⚠️"
|
"⚠️"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user