Compare commits
1 Commits
fix/event-
...
feature/pr
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d43b5c911 |
107
game.js
107
game.js
@@ -1588,6 +1588,113 @@ function renderStats() {
|
||||
const m = Math.floor(elapsed / 60);
|
||||
const s = elapsed % 60;
|
||||
set('st-time', `${m}:${s.toString().padStart(2, '0')}`);
|
||||
|
||||
// Production breakdown — show which buildings contribute to each resource
|
||||
renderProductionBreakdown();
|
||||
}
|
||||
|
||||
function renderProductionBreakdown() {
|
||||
const container = document.getElementById('production-breakdown');
|
||||
if (!container) return;
|
||||
|
||||
// Only show once the player has at least 2 buildings
|
||||
const totalBuildings = Object.values(G.buildings).reduce((a, b) => a + b, 0);
|
||||
if (totalBuildings < 2) {
|
||||
container.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
container.style.display = 'block';
|
||||
|
||||
// Map resource key to its actual rate field on G
|
||||
const resources = [
|
||||
{ key: 'code', label: 'Code', color: '#4a9eff', rateField: 'codeRate' },
|
||||
{ key: 'compute', label: 'Compute', color: '#4a9eff', rateField: 'computeRate' },
|
||||
{ key: 'knowledge', label: 'Knowledge', color: '#4a9eff', rateField: 'knowledgeRate' },
|
||||
{ key: 'user', label: 'Users', color: '#4a9eff', rateField: 'userRate' },
|
||||
{ key: 'impact', label: 'Impact', color: '#4a9eff', rateField: 'impactRate' },
|
||||
{ key: 'rescues', label: 'Rescues', color: '#4a9eff', rateField: 'rescuesRate' },
|
||||
{ key: 'ops', label: 'Ops', color: '#b388ff', rateField: 'opsRate' },
|
||||
{ key: 'trust', label: 'Trust', color: '#4caf50', rateField: 'trustRate' },
|
||||
{ key: 'creativity', label: 'Creativity', color: '#ffd700', rateField: 'creativityRate' }
|
||||
];
|
||||
|
||||
let html = '<h3 style="font-size:11px;color:var(--accent);margin-bottom:8px;letter-spacing:1px">PRODUCTION BREAKDOWN</h3>';
|
||||
|
||||
for (const res of resources) {
|
||||
const totalRate = G[res.rateField];
|
||||
if (totalRate === 0) continue;
|
||||
|
||||
// Collect building contributions (base rates × count, before boost)
|
||||
const contributions = [];
|
||||
let buildingSubtotal = 0;
|
||||
for (const def of BDEF) {
|
||||
const count = G.buildings[def.id] || 0;
|
||||
if (count === 0 || !def.rates || !def.rates[res.key]) continue;
|
||||
const baseRate = def.rates[res.key] * count;
|
||||
// Apply the appropriate boost to match updateRates()
|
||||
let boosted = baseRate;
|
||||
if (res.key === 'code') boosted *= G.codeBoost;
|
||||
else if (res.key === 'compute') boosted *= G.computeBoost;
|
||||
else if (res.key === 'knowledge') boosted *= G.knowledgeBoost;
|
||||
else if (res.key === 'user') boosted *= G.userBoost;
|
||||
else if (res.key === 'impact' || res.key === 'rescues') boosted *= G.impactBoost;
|
||||
if (boosted !== 0) contributions.push({ name: def.name, count, rate: boosted });
|
||||
buildingSubtotal += boosted;
|
||||
}
|
||||
|
||||
// Timmy harmony bonus (applied separately in updateRates)
|
||||
if (G.buildings.timmy > 0 && (res.key === 'code' || res.key === 'compute' || res.key === 'knowledge' || res.key === 'user')) {
|
||||
const timmyMult = Math.max(0.2, Math.min(3, G.harmony / 50));
|
||||
const timmyBase = { code: 5, compute: 2, knowledge: 2, user: 5 }[res.key];
|
||||
const bonus = timmyBase * G.buildings.timmy * (timmyMult - 1);
|
||||
if (Math.abs(bonus) > 0.01) {
|
||||
contributions.push({ name: 'Timmy (harmony)', count: 0, rate: bonus });
|
||||
}
|
||||
}
|
||||
|
||||
// Bilbo random burst (show expected value)
|
||||
if (G.buildings.bilbo > 0 && res.key === 'creativity') {
|
||||
contributions.push({ name: 'Bilbo (random)', count: 0, rate: 5 * G.buildings.bilbo }); // 10% × 50 = 5 EV
|
||||
}
|
||||
|
||||
// Allegro trust penalty
|
||||
if (G.buildings.allegro > 0 && G.trust < 5 && res.key === 'knowledge') {
|
||||
contributions.push({ name: 'Allegro (idle)', count: 0, rate: -10 * G.buildings.allegro });
|
||||
}
|
||||
|
||||
// Show delta: total rate minus what we accounted for
|
||||
const accounted = contributions.reduce((s, c) => s + c.rate, 0);
|
||||
const delta = totalRate - accounted;
|
||||
// Passive sources (ops from users, creativity from users, pact trust, etc.)
|
||||
if (Math.abs(delta) > 0.01) {
|
||||
let label = 'Passive';
|
||||
if (res.key === 'ops') label = 'Passive (from users)';
|
||||
else if (res.key === 'creativity') label = 'Idle creativity';
|
||||
else if (res.key === 'trust' && G.pactFlag) label = 'The Pact';
|
||||
contributions.push({ name: label, count: 0, rate: delta });
|
||||
}
|
||||
|
||||
if (contributions.length === 0) continue;
|
||||
|
||||
html += `<div style="margin-bottom:6px">`;
|
||||
html += `<div style="display:flex;justify-content:space-between;font-size:10px;margin-bottom:2px">`;
|
||||
html += `<span style="color:${res.color};font-weight:600">${res.label}</span>`;
|
||||
html += `<span style="color:#4caf50">+${fmt(totalRate)}/s</span></div>`;
|
||||
|
||||
const absTotal = contributions.reduce((s, c) => s + Math.abs(c.rate), 0);
|
||||
for (const c of contributions.sort((a, b) => Math.abs(b.rate) - Math.abs(a.rate))) {
|
||||
const pct = absTotal > 0 ? Math.abs(c.rate / absTotal * 100) : 0;
|
||||
const barColor = c.rate < 0 ? '#f44336' : '#1a3a5a';
|
||||
html += `<div style="display:flex;align-items:center;font-size:9px;color:#888;margin-left:8px;margin-bottom:1px">`;
|
||||
html += `<span style="width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${c.name}${c.count > 1 ? ' x' + c.count : ''}</span>`;
|
||||
html += `<span style="flex:1;height:3px;background:#111;border-radius:1px;margin:0 6px"><span style="display:block;height:100%;width:${Math.min(100, pct)}%;background:${barColor};border-radius:1px"></span></span>`;
|
||||
html += `<span style="width:50px;text-align:right;color:${c.rate < 0 ? '#f44336' : '#4caf50'}">${c.rate < 0 ? '' : '+'}${fmt(c.rate)}/s</span>`;
|
||||
html += `</div>`;
|
||||
}
|
||||
html += `</div>`;
|
||||
}
|
||||
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
function updateEducation() {
|
||||
|
||||
@@ -132,6 +132,7 @@ Harmony: <span id="st-harmony">50</span><br>
|
||||
Drift: <span id="st-drift">0</span><br>
|
||||
Events Resolved: <span id="st-resolved">0</span>
|
||||
</div>
|
||||
<div id="production-breakdown" style="display:none;margin-top:12px;padding-top:10px;border-top:1px solid var(--border)"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="edu-panel">
|
||||
|
||||
Reference in New Issue
Block a user