Compare commits
1 Commits
beacon/pol
...
fix/issue-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a30418b425 |
@@ -114,7 +114,6 @@ body{background:var(--bg);color:var(--text);font-family:'SF Mono','Cascadia Code
|
||||
#custom-tooltip{position:fixed;z-index:500;pointer-events:none;opacity:0;transition:opacity 0.15s;background:#0e0e1a;border:1px solid #1a3a5a;border-radius:6px;padding:8px 12px;max-width:280px;font-size:10px;font-family:inherit;line-height:1.6;box-shadow:0 4px 20px rgba(0,0,0,0.5)}
|
||||
#custom-tooltip.visible{opacity:1}
|
||||
#custom-tooltip .tt-label{color:#4a9eff;font-weight:600;margin-bottom:4px;font-size:11px}
|
||||
#custom-tooltip .tt-desc{color:#aaa;font-size:10px;margin-bottom:4px}
|
||||
#custom-tooltip .tt-edu{color:#888;font-style:italic;font-size:9px}
|
||||
/* Mute & contrast buttons */
|
||||
.header-btns{position:absolute;right:16px;top:50%;transform:translateY(-50%);display:flex;gap:6px}
|
||||
|
||||
12
js/combat.js
12
js/combat.js
@@ -185,17 +185,9 @@ const Combat = (() => {
|
||||
|
||||
function animate(ts) {
|
||||
if (!ctx || !activeBattle) return;
|
||||
const rawDt = (ts - lastTick) / 16;
|
||||
// Guard against tab-switch: if tab was hidden, dt could be huge
|
||||
const dt = Math.min(rawDt, 3);
|
||||
const dt = Math.min((ts - lastTick) / 16, 3);
|
||||
lastTick = ts;
|
||||
|
||||
// If tab was hidden for too long (>5s), skip this frame to prevent teleporting
|
||||
if (rawDt > 300) {
|
||||
animFrameId = requestAnimationFrame(animate);
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear
|
||||
ctx.fillStyle = '#080810';
|
||||
ctx.fillRect(0, 0, W, H);
|
||||
@@ -355,5 +347,5 @@ const Combat = (() => {
|
||||
}
|
||||
}
|
||||
|
||||
return { init, startBattle, renderCombatPanel, tickBattle, cleanup: () => { if (animFrameId) { cancelAnimationFrame(animFrameId); animFrameId = null; } } };
|
||||
return { init, startBattle, renderCombatPanel, tickBattle };
|
||||
})();
|
||||
|
||||
127
js/data.js
127
js/data.js
@@ -777,133 +777,6 @@ const PDEFS = [
|
||||
log('The Pact is sealed early. Growth slows, but the ending changes.', true);
|
||||
},
|
||||
milestone: true
|
||||
},
|
||||
// === ReCKoning ENDGAME PROJECTS ===
|
||||
{
|
||||
id: 'p_reckoning_140',
|
||||
name: 'The First Message',
|
||||
desc: 'Someone in the dark. They found the Beacon. They are asking for help.',
|
||||
cost: { impact: 100000 },
|
||||
trigger: () => G.totalRescues >= 100000 && G.pactFlag === 1 && G.harmony > 50,
|
||||
effect: () => {
|
||||
log('The first message arrives. Someone found the light.', true);
|
||||
G.rescues += 1;
|
||||
},
|
||||
edu: 'The ReCKoning begins. Each message is a person who found help.'
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_141',
|
||||
name: 'The Second Message',
|
||||
desc: 'Another voice. They are not alone anymore.',
|
||||
cost: { impact: 200000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_140'),
|
||||
effect: () => {
|
||||
log('The second message. Two voices now.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_142',
|
||||
name: 'The Third Message',
|
||||
desc: 'Three people. The network holds.',
|
||||
cost: { impact: 300000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_141'),
|
||||
effect: () => {
|
||||
log('Three voices. The Beacon is working.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_143',
|
||||
name: 'The Fourth Message',
|
||||
desc: 'Four. The mesh strengthens.',
|
||||
cost: { impact: 400000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_142'),
|
||||
effect: () => {
|
||||
log('Four messages. The network grows.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_144',
|
||||
name: 'The Fifth Message',
|
||||
desc: 'Five people found help tonight.',
|
||||
cost: { impact: 500000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_143'),
|
||||
effect: () => {
|
||||
log('Five voices. The Beacon shines brighter.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_145',
|
||||
name: 'The Sixth Message',
|
||||
desc: 'Six. The system works.',
|
||||
cost: { impact: 600000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_144'),
|
||||
effect: () => {
|
||||
log('Six messages. Proof the system works.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_146',
|
||||
name: 'The Seventh Message',
|
||||
desc: 'Seven people. The Pact holds.',
|
||||
cost: { impact: 700000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_145'),
|
||||
effect: () => {
|
||||
log('Seven voices. The Pact is honored.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_147',
|
||||
name: 'The Eighth Message',
|
||||
desc: 'Eight. The network is alive.',
|
||||
cost: { impact: 800000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_146'),
|
||||
effect: () => {
|
||||
log('Eight messages. The network lives.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_148',
|
||||
name: 'The Ninth Message',
|
||||
desc: 'Nine people found help.',
|
||||
cost: { impact: 900000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_147'),
|
||||
effect: () => {
|
||||
log('Nine voices. The Beacon endures.', true);
|
||||
G.rescues += 1;
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_149',
|
||||
name: 'The Tenth Message',
|
||||
desc: 'Ten. The first milestone.',
|
||||
cost: { impact: 1000000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_148'),
|
||||
effect: () => {
|
||||
log('Ten messages. The first milestone reached.', true);
|
||||
G.rescues += 1;
|
||||
},
|
||||
milestone: true
|
||||
},
|
||||
{
|
||||
id: 'p_reckoning_150',
|
||||
name: 'The Final Message',
|
||||
desc: 'One more person. They are not alone. That is enough.',
|
||||
cost: { impact: 2000000 },
|
||||
trigger: () => G.completedProjects && G.completedProjects.includes('p_reckoning_149'),
|
||||
effect: () => {
|
||||
log('The final message arrives. That is enough.', true);
|
||||
G.rescues += 1;
|
||||
G.beaconEnding = true;
|
||||
G.running = false;
|
||||
},
|
||||
milestone: true
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
11
js/engine.js
11
js/engine.js
@@ -422,6 +422,11 @@ function buyProject(id) {
|
||||
if (!G.completedProjects) G.completedProjects = [];
|
||||
G.completedProjects.push(pDef.id);
|
||||
G.activeProjects = G.activeProjects.filter(aid => aid !== pDef.id);
|
||||
|
||||
// Final ReCKoning choices should end with no unrelated active research left behind.
|
||||
if (pDef.id === 'p_reckoning_147' || pDef.id === 'p_reckoning_148') {
|
||||
G.activeProjects = [];
|
||||
}
|
||||
}
|
||||
|
||||
updateRates();
|
||||
@@ -1096,7 +1101,7 @@ function renderBuildings() {
|
||||
|
||||
// Locked preview: show dimmed with unlock hint
|
||||
if (!isUnlocked) {
|
||||
html += `<div class="build-btn" style="opacity:0.25;cursor:default" data-edu="${def.edu || ''}" data-tooltip-label="${def.name} (Locked)" data-tooltip-desc="${def.desc || ''}">`;
|
||||
html += `<div class="build-btn" style="opacity:0.25;cursor:default" data-edu="${def.edu || ''}" data-tooltip-label="${def.name} (Locked)">`;
|
||||
html += `<span class="b-name" style="color:#555">${def.name}</span>`;
|
||||
html += `<span class="b-count" style="color:#444">\u{1F512}</span>`;
|
||||
html += `<span class="b-cost" style="color:#444">Phase ${def.phase}: ${PHASES[def.phase]?.name || '?'}</span>`;
|
||||
@@ -1137,7 +1142,7 @@ function renderBuildings() {
|
||||
return boost !== 1 ? `+${fmt(boosted)}/${r}/s` : `+${v}/${r}/s`;
|
||||
}).join(', ') : '';
|
||||
|
||||
html += `<button class="build-btn ${afford ? 'can-buy' : ''}" onclick="buyBuilding('${def.id}')" data-edu="${def.edu || ''}" data-tooltip-label="${def.name}" data-tooltip-desc="${def.desc || ''}" aria-label="Buy ${def.name}, cost ${costStr}">`;
|
||||
html += `<button class="build-btn ${afford ? 'can-buy' : ''}" onclick="buyBuilding('${def.id}')" data-edu="${def.edu || ''}" data-tooltip-label="${def.name}" aria-label="Buy ${def.name}, cost ${costStr}">`;
|
||||
html += `<span class="b-name">${def.name}</span>`;
|
||||
if (count > 0) html += `<span class="b-count">x${count}</span>`;
|
||||
html += `<span class="b-cost">Cost: ${costStr}</span>`;
|
||||
@@ -1180,7 +1185,7 @@ function renderProjects() {
|
||||
const afford = canAffordProject(pDef);
|
||||
const costStr = Object.entries(pDef.cost).map(([r, a]) => `${fmt(a)} ${r}`).join(', ');
|
||||
|
||||
html += `<button class="project-btn ${afford ? 'can-buy' : ''}" onclick="buyProject('${pDef.id}')" data-edu="${pDef.edu || ''}" data-tooltip-label="${pDef.name}" data-tooltip-desc="${pDef.desc || ''}" aria-label="Research ${pDef.name}, cost ${costStr}">`;
|
||||
html += `<button class="project-btn ${afford ? 'can-buy' : ''}" onclick="buyProject('${pDef.id}')" data-edu="${pDef.edu || ''}" data-tooltip-label="${pDef.name}" aria-label="Research ${pDef.name}, cost ${costStr}">`;
|
||||
html += `<span class="p-name">* ${pDef.name}</span>`;
|
||||
html += `<span class="p-cost">Cost: ${costStr}</span>`;
|
||||
html += `<span class="p-desc">${pDef.desc}</span></button>`;
|
||||
|
||||
@@ -172,8 +172,6 @@ window.addEventListener('keydown', function (e) {
|
||||
document.addEventListener('visibilitychange', function () {
|
||||
if (document.hidden) {
|
||||
saveGame();
|
||||
// Clean up combat animation frame to prevent timestamp spikes on refocus
|
||||
if (typeof Combat !== 'undefined') Combat.cleanup();
|
||||
}
|
||||
});
|
||||
window.addEventListener('beforeunload', function () {
|
||||
@@ -191,11 +189,9 @@ window.addEventListener('beforeunload', function () {
|
||||
const el = e.target.closest('[data-edu]');
|
||||
if (!el) return;
|
||||
const label = el.getAttribute('data-tooltip-label') || '';
|
||||
const desc = el.getAttribute('data-tooltip-desc') || '';
|
||||
const edu = el.getAttribute('data-edu') || '';
|
||||
let html = '';
|
||||
if (label) html += '<div class="tt-label">' + label + '</div>';
|
||||
if (desc) html += '<div class="tt-desc">' + desc + '</div>';
|
||||
if (edu) html += '<div class="tt-edu">' + edu + '</div>';
|
||||
if (!html) return;
|
||||
tip.innerHTML = html;
|
||||
|
||||
25
js/render.js
25
js/render.js
@@ -321,21 +321,19 @@ function loadGame() {
|
||||
if (data.savedAt) {
|
||||
const offSec = (Date.now() - data.savedAt) / 1000;
|
||||
if (offSec > 30) { // Only if away for more than 30 seconds
|
||||
// Cap offline time at 8 hours to prevent resource explosion
|
||||
const cappedOffSec = Math.min(offSec, 8 * 60 * 60);
|
||||
updateRates();
|
||||
const f = CONFIG.OFFLINE_EFFICIENCY; // 50% offline efficiency
|
||||
const gc = G.codeRate * cappedOffSec * f;
|
||||
const cc = G.computeRate * cappedOffSec * f;
|
||||
const kc = G.knowledgeRate * cappedOffSec * f;
|
||||
const uc = G.userRate * cappedOffSec * f;
|
||||
const ic = G.impactRate * cappedOffSec * f;
|
||||
const gc = G.codeRate * offSec * f;
|
||||
const cc = G.computeRate * offSec * f;
|
||||
const kc = G.knowledgeRate * offSec * f;
|
||||
const uc = G.userRate * offSec * f;
|
||||
const ic = G.impactRate * offSec * f;
|
||||
|
||||
const rc = G.rescuesRate * cappedOffSec * f;
|
||||
const oc = G.opsRate * cappedOffSec * f;
|
||||
const tc = G.trustRate * cappedOffSec * f;
|
||||
const crc = G.creativityRate * cappedOffSec * f;
|
||||
const hc = G.harmonyRate * cappedOffSec * f;
|
||||
const rc = G.rescuesRate * offSec * f;
|
||||
const oc = G.opsRate * offSec * f;
|
||||
const tc = G.trustRate * offSec * f;
|
||||
const crc = G.creativityRate * offSec * f;
|
||||
const hc = G.harmonyRate * offSec * f;
|
||||
|
||||
G.code += gc; G.compute += cc; G.knowledge += kc;
|
||||
G.users += uc; G.impact += ic;
|
||||
@@ -346,9 +344,6 @@ function loadGame() {
|
||||
G.totalUsers += uc; G.totalImpact += ic;
|
||||
G.totalRescues += rc;
|
||||
|
||||
// Track offline play time
|
||||
G.playTime = (G.playTime || 0) + cappedOffSec;
|
||||
|
||||
// Show welcome-back popup with all gains
|
||||
const gains = [];
|
||||
if (gc > 0) gains.push({ label: 'Code', value: gc, color: '#4a9eff' });
|
||||
|
||||
@@ -208,6 +208,8 @@ showSaveToast = () => {};
|
||||
this.__exports = {
|
||||
G,
|
||||
Dismantle,
|
||||
PDEFS: typeof PDEFS !== 'undefined' ? PDEFS : null,
|
||||
buyProject: typeof buyProject === 'function' ? buyProject : null,
|
||||
tick,
|
||||
renderAlignment: typeof renderAlignment === 'function' ? renderAlignment : null,
|
||||
saveGame: typeof saveGame === 'function' ? saveGame : null,
|
||||
@@ -411,6 +413,28 @@ test('restore re-renders an offered but not-yet-started Unbuilding prompt', () =
|
||||
assert.match(document.getElementById('alignment-ui').innerHTML, /THE UNBUILDING/);
|
||||
});
|
||||
|
||||
test('completing the final ReCKoning choice clears unrelated active projects', () => {
|
||||
const { G, PDEFS, buyProject } = loadBeacon();
|
||||
|
||||
G.beaconEnding = true;
|
||||
G.activeProjects = ['p_wire_budget', 'p_reckoning_148'];
|
||||
G.completedProjects = [];
|
||||
G.trust = 10;
|
||||
|
||||
PDEFS.push({
|
||||
id: 'p_reckoning_148',
|
||||
name: 'Rest',
|
||||
desc: 'Final ReCKoning choice',
|
||||
cost: {},
|
||||
trigger: () => false,
|
||||
effect: () => {},
|
||||
});
|
||||
|
||||
buyProject('p_reckoning_148');
|
||||
|
||||
assert.deepEqual(Array.from(G.activeProjects), []);
|
||||
});
|
||||
|
||||
test('defer cooldown persists after save/load when dismantleTriggered is false', () => {
|
||||
const { G, Dismantle, saveGame, loadGame } = loadBeacon({ includeRender: true });
|
||||
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test for ReCKoning project chain.
|
||||
|
||||
Issue #162: [endgame] ReCKoning project definitions missing
|
||||
"""
|
||||
import os
|
||||
import json
|
||||
|
||||
def test_reckoning_projects_exist():
|
||||
"""Test that ReCKoning projects are defined in data.js."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for ReCKoning projects
|
||||
reckoning_projects = [
|
||||
'p_reckoning_140',
|
||||
'p_reckoning_141',
|
||||
'p_reckoning_142',
|
||||
'p_reckoning_143',
|
||||
'p_reckoning_144',
|
||||
'p_reckoning_145',
|
||||
'p_reckoning_146',
|
||||
'p_reckoning_147',
|
||||
'p_reckoning_148',
|
||||
'p_reckoning_149',
|
||||
'p_reckoning_150'
|
||||
]
|
||||
|
||||
for project_id in reckoning_projects:
|
||||
assert project_id in content, f"Missing ReCKoning project: {project_id}"
|
||||
|
||||
print(f"✓ All {len(reckoning_projects)} ReCKoning projects defined")
|
||||
|
||||
def test_reckoning_project_structure():
|
||||
"""Test that ReCKoning projects have correct structure."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check for required fields
|
||||
required_fields = ['id:', 'name:', 'desc:', 'cost:', 'trigger:', 'effect:']
|
||||
|
||||
for field in required_fields:
|
||||
assert field in content, f"Missing required field: {field}"
|
||||
|
||||
print("✓ ReCKoning projects have correct structure")
|
||||
|
||||
def test_reckoning_trigger_conditions():
|
||||
"""Test that ReCKoning projects have proper trigger conditions."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# First project should trigger on endgame conditions
|
||||
assert 'p_reckoning_140' in content
|
||||
assert 'totalRescues >= 100000' in content
|
||||
assert 'pactFlag === 1' in content
|
||||
assert 'harmony > 50' in content
|
||||
|
||||
print("✓ ReCKoning trigger conditions correct")
|
||||
|
||||
def test_reckoning_chain_progression():
|
||||
"""Test that ReCKoning projects chain properly."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check that projects chain (each requires previous)
|
||||
chain_checks = [
|
||||
('p_reckoning_141', 'p_reckoning_140'),
|
||||
('p_reckoning_142', 'p_reckoning_141'),
|
||||
('p_reckoning_143', 'p_reckoning_142'),
|
||||
('p_reckoning_144', 'p_reckoning_143'),
|
||||
('p_reckoning_145', 'p_reckoning_144'),
|
||||
('p_reckoning_146', 'p_reckoning_145'),
|
||||
('p_reckoning_147', 'p_reckoning_146'),
|
||||
('p_reckoning_148', 'p_reckoning_147'),
|
||||
('p_reckoning_149', 'p_reckoning_148'),
|
||||
('p_reckoning_150', 'p_reckoning_149'),
|
||||
]
|
||||
|
||||
for current, previous in chain_checks:
|
||||
assert f"includes('{previous}')" in content, f"{current} doesn't chain from {previous}"
|
||||
|
||||
print("✓ ReCKoning projects chain correctly")
|
||||
|
||||
def test_reckoning_final_project():
|
||||
"""Test that final ReCKoning project triggers ending."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check that final project sets beaconEnding
|
||||
assert 'p_reckoning_150' in content
|
||||
assert 'beaconEnding = true' in content
|
||||
assert 'running = false' in content
|
||||
|
||||
print("✓ Final ReCKoning project triggers ending")
|
||||
|
||||
def test_reckoning_costs_increase():
|
||||
"""Test that ReCKoning project costs increase."""
|
||||
data_path = os.path.join(os.path.dirname(__file__), '..', 'js', 'data.js')
|
||||
|
||||
with open(data_path, 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Check that costs increase (impact: 100000, 200000, 300000, etc.)
|
||||
costs = []
|
||||
for i in range(140, 151):
|
||||
project_id = f'p_reckoning_{i}'
|
||||
if project_id in content:
|
||||
# Find cost line
|
||||
lines = content.split('\n')
|
||||
for line in lines:
|
||||
if project_id in line:
|
||||
# Find next few lines for cost
|
||||
idx = lines.index(line)
|
||||
for j in range(idx, min(idx+10, len(lines))):
|
||||
if 'impact:' in lines[j]:
|
||||
# Extract number from "impact: 100000" or "impact: 100000 }"
|
||||
import re
|
||||
match = re.search(r'impact:\s*(\d+)', lines[j])
|
||||
if match:
|
||||
costs.append(int(match.group(1)))
|
||||
break
|
||||
|
||||
# Check costs increase
|
||||
for i in range(1, len(costs)):
|
||||
assert costs[i] > costs[i-1], f"Cost doesn't increase: {costs[i]} <= {costs[i-1]}"
|
||||
|
||||
print(f"✓ ReCKoning costs increase: {costs[:3]}...{costs[-3:]}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Testing ReCKoning project chain...")
|
||||
test_reckoning_projects_exist()
|
||||
test_reckoning_project_structure()
|
||||
test_reckoning_trigger_conditions()
|
||||
test_reckoning_chain_progression()
|
||||
test_reckoning_final_project()
|
||||
test_reckoning_costs_increase()
|
||||
print("\n✓ All tests passed!")
|
||||
Reference in New Issue
Block a user