some fixes
This commit is contained in:
@@ -87,7 +87,32 @@ window.sendCommand = async function() {
|
|||||||
let payload = {};
|
let payload = {};
|
||||||
|
|
||||||
if (type === 'build') {
|
if (type === 'build') {
|
||||||
payload = { building_id: document.getElementById('building-select').value };
|
const building_id = document.getElementById('building-select').value;
|
||||||
|
const bData = town.build_data?.[building_id];
|
||||||
|
|
||||||
|
// UI Validation logic
|
||||||
|
if (bData) {
|
||||||
|
const missingDeps = bData.missing_dependencies || {};
|
||||||
|
const missingKeys = Object.keys(missingDeps);
|
||||||
|
|
||||||
|
// 1. Popup if dependencies are lacking
|
||||||
|
if (missingKeys.length > 0) {
|
||||||
|
let msg = '⚠ ΑΔΥΝΑΤΗ Η ΚΑΤΑΣΚΕΥΗ: Λείπουν προϋποθέσεις!\n\nΑπαιτείται:\n';
|
||||||
|
for (const k of missingKeys) {
|
||||||
|
msg += `- ${missingDeps[k].name} (Επίπεδο ${missingDeps[k].needed_level})\n`;
|
||||||
|
}
|
||||||
|
return alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Confirmation if resources are lacking
|
||||||
|
if (bData.enough_resources === false) {
|
||||||
|
if (!confirm('❌ Δεν έχετε αρκετούς πόρους!\n\nΘέλετε να προστεθεί στην ουρά αναμονής; Το σύστημα θα το χτίσει αυτόματα μόλις συγκεντρωθούν οι πόροι.')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
payload = { building_id };
|
||||||
} else {
|
} else {
|
||||||
payload = {
|
payload = {
|
||||||
unit_id: document.getElementById('unit-select').value,
|
unit_id: document.getElementById('unit-select').value,
|
||||||
|
|||||||
@@ -36,15 +36,16 @@ window.renderBuildingDropdown = function() {
|
|||||||
const popStr = pop > 0 ? ` 🧔:${pop} ` : ' ';
|
const popStr = pop > 0 ? ` 🧔:${pop} ` : ' ';
|
||||||
const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${t}`;
|
const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${t}`;
|
||||||
|
|
||||||
// Figure out the state
|
// Figure out the state - missing_dependencies is an Object!
|
||||||
const isLocked = (!data.dependencies) || (data.missing_dependencies && data.missing_dependencies.length > 0);
|
const missingKeys = data.missing_dependencies ? Object.keys(data.missing_dependencies) : [];
|
||||||
|
const isLocked = (!data.dependencies) || (missingKeys.length > 0);
|
||||||
|
|
||||||
const option = document.createElement('option');
|
const option = document.createElement('option');
|
||||||
option.value = key;
|
option.value = key;
|
||||||
|
|
||||||
if (isLocked) {
|
if (isLocked) {
|
||||||
option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`;
|
option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`;
|
||||||
option.style.color = '#777777';
|
option.style.color = '#ff4444'; // Red as requested
|
||||||
} else if (data.can_upgrade === true) {
|
} else if (data.can_upgrade === true) {
|
||||||
option.textContent = `${text} — ✅ ${costStr}`;
|
option.textContent = `${text} — ✅ ${costStr}`;
|
||||||
} else if (data.enough_resources === false) {
|
} else if (data.enough_resources === false) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ window.BUILDING_NAMES_GR = {
|
|||||||
temple: "Ναός",
|
temple: "Ναός",
|
||||||
barracks: "Στρατώνας",
|
barracks: "Στρατώνας",
|
||||||
docks: "Λιμάνι",
|
docks: "Λιμάνι",
|
||||||
market: "Αγορά",
|
market: "Παζάρι",
|
||||||
hide: "Σπηλιά",
|
hide: "Σπηλιά",
|
||||||
lumber: "Ξυλουργείο",
|
lumber: "Ξυλουργείο",
|
||||||
stoner: "Λατομείο",
|
stoner: "Λατομείο",
|
||||||
|
|||||||
Reference in New Issue
Block a user