enchance dropdown
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name Grepolis Remote Control
|
||||
// @namespace http://tampermonkey.net/
|
||||
// @version 1.8
|
||||
// @version 1.9
|
||||
// @description Polls grepo.haunter-pets.top for remote commands and executes them in-game
|
||||
// @author Dimitrios
|
||||
// @match https://*.grepolis.com/game/*
|
||||
@@ -107,7 +107,10 @@
|
||||
stone: buildDataRaw[k].resources_for?.stone || 0,
|
||||
iron: buildDataRaw[k].resources_for?.iron || 0,
|
||||
pop: buildDataRaw[k].population_for || 0,
|
||||
build_time: buildDataRaw[k].building_time || ''
|
||||
build_time: buildDataRaw[k].building_time || '',
|
||||
can_upgrade: !!buildDataRaw[k].can_upgrade,
|
||||
enough_resources: !!buildDataRaw[k].enough_resources,
|
||||
missing_dependencies: buildDataRaw[k].missing_dependencies || []
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -25,22 +25,44 @@ window.renderBuildingDropdown = function() {
|
||||
|
||||
let text = `${nameGr} [Επίπεδο ${level}]`;
|
||||
|
||||
if (data && data.dependencies) {
|
||||
if (data) {
|
||||
const w = window.fmt(data.wood || 0);
|
||||
const st = window.fmt(data.stone || 0);
|
||||
const i = window.fmt(data.iron || 0);
|
||||
const pop = data.pop || 0;
|
||||
let t = data.build_time || '';
|
||||
if (t.startsWith('00:')) t = t.substring(3); // make '00:06:00' cleaner as '06:00'
|
||||
|
||||
// Only show costs if the prerequisites are fulfilled
|
||||
text += ` — Ξ:${w} Π:${st} Α:${i} · ⏱ ${t}`;
|
||||
}
|
||||
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);
|
||||
|
||||
const option = document.createElement('option');
|
||||
option.value = key;
|
||||
option.textContent = text;
|
||||
|
||||
if (isLocked) {
|
||||
option.textContent = `${text} — 🔒 Κλειδωμένο (Προϋποθέσεις)`;
|
||||
option.style.color = '#777777';
|
||||
} else if (data.can_upgrade === true) {
|
||||
option.textContent = `${text} — ✅ ${costStr}`;
|
||||
} else if (data.enough_resources === false) {
|
||||
option.textContent = `${text} — ❌ ${costStr} (Λείπουν Πόροι)`;
|
||||
option.style.color = '#aa5555';
|
||||
} else {
|
||||
// can_upgrade is false, but resources are fine = Population limit or Queue full
|
||||
option.textContent = `${text} — ⚠️ ${costStr} (Πληθυσμός / Ουρά)`;
|
||||
option.style.color = '#aa8855';
|
||||
}
|
||||
|
||||
bSelect.appendChild(option);
|
||||
} else {
|
||||
const option = document.createElement('option');
|
||||
option.value = key;
|
||||
option.textContent = text;
|
||||
bSelect.appendChild(option);
|
||||
}
|
||||
}
|
||||
|
||||
if (currentVal && Array.from(bSelect.options).some(o => o.value === currentVal)) {
|
||||
|
||||
Reference in New Issue
Block a user