blueprint function
This commit is contained in:
@@ -318,9 +318,9 @@ tr:hover td { background: #1e1e40; }
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Building, Academy, Unit & Market Modals
|
||||
Building, Academy, Unit, Market & Blueprint Modals
|
||||
========================================================================== */
|
||||
#building-modal-overlay, #academy-modal-overlay, #unit-modal-overlay, #market-modal-overlay {
|
||||
#building-modal-overlay, #academy-modal-overlay, #unit-modal-overlay, #market-modal-overlay, #blueprints-modal-overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -329,9 +329,9 @@ tr:hover td { background: #1e1e40; }
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
#building-modal-overlay.open, #academy-modal-overlay.open, #unit-modal-overlay.open, #market-modal-overlay.open { display: flex; }
|
||||
#building-modal-overlay.open, #academy-modal-overlay.open, #unit-modal-overlay.open, #market-modal-overlay.open, #blueprints-modal-overlay.open { display: flex; }
|
||||
|
||||
#building-modal, #academy-modal, #unit-modal, #market-modal {
|
||||
#building-modal, #academy-modal, #unit-modal, #market-modal, #blueprints-modal {
|
||||
background: #16213e;
|
||||
border: 2px solid #c8a44a;
|
||||
border-radius: 10px;
|
||||
|
||||
@@ -182,6 +182,30 @@ window.sendCommand = async function() {
|
||||
}
|
||||
|
||||
payload = { research_id };
|
||||
} else if (type === 'blueprints') {
|
||||
const blueprint_name = window.selectedBlueprintName;
|
||||
if (!blueprint_name) return alert('Παρακαλώ επιλέξτε Blueprint.');
|
||||
|
||||
try {
|
||||
const res = await fetch('/dashboard/blueprints', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
town_id: town.town_id,
|
||||
blueprint_name: blueprint_name
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok) {
|
||||
alert(data.is_active ? 'Blueprint ενεργοποιήθηκε!' : 'Blueprint απενεργοποιήθηκε!');
|
||||
window.fetchTowns(); // refresh towns to update UI state
|
||||
} else {
|
||||
alert('Σφάλμα: ' + data.error);
|
||||
}
|
||||
} catch(e) {
|
||||
alert('Failed to toggle blueprint: ' + e);
|
||||
}
|
||||
return; // Exit here as we don't send this to /dashboard/commands
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -49,6 +49,12 @@ window.updateSelectionDisplay = function() {
|
||||
}
|
||||
} else if (type === 'market_offer') {
|
||||
labelEl.innerHTML = `🛒 Ρυθμίσεις Παζαριού`;
|
||||
} else if (type === 'blueprints') {
|
||||
if (window.selectedBlueprintName) {
|
||||
labelEl.innerHTML = `📜 ${window.selectedBlueprintName}`;
|
||||
} else {
|
||||
labelEl.innerHTML = `-- Επιλέξτε Blueprint --`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,6 +64,22 @@ window.reopenActiveModal = function() {
|
||||
else if (type === 'recruit') window.openUnitModal();
|
||||
else if (type === 'research') window.openAcademyModal();
|
||||
else if (type === 'market_offer') window.openMarketModal();
|
||||
else if (type === 'blueprints') window.openBlueprintsModal();
|
||||
};
|
||||
|
||||
window.selectedBlueprintName = null;
|
||||
window.selectBlueprint = function(name) {
|
||||
window.selectedBlueprintName = name;
|
||||
window.updateSelectionDisplay();
|
||||
window.closeBlueprintsModal();
|
||||
};
|
||||
|
||||
window.openBlueprintsModal = function() {
|
||||
document.getElementById('blueprints-modal-overlay').classList.add('open');
|
||||
};
|
||||
window.closeBlueprintsModal = function(e) {
|
||||
if (e && e.target.id !== 'blueprints-modal-overlay' && !e.target.classList.contains('modal-close')) return;
|
||||
document.getElementById('blueprints-modal-overlay').classList.remove('open');
|
||||
};
|
||||
|
||||
window.openMarketModal = function() {
|
||||
|
||||
@@ -212,4 +212,43 @@ window.renderTownDetails = function() {
|
||||
if(unitsHtml === '') unitsHtml = '<div style="color:#666">Κανένα στράτευμα</div>';
|
||||
|
||||
document.getElementById('td-units').innerHTML = unitsHtml;
|
||||
|
||||
// ---- Blueprint Lock & Indicator ----
|
||||
const isBlueprintActive = !!t.blueprint_active;
|
||||
const bpName = t.blueprint_name || 'Standard Growth';
|
||||
|
||||
if (isBlueprintActive) {
|
||||
document.getElementById('td-general').innerHTML += `
|
||||
<div style="margin-top:10px; padding: 4px 8px; background: rgba(200,164,74,0.15); border-left: 3px solid #c8a44a; border-radius:4px; font-size:0.8rem;">
|
||||
🤖 Blueprint: <strong style="color:#c8a44a">${bpName}</strong> <span style="color:#2ecc71">(ΕΝΕΡΓΟ)</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
const btnBuild = document.getElementById('seg-build');
|
||||
const btnResearch = document.getElementById('seg-research');
|
||||
|
||||
if (btnBuild && btnResearch) {
|
||||
if (isBlueprintActive) {
|
||||
btnBuild.style.opacity = '0.3';
|
||||
btnBuild.style.pointerEvents = 'none';
|
||||
btnBuild.title = 'Απενεργοποιημένο λόγω Blueprint';
|
||||
|
||||
btnResearch.style.opacity = '0.3';
|
||||
btnResearch.style.pointerEvents = 'none';
|
||||
btnResearch.title = 'Απενεργοποιημένο λόγω Blueprint';
|
||||
|
||||
if (window.currentCmdType === 'build' || window.currentCmdType === 'research') {
|
||||
window.setCmdType('recruit');
|
||||
}
|
||||
} else {
|
||||
btnBuild.style.opacity = '1';
|
||||
btnBuild.style.pointerEvents = 'auto';
|
||||
btnBuild.title = '';
|
||||
|
||||
btnResearch.style.opacity = '1';
|
||||
btnResearch.style.pointerEvents = 'auto';
|
||||
btnResearch.title = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user