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,
|
||||
|
||||
Reference in New Issue
Block a user