fix broken previoius push
This commit is contained in:
@@ -17,22 +17,25 @@ window.renderTowns = function() {
|
|||||||
|
|
||||||
const filteredTowns = window.towns.filter(t => {
|
const filteredTowns = window.towns.filter(t => {
|
||||||
// 1. Search by name
|
// 1. Search by name
|
||||||
if (searchTerm && !t.town_name.toLowerCase().includes(searchTerm)) return false;
|
const tName = t.town_name || '';
|
||||||
|
if (searchTerm && !tName.toLowerCase().includes(searchTerm)) return false;
|
||||||
|
|
||||||
const cap = t.resources.storage || 1;
|
const res = t.resources || {};
|
||||||
const wPct = t.resources.wood / cap;
|
const cap = res.storage || 1;
|
||||||
const sPct = t.resources.stone / cap;
|
const wPct = (res.wood || 0) / cap;
|
||||||
const iPct = t.resources.iron / cap;
|
const sPct = (res.stone || 0) / cap;
|
||||||
|
const iPct = (res.iron || 0) / cap;
|
||||||
|
|
||||||
// 2. Full WH (>95%)
|
// 2. Full WH (>95%)
|
||||||
if (reqFullWh && Math.max(wPct, sPct, iPct) < 0.95) return false;
|
if (reqFullWh && Math.max(wPct, sPct, iPct) < 0.95) return false;
|
||||||
|
|
||||||
// 3. Festival (Wood>15k, Stone>18k, Iron>15k)
|
// 3. Festival (Wood>15k, Stone>18k, Iron>15k)
|
||||||
// City Festival exact costs = 15000, 18000, 15000
|
// City Festival exact costs = 15000, 18000, 15000
|
||||||
if (reqFestival && (t.resources.wood < 15000 || t.resources.stone < 18000 || t.resources.iron < 15000)) return false;
|
if (reqFestival && ((res.wood || 0) < 15000 || (res.stone || 0) < 18000 || (res.iron || 0) < 15000)) return false;
|
||||||
|
|
||||||
// 4. Large Points
|
// 4. Large Points
|
||||||
if (reqPoints && t.points < 10000) return false;
|
const pts = typeof t.points === 'number' ? t.points : parseInt(t.points) || 0;
|
||||||
|
if (reqPoints && pts < 10000) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -49,16 +52,17 @@ window.renderTowns = function() {
|
|||||||
const stale = ageMin > 3;
|
const stale = ageMin > 3;
|
||||||
const selected = t.town_id === window.selectedTownId ? 'selected' : '';
|
const selected = t.town_id === window.selectedTownId ? 'selected' : '';
|
||||||
|
|
||||||
const cap = t.resources.storage || 1;
|
const res = t.resources || {};
|
||||||
const wPct = t.resources.wood / cap;
|
const cap = res.storage || 1;
|
||||||
const sPct = t.resources.stone / cap;
|
const wPct = (res.wood || 0) / cap;
|
||||||
const iPct = t.resources.iron / cap;
|
const sPct = (res.stone || 0) / cap;
|
||||||
|
const iPct = (res.iron || 0) / cap;
|
||||||
|
|
||||||
let markers = '';
|
let markers = '';
|
||||||
if (wPct >= 0.95 || sPct >= 0.95 || iPct >= 0.95) {
|
if (wPct >= 0.95 || sPct >= 0.95 || iPct >= 0.95) {
|
||||||
markers += '<span title="Γεμάτη Αποθήκη!" style="margin-right:4px;">⚠️</span>';
|
markers += '<span title="Γεμάτη Αποθήκη!" style="margin-right:4px;">⚠️</span>';
|
||||||
}
|
}
|
||||||
if (t.resources.wood >= 15000 && t.resources.stone >= 18000 && t.resources.iron >= 15000) {
|
if ((res.wood || 0) >= 15000 && (res.stone || 0) >= 18000 && (res.iron || 0) >= 15000) {
|
||||||
markers += '<span title="Αρκετοί πόροι για Φεστιβάλ!" style="margin-right:4px;">🎭</span>';
|
markers += '<span title="Αρκετοί πόροι για Φεστιβάλ!" style="margin-right:4px;">🎭</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,13 +71,13 @@ window.renderTowns = function() {
|
|||||||
return `
|
return `
|
||||||
<div class="town-card ${selected} ${stale ? 'town-stale' : ''}"
|
<div class="town-card ${selected} ${stale ? 'town-stale' : ''}"
|
||||||
onclick="selectTown('${t.town_id}')">
|
onclick="selectTown('${t.town_id}')">
|
||||||
<div class="town-name">${markers}${t.town_name}${t.has_premium ? ' <span style="color:#c8a44a;font-size:0.7rem;">★</span>' : ''}</div>
|
<div class="town-name">${markers}${t.town_name || 'Άγνωστη'}${t.has_premium ? ' <span style="color:#c8a44a;font-size:0.7rem;">★</span>' : ''}</div>
|
||||||
<div class="town-meta">${t.sea != null ? `🌊 Θ${t.sea} · ` : ''}${t.points} pts · ${t.god || 'No god'} · ${ageMin}m ago</div>
|
<div class="town-meta">${t.sea != null ? `🌊 Θ${t.sea} · ` : ''}${t.points || 0} pts · ${t.god || 'No god'} · ${ageMin}m ago</div>
|
||||||
<div class="town-res">
|
<div class="town-res">
|
||||||
<div class="res-item" style="${getC(wPct)}"><div class="res-icon res-wood"></div>${window.fmt(t.resources.wood)}</div>
|
<div class="res-item" style="${getC(wPct)}"><div class="res-icon res-wood"></div>${window.fmt(res.wood || 0)}</div>
|
||||||
<div class="res-item" style="${getC(sPct)}"><div class="res-icon res-stone"></div>${window.fmt(t.resources.stone)}</div>
|
<div class="res-item" style="${getC(sPct)}"><div class="res-icon res-stone"></div>${window.fmt(res.stone || 0)}</div>
|
||||||
<div class="res-item" style="${getC(iPct)}"><div class="res-icon res-iron"></div>${window.fmt(t.resources.iron)}</div>
|
<div class="res-item" style="${getC(iPct)}"><div class="res-icon res-iron"></div>${window.fmt(res.iron || 0)}</div>
|
||||||
<div class="res-item"><div class="res-icon res-pop"></div>${window.fmt(t.resources.population)}</div>
|
<div class="res-item"><div class="res-icon res-pop"></div>${window.fmt(res.population || 0)}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
@@ -101,9 +105,10 @@ window.renderTownDetails = function() {
|
|||||||
const t = window.getSelectedTown();
|
const t = window.getSelectedTown();
|
||||||
if(!t) return;
|
if(!t) return;
|
||||||
|
|
||||||
document.getElementById('td-name').textContent = t.town_name;
|
document.getElementById('td-name').textContent = t.town_name || 'Άγνωστη';
|
||||||
|
|
||||||
const cap = t.resources.storage || 1;
|
const resObj = t.resources || {};
|
||||||
|
const cap = resObj.storage || 1;
|
||||||
const getCol = (amt) => {
|
const getCol = (amt) => {
|
||||||
const pct = amt / cap;
|
const pct = amt / cap;
|
||||||
if (pct >= 0.95) return 'color: #ff4a4a;'; // Red
|
if (pct >= 0.95) return 'color: #ff4a4a;'; // Red
|
||||||
@@ -146,14 +151,14 @@ window.renderTownDetails = function() {
|
|||||||
return base;
|
return base;
|
||||||
};
|
};
|
||||||
|
|
||||||
const capFmt = (t.resources.storage != null && t.resources.storage !== '') ? window.fmt(t.resources.storage) : '?';
|
const capFmt = (resObj.storage != null && resObj.storage !== '') ? window.fmt(resObj.storage) : '?';
|
||||||
|
|
||||||
document.getElementById('td-resources').innerHTML = `
|
document.getElementById('td-resources').innerHTML = `
|
||||||
<div style="font-size:0.75rem; color:#aaa; margin-bottom: 4px;">Χωρητικότητα: <strong style="color:#eee">${capFmt}</strong></div>
|
<div style="font-size:0.75rem; color:#aaa; margin-bottom: 4px;">Χωρητικότητα: <strong style="color:#eee">${capFmt}</strong></div>
|
||||||
<div>${window.RES_ICONS.wood} Ξύλο: ${resHtml(t.resources.wood, reservedWood)}</div>
|
<div>${window.RES_ICONS.wood} Ξύλο: ${resHtml(resObj.wood || 0, reservedWood)}</div>
|
||||||
<div>${window.RES_ICONS.stone} Πέτρα: ${resHtml(t.resources.stone, reservedStone)}</div>
|
<div>${window.RES_ICONS.stone} Πέτρα: ${resHtml(resObj.stone || 0, reservedStone)}</div>
|
||||||
<div>${window.RES_ICONS.iron} Ασήμι: ${resHtml(t.resources.iron, reservedIron)}</div>
|
<div>${window.RES_ICONS.iron} Ασήμι: ${resHtml(resObj.iron || 0, reservedIron)}</div>
|
||||||
<div style="margin-top: 6px;">${window.RES_ICONS.pop} Πληθυσμός: <strong style="color:#fff">${t.resources.population}</strong></div>
|
<div style="margin-top: 6px;">${window.RES_ICONS.pop} Πληθυσμός: <strong style="color:#fff">${resObj.population || 0}</strong></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας';
|
const godName = t.god ? t.god.charAt(0).toUpperCase() + t.god.slice(1) : 'Κανένας';
|
||||||
|
|||||||
Reference in New Issue
Block a user