some fixes
This commit is contained in:
@@ -87,7 +87,32 @@ window.sendCommand = async function() {
|
||||
let payload = {};
|
||||
|
||||
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 {
|
||||
payload = {
|
||||
unit_id: document.getElementById('unit-select').value,
|
||||
|
||||
@@ -36,15 +36,16 @@ window.renderBuildingDropdown = function() {
|
||||
const popStr = pop > 0 ? ` 🧔:${pop} ` : ' ';
|
||||
const costStr = `Ξ:${w} Π:${st} Α:${i}${popStr}· ⏱ ${t}`;
|
||||
|
||||
// Figure out the state
|
||||
const isLocked = (!data.dependencies) || (data.missing_dependencies && data.missing_dependencies.length > 0);
|
||||
// Figure out the state - missing_dependencies is an Object!
|
||||
const missingKeys = data.missing_dependencies ? Object.keys(data.missing_dependencies) : [];
|
||||
const isLocked = (!data.dependencies) || (missingKeys.length > 0);
|
||||
|
||||
const option = document.createElement('option');
|
||||
option.value = key;
|
||||
|
||||
if (isLocked) {
|
||||
option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`;
|
||||
option.style.color = '#777777';
|
||||
option.style.color = '#ff4444'; // Red as requested
|
||||
} else if (data.can_upgrade === true) {
|
||||
option.textContent = `${text} — ✅ ${costStr}`;
|
||||
} else if (data.enough_resources === false) {
|
||||
|
||||
@@ -15,7 +15,7 @@ window.BUILDING_NAMES_GR = {
|
||||
temple: "Ναός",
|
||||
barracks: "Στρατώνας",
|
||||
docks: "Λιμάνι",
|
||||
market: "Αγορά",
|
||||
market: "Παζάρι",
|
||||
hide: "Σπηλιά",
|
||||
lumber: "Ξυλουργείο",
|
||||
stoner: "Λατομείο",
|
||||
|
||||
Reference in New Issue
Block a user