Planetengenerierung
This commit is contained in:
@@ -42,6 +42,9 @@ export const translations = {
|
||||
// --- Sektor-Onboarding ---
|
||||
ERR_ALREADY_IN_SECTOR: "Du bist diesem Sektor bereits beigetreten.",
|
||||
ERR_LOCAL_USERNAME_TAKEN: "Dieser Commander-Name ist in diesem Sektor leider schon vergeben.",
|
||||
ERR_ACCOUNT_ALREADY_EXISTS: "Dieser Commander-Name oder deine Lobby-ID ist in diesem Sektor bereits registriert.",
|
||||
ERR_SECTOR_OFFLINE: "Dieser Sektor ist derzeit offline oder wird gewartet. Beitritt nicht möglich.",
|
||||
ERR_SECTOR_CONNECTION_FAILED: "Verbindung zum Sektor fehlgeschlagen. Bitte versuche es später noch einmal.",
|
||||
MSG_SECTOR_JOINED_SUCCESS: "Sektor erfolgreich beigetreten!",
|
||||
|
||||
// --- Footer ---
|
||||
@@ -83,7 +86,7 @@ export const translations = {
|
||||
btn_reset_password: "CHANGE PASSWORD",
|
||||
link_back: "« back",
|
||||
btn_male: "Male",
|
||||
btn_female: "Femail",
|
||||
btn_female: "Female",
|
||||
btn_cancel: "Cancel",
|
||||
btn_join: "Join Sector",
|
||||
|
||||
@@ -95,7 +98,8 @@ export const translations = {
|
||||
ph_otp: "6-digit code",
|
||||
|
||||
// --- Labels ---
|
||||
lbl_agb: "I accept the <a href='agb.html' target='_blank'>Terms of Service</a>, <a href='regeln.html' target='_blank'>Rules</a> & <a href='datenschutz.html' target='_blank'>Privacy Policy</a>", lbl_remember: "Keep me logged in",
|
||||
lbl_agb: "I accept the <a href='agb.html' target='_blank'>Terms of Service</a>, <a href='regeln.html' target='_blank'>Rules</a> & <a href='datenschutz.html' target='_blank'>Privacy Policy</a>",
|
||||
lbl_remember: "Keep me logged in",
|
||||
|
||||
// --- OTP Modus ---
|
||||
txt_otp_instruction: "Please enter the 6-digit code from your e-mail.",
|
||||
@@ -108,6 +112,9 @@ export const translations = {
|
||||
// --- Sektor-Onboarding ---
|
||||
ERR_ALREADY_IN_SECTOR: "You have already joined this sector.",
|
||||
ERR_LOCAL_USERNAME_TAKEN: "This Commander name is already taken in this sector.",
|
||||
ERR_ACCOUNT_ALREADY_EXISTS: "This Commander name or your Lobby ID is already registered in this sector.",
|
||||
ERR_SECTOR_OFFLINE: "This sector is currently offline or under maintenance. Cannot join.",
|
||||
ERR_SECTOR_CONNECTION_FAILED: "Connection to sector failed. Please try again later.",
|
||||
MSG_SECTOR_JOINED_SUCCESS: "Successfully joined the sector!",
|
||||
|
||||
// --- Footer ---
|
||||
@@ -139,16 +146,8 @@ export const translations = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Die aktuell gewählte Sprache.
|
||||
* Später können wir das auch im LocalStorage des Browsers speichern,
|
||||
* damit sich das Spiel die Sprache des Nutzers merkt.
|
||||
*/
|
||||
export let currentLang = localStorage.getItem('void_language') || 'de';
|
||||
|
||||
/**
|
||||
* Hilfsfunktion, um die Sprache zu wechseln.
|
||||
*/
|
||||
export function setLanguage(lang) {
|
||||
if (translations[lang]) {
|
||||
currentLang = lang;
|
||||
@@ -156,11 +155,6 @@ export function setLanguage(lang) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt den passenden Text für den übergebenen Schlüssel (Key).
|
||||
* Fällt auf den Key selbst zurück, falls keine Übersetzung gefunden wird
|
||||
* (hilft beim Debuggen, um fehlende Übersetzungen zu erkennen).
|
||||
*/
|
||||
export function t(key) {
|
||||
return translations[currentLang][key] || key;
|
||||
}
|
||||
@@ -521,9 +521,52 @@ function renderSectorList(sectors, type) {
|
||||
// HTML-Karte im DOM blitzschnell zu finden, ohne das Grid neu aufzubauen.
|
||||
cardLink.setAttribute('data-sector-id', sector.id);
|
||||
|
||||
// --- Temporäre Platzhalter für das neue UI (ersetzen wir später durch echte DB-Werte) ---
|
||||
const ageDays = sector.age_days || Math.floor(Math.random() * 30) + 1;
|
||||
const totalPlayers = sector.total_players || Math.floor(Math.random() * 500) + 150;
|
||||
// --- ECHTE DATEN STATT PLATZHALTER ---
|
||||
const createdDate = new Date(sector.created_at);
|
||||
const ageDays = Math.max(1, Math.ceil((new Date() - createdDate) / (1000 * 60 * 60 * 24)));
|
||||
|
||||
// Tooltip mit echten Konfigurationswerten aus der Sektor-DB aufbauen
|
||||
const tooltipLines = [
|
||||
`Anzahl der Galaxien: ${sector.max_galaxies}`,
|
||||
`Ökonomie-Tempo: ${sector.speed_economy}x`,
|
||||
`Forschungs-Tempo: ${sector.research_speed}x`,
|
||||
`Flotten Geschwindigkeiten:`,
|
||||
`Feindliche Flotte: ${sector.fleet_speed_hostile}x`,
|
||||
`Friedliche Flotte: ${sector.fleet_speed_peaceful}x`,
|
||||
`Freundliche Flotte: ${sector.fleet_speed_friendly}x`
|
||||
];
|
||||
|
||||
// BEDINGUNG: Treibstoff-Verbrauchsfaktor nur anzeigen, wenn er ungleich 1 ist
|
||||
if (sector.fuel_consumption_factor !== undefined && parseInt(sector.fuel_consumption_factor, 10) !== 1) {
|
||||
tooltipLines.push(`Treibstoff Verbrauch: ${sector.fuel_consumption_factor}x`);
|
||||
}
|
||||
|
||||
// Standardmäßig immer das Flotten-Trümmerfeld-Prozent anzeigen
|
||||
tooltipLines.push(`${sector.fleet_to_debris_percentage}% der Flotten ins Trümmerfeld`);
|
||||
|
||||
// BEDINGUNG: Verteidigungs-Trümmerfeld-Prozent nur anzeigen, wenn es größer als 0 ist
|
||||
if (sector.defense_to_debris_percentage !== undefined && parseInt(sector.defense_to_debris_percentage, 10) > 0) {
|
||||
tooltipLines.push(`${sector.defense_to_debris_percentage}% der Verteidigungsanlagen ins Trümmerfeld`);
|
||||
}
|
||||
|
||||
// BEDINGUNG: Treibstoff im Trümmerfeld anzeigen, wenn das Flag true (oder ungleich 0 / false) ist
|
||||
if (sector.fuel_included_in_debris === true || sector.fuel_included_in_debris === 1 || sector.fuel_included_in_debris === 'true') {
|
||||
tooltipLines.push(`Treibstoff im Trümmerfeld: Ja`);
|
||||
}
|
||||
|
||||
// BEDINGUNG: Start-Premium-Währung nur auflisten, wenn sie ungleich 0 ist
|
||||
if (sector.initial_res_premium !== undefined && parseInt(sector.initial_res_premium, 10) !== 0) {
|
||||
tooltipLines.push(`Void Kristalle beim Start: ${sector.initial_res_premium}`);
|
||||
}
|
||||
|
||||
// BEDINGUNG: Bonus-Felder für Planeten nur anzeigen, wenn sie ungleich 0 sind
|
||||
if (sector.bonus_fields !== undefined && parseInt(sector.bonus_fields, 10) !== 0) {
|
||||
tooltipLines.push(`Bonus auf Planetenfelder: ${sector.bonus_fields}`);
|
||||
}
|
||||
|
||||
// 3. Alle gesammelten Zeilen mit einem echten Zeilenumbruch (\n) zu einem einzelnen String verknüpfen
|
||||
const tooltipText = tooltipLines.join('\n');
|
||||
|
||||
|
||||
let bottomRowHtml = '';
|
||||
if (type === 'my' && sector.local_username) {
|
||||
@@ -532,7 +575,7 @@ function renderSectorList(sectors, type) {
|
||||
|
||||
cardLink.innerHTML = `
|
||||
<div class="sector-card-content" style="position: relative; width: 100%; height: 100%; padding: 0;">
|
||||
<span style="position: absolute; left: 10px; top: 15px; width: 25px; height: 27px; cursor: help;" title="Sektor-Details (Flotte: ${sector.speed_fleet}x, Öko: ${sector.speed_economy}x)"></span>
|
||||
<span style="position: absolute; left: 10px; top: 15px; width: 25px; height: 27px; cursor: help;" title="${tooltipText}"></span>
|
||||
<span style="position: absolute; left: 40px; top: 15px; width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; font-weight: bold;" title="${sector.name}">
|
||||
${sector.name}
|
||||
</span>
|
||||
@@ -540,7 +583,8 @@ function renderSectorList(sectors, type) {
|
||||
<span class="sector-status ${sector.status === 'online' ? 'status-online' : 'status-maintenance'}" style="position: absolute; right: 20px; top: 17px;">
|
||||
${sector.status === 'online' ? 'online' : 'offline'}
|
||||
</span>
|
||||
<span class="sector-online-count" style="position: absolute; left: 40px; top: 54px; font-size: 13px; color: var(--color-text-placeholder);">Online: ${sector.online_players}/${totalPlayers}</span>
|
||||
|
||||
<span class="sector-online-count" style="position: absolute; left: 40px; top: 54px; font-size: 13px; color: var(--color-text-placeholder);">Online: ${sector.online_players}/${sector.current_players}</span>
|
||||
<span class="sector-planets-count" style="position: absolute; left: 170px; top: 54px; font-size: 13px; color: var(--color-text-placeholder);">Planeten: ${sector.planets_count}</span>
|
||||
${bottomRowHtml}
|
||||
</div>
|
||||
@@ -755,12 +799,11 @@ function updateLiveStatus(sectors, type) {
|
||||
statusEl.className = `sector-status ${sector.status === 'online' ? 'status-online' : 'status-maintenance'}`;
|
||||
}
|
||||
|
||||
// 2. HTML-Spielerzahlen über die neue, eindeutige Klasse aktualisieren
|
||||
/// 2. HTML-Spielerzahlen über die eindeutige Klasse aktualisieren
|
||||
const midRowEl = cardLink.querySelector('.sector-online-count');
|
||||
if (midRowEl) {
|
||||
// Wir behalten deine Logik bei, falls die Gesamtzahl temporär berechnet werden muss
|
||||
const totalPlayers = sector.total_players || Math.floor(Math.random() * 500) + 150;
|
||||
midRowEl.textContent = `Online: ${sector.online_players}/${totalPlayers}`;
|
||||
// Das DOM übernimmt die echten Live-Werte für Online und Gesamt
|
||||
midRowEl.textContent = `Online: ${sector.online_players}/${sector.current_players}`;
|
||||
}
|
||||
|
||||
// 3. HTML-Planetenanzahl über die neue, eindeutige Klasse aktualisieren
|
||||
|
||||
Reference in New Issue
Block a user