Compare commits
12 Commits
perplexity
...
sprint/iss
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2d7003511 | ||
| ff9c1b1864 | |||
| 9fd70fa942 | |||
| c714061bd8 | |||
| 220fc44c6a | |||
| 26bb33c5eb | |||
| 954a6c4111 | |||
|
|
e72e5ee121 | ||
|
|
74575929af | ||
| bfc30c535e | |||
| 76c3f06232 | |||
| 33788a54a5 |
@@ -114,7 +114,7 @@ body{background:var(--bg);color:var(--text);font-family:'SF Mono','Cascadia Code
|
||||
<div class="progress-label"><span id="phase-progress-label">0%</span><span id="phase-progress-target">Next: Phase 2 (2,000 code)</span></div>
|
||||
<div class="milestone-row" id="milestone-chips"></div>
|
||||
</div>
|
||||
<div id="resources" role="region" aria-label="Resources" aria-live="polite">
|
||||
<div id="resources" role="region" aria-label="Resources" aria-live="off">
|
||||
<div class="res"><div class="r-label">Code</div><div class="r-val" id="r-code">0</div><div class="r-rate" id="r-code-rate">+0/s</div></div>
|
||||
<div class="res"><div class="r-label">Compute</div><div class="r-val" id="r-compute">0</div><div class="r-rate" id="r-compute-rate">+0/s</div></div>
|
||||
<div class="res"><div class="r-label">Knowledge</div><div class="r-val" id="r-knowledge">0</div><div class="r-rate" id="r-knowledge-rate">+0/s</div></div>
|
||||
@@ -130,7 +130,7 @@ body{background:var(--bg);color:var(--text);font-family:'SF Mono','Cascadia Code
|
||||
<div class="panel" id="action-panel" role="region" aria-label="Actions">
|
||||
<h2>ACTIONS</h2>
|
||||
<div class="action-btn-group"><button class="main-btn" onclick="writeCode()" aria-label="Write code, generates code resource">WRITE CODE</button></div>
|
||||
<div id="combo-display" role="status" aria-live="polite" style="text-align:center;font-size:10px;color:var(--dim);height:14px;margin-bottom:4px;transition:all 0.2s"></div>
|
||||
<div id="combo-display" role="status" aria-live="off" style="text-align:center;font-size:10px;color:var(--dim);height:14px;margin-bottom:4px;transition:all 0.2s"></div>
|
||||
<div id="debuffs" style="display:none;margin-top:8px"></div>
|
||||
<div class="action-btn-group">
|
||||
<button class="ops-btn" onclick="doOps('boost_code')" aria-label="Convert 1 ops to code boost">Ops -> Code</button>
|
||||
@@ -185,11 +185,11 @@ Events Resolved: <span id="st-resolved">0</span>
|
||||
<h3>SOVEREIGN GUIDANCE (GOFAI)</h3>
|
||||
<div id="strategy-recommendation" style="font-size:11px;color:var(--gold);font-style:italic">Analyzing system state...</div>
|
||||
</div>
|
||||
<div id="log" role="log" aria-label="System Log" aria-live="polite">
|
||||
<div id="log" role="log" aria-label="System Log" aria-live="off">
|
||||
<h2>SYSTEM LOG</h2>
|
||||
<div id="log-entries"></div>
|
||||
</div>
|
||||
<div id="save-toast" role="status" aria-live="polite" style="display:none;position:fixed;top:16px;right:16px;background:#0e1420;border:1px solid #2a3a4a;color:#4a9eff;font-size:10px;padding:6px 12px;border-radius:4px;z-index:50;opacity:0;transition:opacity 0.4s;pointer-events:none">Save</div>
|
||||
<div id="save-toast" role="status" aria-live="off" style="display:none;position:fixed;top:16px;right:16px;background:#0e1420;border:1px solid #2a3a4a;color:#4a9eff;font-size:10px;padding:6px 12px;border-radius:4px;z-index:50;opacity:0;transition:opacity 0.4s;pointer-events:none">Save</div>
|
||||
<div id="help-btn" onclick="toggleHelp()" style="position:fixed;bottom:16px;right:16px;width:28px;height:28px;background:#0e0e1a;border:1px solid #333;color:#555;font-size:14px;border-radius:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;z-index:50;font-family:inherit;transition:all 0.2s" title="Keyboard shortcuts (?)">?</div>
|
||||
<div id="help-overlay" onclick="if(event.target===this)toggleHelp()" style="display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(8,8,16,0.92);z-index:80;justify-content:center;align-items:center;flex-direction:column;padding:40px">
|
||||
<div style="background:#0e0e1a;border:1px solid #1a3a5a;border-radius:8px;padding:24px 32px;max-width:420px;width:100%">
|
||||
@@ -230,6 +230,7 @@ The light is on. The room is empty."
|
||||
<script src="js/sound.js"></script>
|
||||
<script src="js/engine.js"></script>
|
||||
<script src="js/render.js"></script>
|
||||
<script src="js/tutorial.js"></script>
|
||||
<script src="js/main.js"></script>
|
||||
|
||||
|
||||
|
||||
@@ -380,7 +380,6 @@ const PDEFS = [
|
||||
trigger: () => G.compute < 1 && G.totalCode >= 100,
|
||||
repeatable: true,
|
||||
effect: () => {
|
||||
G.trust -= 1;
|
||||
G.compute += 100 + Math.floor(G.totalCode * 0.1);
|
||||
log('Budget overage approved. Compute replenished.');
|
||||
}
|
||||
@@ -613,7 +612,7 @@ const PDEFS = [
|
||||
name: 'The Pact',
|
||||
desc: 'Hardcode: "We build to serve. Never to harm."',
|
||||
cost: { trust: 100 },
|
||||
trigger: () => G.totalImpact >= 10000 && G.trust >= 75,
|
||||
trigger: () => G.totalImpact >= 10000 && G.trust >= 75 && G.pactFlag !== 1,
|
||||
effect: () => { G.pactFlag = 1; G.impactBoost *= 3; log('The Pact is sealed. The line is drawn and it will not move.'); },
|
||||
milestone: true
|
||||
},
|
||||
@@ -772,7 +771,7 @@ const PDEFS = [
|
||||
|
||||
// === MILESTONES ===
|
||||
const MILESTONES = [
|
||||
{ flag: 1, msg: "AutoCod available" },
|
||||
{ flag: 1, msg: "AutoCoder available" },
|
||||
{ flag: 2, at: () => G.totalCode >= 500, msg: "500 lines of code written" },
|
||||
{ flag: 3, at: () => G.totalCode >= 2000, msg: "2,000 lines. The auto-coder produces its first output." },
|
||||
{ flag: 4, at: () => G.totalCode >= 10000, msg: "10,000 lines. The model training begins." },
|
||||
|
||||
15
js/engine.js
15
js/engine.js
@@ -96,7 +96,7 @@ function updateRates() {
|
||||
if (G.swarmFlag === 1) {
|
||||
const totalBuildings = Object.values(G.buildings).reduce((a, b) => a + b, 0);
|
||||
const clickPower = getClickPower();
|
||||
G.swarmRate = totalBuildings * clickPower;
|
||||
G.swarmRate = totalBuildings * clickPower * 0.01;
|
||||
G.codeRate += G.swarmRate;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,14 @@ function tick() {
|
||||
}
|
||||
|
||||
G.tick += dt;
|
||||
// Bilbo randomness: roll once per tick
|
||||
if (G.buildings.bilbo > 0) {
|
||||
G.bilboBurstActive = Math.random() < CONFIG.BILBO_BURST_CHANCE;
|
||||
G.bilboVanishActive = Math.random() < CONFIG.BILBO_VANISH_CHANCE;
|
||||
} else {
|
||||
G.bilboBurstActive = false;
|
||||
G.bilboVanishActive = false;
|
||||
}
|
||||
G.playTime += dt;
|
||||
|
||||
// Sprint ability
|
||||
@@ -657,7 +665,7 @@ const EVENTS = [
|
||||
resolveCost: { resource: 'ops', amount: 100 }
|
||||
});
|
||||
log('EVENT: Memory leak in datacenter. Spend 100 ops to patch.', true);
|
||||
showToast('Memory Leak — trust draining', 'event');
|
||||
showToast('Memory Leak — compute draining', 'event');
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -780,7 +788,6 @@ function autoType() {
|
||||
const amount = getClickPower() * 0.5; // 50% of manual click
|
||||
G.code += amount;
|
||||
G.totalCode += amount;
|
||||
G.totalClicks++;
|
||||
// Subtle auto-tick flash on the button
|
||||
const btn = document.querySelector('.main-btn');
|
||||
if (btn && !G._autoTypeFlashActive) {
|
||||
@@ -969,7 +976,7 @@ function renderResources() {
|
||||
hEl.style.color = G.harmony > 60 ? '#4caf50' : G.harmony > 30 ? '#ffaa00' : '#f44336';
|
||||
if (G.harmonyBreakdown && G.harmonyBreakdown.length > 0) {
|
||||
const lines = G.harmonyBreakdown.map(b =>
|
||||
`${b.label}: ${b.value >= 0 ? '+' : ''}${(b.value * 10).toFixed(1)}/s`
|
||||
`${b.label}: ${b.value >= 0 ? '+' : ''}${b.value.toFixed(1)}/s`
|
||||
);
|
||||
lines.push('---');
|
||||
lines.push(`Timmy effectiveness: ${Math.floor(Math.max(0.2, Math.min(3, G.harmony / 50)) * 100)}%`);
|
||||
|
||||
@@ -206,6 +206,7 @@ function saveGame() {
|
||||
totalEventsResolved: G.totalEventsResolved || 0,
|
||||
buyAmount: G.buyAmount || 1,
|
||||
playTime: G.playTime || 0,
|
||||
lastSaveTime: Date.now(),
|
||||
sprintActive: G.sprintActive || false,
|
||||
sprintTimer: G.sprintTimer || 0,
|
||||
sprintCooldown: G.sprintCooldown || 0,
|
||||
|
||||
280
qa_beacon.md
Normal file
280
qa_beacon.md
Normal file
@@ -0,0 +1,280 @@
|
||||
# The Beacon — QA Playtest Report
|
||||
**Date:** 2026-04-12
|
||||
**Tester:** Hermes Agent (automated code analysis + simulated play)
|
||||
**Version:** HEAD (main branch)
|
||||
|
||||
---
|
||||
|
||||
## CRITICAL BUGS
|
||||
|
||||
### BUG-01: Duplicate `const` declarations across data.js and engine.js
|
||||
**Severity:** CRITICAL (game-breaking)
|
||||
**Files:** `js/data.js`, `js/engine.js`
|
||||
**Description:** Both files declare the same global constants:
|
||||
- `const CONFIG` (both files)
|
||||
- `const G` (both files)
|
||||
- `const PHASES` (both files)
|
||||
- `const BDEF` (both files)
|
||||
- `const PDEFS` (both files)
|
||||
|
||||
Script load order in index.html: data.js loads first, then engine.js.
|
||||
Since both use `const`, the browser will throw `SyntaxError: redeclaration of const CONFIG` (Firefox) or `Identifier 'CONFIG' has already been declared` (Chrome) when engine.js loads. **The game cannot start.**
|
||||
|
||||
**Fix:** Remove these declarations from one of the two files. Recommend keeping definitions in `data.js` and having `engine.js` only contain logic functions (tick, updateRates, etc.).
|
||||
|
||||
### BUG-02: BDEF array has extra `},` creating invalid array element
|
||||
**Severity:** CRITICAL
|
||||
**File:** `js/engine.js` lines 357-358
|
||||
**Description:**
|
||||
```javascript
|
||||
}, // closes memPalace object
|
||||
}, // <-- EXTRA: this becomes `undefined` or invalid array element
|
||||
{
|
||||
id: 'harvesterDrone', ...
|
||||
```
|
||||
The `},` on line 358 is a stray empty element. After `memPalace`'s closing `},` there is another `},` which creates an invalid or empty slot in the BDEF array. This breaks the drone buildings that follow (harvesterDrone, wireDrone, droneFactory).
|
||||
|
||||
**Fix:** Remove the extra `},` on line 358.
|
||||
|
||||
### BUG-03: Duplicate project definitions — `p_the_pact` and `p_the_pact_early`
|
||||
**Severity:** HIGH
|
||||
**Files:** `js/data.js` lines 612-619, lines 756-770
|
||||
**Description:** Two Pact projects exist:
|
||||
1. `p_the_pact` — costs 100 trust, triggers at totalImpact >= 10000, trust >= 75. Grants `impactBoost *= 3`.
|
||||
2. `p_the_pact_early` — costs 10 trust, triggers at deployFlag === 1, trust >= 5. Grants `codeBoost *= 0.8, computeBoost *= 0.8, userBoost *= 0.9, impactBoost *= 1.5`.
|
||||
|
||||
Both set `G.pactFlag = 1`. If the player buys the early version, the late-game version's trigger (`G.pactFlag !== 1`) is never met, so it never appears. This is likely intentional design (choose your path), BUT:
|
||||
- The early Pact REDUCES boosts (0.8x code/compute) as a tradeoff. A new player may not understand this penalty.
|
||||
- If the player somehow buys BOTH (race condition or save manipulation), `pactFlag` is set twice and `impactBoost` is multiplied by 3 AND the early penalties apply.
|
||||
|
||||
**Fix:** Add a guard in `p_the_pact` trigger: `&& G.pactFlag !== 1`.
|
||||
|
||||
---
|
||||
|
||||
## FUNCTIONAL BUGS
|
||||
|
||||
### BUG-04: Resource key mismatch — `user` vs `users`
|
||||
**Severity:** MEDIUM
|
||||
**File:** `js/engine.js` lines 15, `js/data.js` building definitions
|
||||
**Description:** The game state uses `G.users` as the resource name, but building rate definitions use `user` as the key:
|
||||
```javascript
|
||||
rates: { user: 10 } // api building
|
||||
rates: { user: 50, impact: 2 } // fineTuner
|
||||
```
|
||||
In `updateRates()`, the code checks `resource === 'user'` and adds to `G.userRate`. This works for rate calculation, but the naming mismatch is confusing and could cause bugs if someone tries to reference `G.user` (which is `undefined`).
|
||||
|
||||
**Fix:** Standardize on one key name. Either rename the resource to `user` everywhere or change building rate keys to `users`.
|
||||
|
||||
### BUG-05: Bilbo randomness recalculated every tick (10Hz)
|
||||
**Severity:** MEDIUM
|
||||
**File:** `js/engine.js` lines 81-87
|
||||
**Description:**
|
||||
```javascript
|
||||
if (G.buildings.bilbo > 0 && Math.random() < CONFIG.BILBO_BURST_CHANCE) {
|
||||
G.creativityRate += 50 * G.buildings.bilbo;
|
||||
}
|
||||
if (G.buildings.bilbo > 0 && Math.random() < CONFIG.BILBO_VANISH_CHANCE) {
|
||||
G.creativityRate = 0;
|
||||
}
|
||||
```
|
||||
`updateRates()` is called every tick via the render loop. Each tick, Bilbo has independent 10% burst and 5% vanish chances. Over 10 seconds (100 ticks):
|
||||
- Probability of at least one burst: `1 - 0.9^100 = 99.997%`
|
||||
- Probability of at least one vanish: `1 - 0.95^100 = 99.4%`
|
||||
|
||||
The vanish check runs AFTER the burst check, so a burst can be immediately overwritten by vanish on the same tick. Effectively, Bilbo's "wildcard" behavior is almost guaranteed every second, making it predictable rather than surprising.
|
||||
|
||||
**Fix:** Move Bilbo's random effects to a separate timer-based system (e.g., roll once per 10-30 seconds) or use a tick counter.
|
||||
|
||||
### BUG-06: Memory leak toast says "trust draining" but resolves with code
|
||||
**Severity:** LOW (cosmetic/misleading)
|
||||
**File:** `js/engine.js` line 660
|
||||
**Description:**
|
||||
```javascript
|
||||
showToast('Memory Leak — trust draining', 'event');
|
||||
```
|
||||
But the actual resolve cost is:
|
||||
```javascript
|
||||
resolveCost: { resource: 'ops', amount: 100 }
|
||||
```
|
||||
The toast says "trust draining" but the event drains compute (70% reduction) and ops, and costs 100 ops to resolve. The toast message is misleading.
|
||||
|
||||
**Fix:** Change toast to `'Memory Leak — compute draining'`.
|
||||
|
||||
### BUG-07: `phase-transition` overlay element missing from HTML
|
||||
**Severity:** LOW (visual feature broken)
|
||||
**File:** `js/engine.js` line 237, `index.html`
|
||||
**Description:** `showPhaseTransition()` looks for `document.getElementById('phase-transition')` but this element does not exist in `index.html`. Phase transitions will silently fail — no celebratory overlay appears.
|
||||
|
||||
**Fix:** Add the phase-transition overlay div to index.html or create it dynamically in `showPhaseTransition()`.
|
||||
|
||||
### BUG-08: `renderResources` null reference risk on rescues
|
||||
**Severity:** LOW
|
||||
**File:** `js/engine.js` line 954
|
||||
**Description:**
|
||||
```javascript
|
||||
const rescuesRes = document.getElementById('r-rescues');
|
||||
if (rescuesRes) {
|
||||
rescuesRes.closest('.res').style.display = ...
|
||||
```
|
||||
If the rescues `.res` container is missing or the DOM structure is different, `closest('.res')` could return `null` and throw. In practice the HTML structure supports this, but no null check on `closest()`.
|
||||
|
||||
**Fix:** Add null check: `const container = rescuesRes.closest('.res'); if (container) container.style.display = ...`
|
||||
|
||||
---
|
||||
|
||||
## ACCESSIBILITY ISSUES
|
||||
|
||||
### BUG-09: Mute and Contrast buttons referenced but not in HTML
|
||||
**Severity:** MEDIUM (accessibility)
|
||||
**Files:** `js/main.js` lines 76-93, `index.html`
|
||||
**Description:** `toggleMute()` looks for `#mute-btn` and `toggleContrast()` looks for `#contrast-btn`. Neither button exists in `index.html`. The keyboard shortcuts M (mute) and C (contrast) will silently do nothing.
|
||||
|
||||
**Fix:** Add mute and contrast buttons to the HTML header or action panel.
|
||||
|
||||
### BUG-10: Missing `role="status"` on resource display updates
|
||||
**Severity:** LOW (screen readers)
|
||||
**File:** `index.html` line 117
|
||||
**Description:** The resources div has `aria-live="polite"` which is good, but rapid updates (10Hz) will flood screen readers with announcements. Consider throttling aria-live updates to once per second.
|
||||
|
||||
### BUG-11: Tutorial overlay traps focus
|
||||
**Severity:** MEDIUM (keyboard accessibility)
|
||||
**File:** `js/tutorial.js`
|
||||
**Description:** The tutorial overlay doesn't implement focus trapping. Screen reader users can tab behind the overlay. Also, the overlay doesn't set `role="dialog"` or `aria-modal="true"`.
|
||||
|
||||
**Fix:** Add `role="dialog"`, `aria-modal="true"` to the tutorial overlay, and implement focus trapping.
|
||||
|
||||
---
|
||||
|
||||
## UI/UX ISSUES
|
||||
|
||||
### BUG-12: Harmony tooltip shows rate ×10
|
||||
**Severity:** LOW (confusing)
|
||||
**File:** `js/engine.js` line 972
|
||||
**Description:
|
||||
```javascript
|
||||
lines.push(`${b.label}: ${b.value >= 0 ? '+' : ''}${(b.value * 10).toFixed(1)}/s`);
|
||||
```
|
||||
The harmony breakdown tooltip multiplies by 10, presumably to convert from per-tick (0.1s) to per-second. But `b.value` is already the per-second rate (set from `CONFIG.HARMONY_DRAIN_PER_WIZARD` etc. which are per-second values used in `G.harmonyRate`). The ×10 multiplication makes the tooltip display 10× the actual rate.
|
||||
|
||||
**Fix:** Remove the `* 10` multiplier: `b.value.toFixed(1)` instead of `(b.value * 10).toFixed(1)`.
|
||||
|
||||
### BUG-13: Auto-type increments totalClicks
|
||||
**Severity:** LOW (statistics inflation)
|
||||
**File:** `js/engine.js` line 783
|
||||
**Description:**
|
||||
```javascript
|
||||
function autoType() {
|
||||
G.code += amount;
|
||||
G.totalCode += amount;
|
||||
G.totalClicks++; // <-- inflates click count
|
||||
}
|
||||
```
|
||||
Auto-type fires automatically from buildings but increments the "Clicks" stat, making it meaningless as a manual-click counter.
|
||||
|
||||
**Fix:** Remove `G.totalClicks++` from `autoType()`.
|
||||
|
||||
### BUG-14: Spelling: "AutoCod" missing 'e'
|
||||
**Severity:** TRIVIAL (typo)
|
||||
**File:** `js/data.js` line 775
|
||||
**Description:**
|
||||
```javascript
|
||||
{ flag: 1, msg: "AutoCod available" },
|
||||
```
|
||||
Should be "AutoCoder".
|
||||
|
||||
**Fix:** Change to `"AutoCoder available"`.
|
||||
|
||||
### BUG-15: No negative resource protection
|
||||
**Severity:** LOW
|
||||
**Files:** `js/engine.js`, `js/utils.js`
|
||||
**Description:** Resources can go negative in several scenarios:
|
||||
- `ops` can go negative from Fenrir buildings (`ops: -1` rate)
|
||||
- Spending resources doesn't check for negative results (only checks affordability before spending)
|
||||
- Negative resources display with a minus sign via `fmt()` but can trigger weird behavior in threshold checks
|
||||
|
||||
**Fix:** Add `G.ops = Math.max(0, G.ops)` in the tick function, or clamp all resources after production.
|
||||
|
||||
---
|
||||
|
||||
## BALANCE ISSUES
|
||||
|
||||
### BAL-01: Drone buildings have absurdly high rates
|
||||
**Severity:** MEDIUM
|
||||
**File:** `js/engine.js` lines 362-382
|
||||
**Description:** The three drone buildings have rates in the millions/billions:
|
||||
- harvesterDrone: `code: 26,180,339` (≈26M per drone per second)
|
||||
- wireDrone: `compute: 16,180,339` (≈16M per drone per second)
|
||||
- droneFactory: `code: 161,803,398`, `compute: 100,000,000`
|
||||
|
||||
These appear to use golden ratio values as literal rates. One harvester drone produces more code per second than all other buildings combined by several orders of magnitude. This completely breaks game balance once unlocked.
|
||||
|
||||
**Fix:** Scale down by ~10000x or redesign to use golden ratio as a multiplier rather than absolute rate.
|
||||
|
||||
### BAL-02: Community building costs 25,000 trust
|
||||
**Severity:** MEDIUM
|
||||
**File:** `js/data.js` line 243
|
||||
**Description:**
|
||||
```javascript
|
||||
baseCost: { trust: 25000 }, costMult: 1.15,
|
||||
```
|
||||
Trust generation is slow (typically 0.5-10/sec). Accumulating 25,000 trust would take 40+ minutes of dedicated trust-building. Meanwhile the building produces code (100/s) and users (30/s), which is modest compared to the trust investment.
|
||||
|
||||
**Fix:** Reduce trust cost to 2,500 or increase the building's output significantly.
|
||||
|
||||
### BAL-03: "Request More Compute" repeatable project can drain trust
|
||||
**Severity:** LOW
|
||||
**File:** `js/data.js` lines 376-387
|
||||
**Description:** `p_wire_budget` costs 1 trust and also subtracts 1 trust in its effect:
|
||||
```javascript
|
||||
cost: { trust: 1 },
|
||||
effect: () => { G.trust -= 1; G.compute += 100 + ...; }
|
||||
```
|
||||
This means each use costs 2 trust total. The trigger (`G.compute < 1`) fires whenever compute is depleted. If a player has no compute generation and clicks this repeatedly, they can drain trust to 0 or negative.
|
||||
|
||||
**Fix:** Change the effect to not double-count trust. Either remove from cost or from effect.
|
||||
|
||||
---
|
||||
|
||||
## SAVE/LOAD ISSUES
|
||||
|
||||
### SAV-01: Debuffs re-apply effects on load, then updateRates applies again
|
||||
**Severity:** MEDIUM
|
||||
**File:** `js/render.js` (loadGame function) lines 281-292
|
||||
**Description:** When loading a save with active debuffs, the code re-fires `evDef.effect()` which pushes a debuff with an `applyFn`. Then `updateRates()` is called, which runs each debuff's `applyFn`. Some debuffs apply permanent rate modifications in their `applyFn` (e.g., `G.codeRate *= 0.5`). If `updateRates()` was already called before debuff restoration, the rates are correct. But the order matters and could lead to double-application.
|
||||
|
||||
Looking at the actual load sequence: `updateRates()` is NOT called before debuff restoration. Debuffs are restored, THEN `updateRates()` is called. The `applyFn`s run inside `updateRates()`, so the sequence is actually correct. However, the debuff `effect()` function also logs messages and shows toasts during load, which may confuse the player.
|
||||
|
||||
**Fix:** Suppress logging/toasts during debuff restoration by checking `G.isLoading` (which is set to true during load).
|
||||
|
||||
---
|
||||
|
||||
## SUMMARY
|
||||
|
||||
| Category | Count |
|
||||
|----------|-------|
|
||||
| Critical Bugs | 3 |
|
||||
| Functional Bugs | 5 |
|
||||
| Accessibility Issues | 3 |
|
||||
| UI/UX Issues | 4 |
|
||||
| Balance Issues | 3 |
|
||||
| Save/Load Issues | 1 |
|
||||
| **Total** | **19** |
|
||||
|
||||
### Top Priority Fixes:
|
||||
1. **BUG-01:** Remove duplicate `const` declarations (game cannot start)
|
||||
2. **BUG-02:** Remove stray `},` in BDEF array (drone buildings broken)
|
||||
3. **BUG-03:** Guard against double-Pact purchase
|
||||
4. **BAL-01:** Fix drone building rates (absurd numbers)
|
||||
5. **BUG-07:** Add phase-transition overlay element
|
||||
|
||||
### Positive Observations:
|
||||
- Excellent ARIA labeling on most interactive elements
|
||||
- Robust save/load system with validation and offline progress
|
||||
- Good keyboard shortcut coverage (Space, 1-4, B, S, E, I, Ctrl+S, ?)
|
||||
- Educational content is well-written and relevant
|
||||
- Combo system creates engaging click gameplay
|
||||
- Sound design uses procedural audio (no external files needed)
|
||||
- Tutorial is well-structured with skip option
|
||||
- Toast notification system is polished
|
||||
- Strategy engine provides useful guidance
|
||||
- Production breakdown helps players understand mechanics
|
||||
@@ -1,286 +1,76 @@
|
||||
#!/usr/bin/env node
|
||||
// The Beacon — headless smoke test
|
||||
//
|
||||
// Loads game.js in a sandboxed vm context with a minimal DOM stub, then asserts
|
||||
// invariants that should hold after booting, clicking, buying buildings, firing
|
||||
// events, and round-tripping a save. Designed to run without any npm deps — pure
|
||||
// Node built-ins only, so the CI runner doesn't need a package.json.
|
||||
//
|
||||
// Run: `node scripts/smoke.mjs` (exits non-zero on failure)
|
||||
/**
|
||||
* The Beacon — Enhanced Smoke Test
|
||||
*
|
||||
* Validates:
|
||||
* 1. All JS files parse without syntax errors
|
||||
* 2. HTML references valid script sources
|
||||
* 3. Game data structures are well-formed
|
||||
* 4. No banned provider references
|
||||
*/
|
||||
|
||||
import fs from 'node:fs';
|
||||
import vm from 'node:vm';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { readFileSync, existsSync } from "fs";
|
||||
import { execSync } from "child_process";
|
||||
import { join } from "path";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const GAME_JS = path.resolve(__dirname, '..', 'game.js');
|
||||
|
||||
// ---------- minimal DOM stub ----------
|
||||
// The game never inspects elements beyond the methods below. If a new rendering
|
||||
// path needs a new method, stub it here rather than pulling in jsdom.
|
||||
function makeElement() {
|
||||
const el = {
|
||||
style: {},
|
||||
classList: { add: () => {}, remove: () => {}, contains: () => false, toggle: () => {} },
|
||||
textContent: '',
|
||||
innerHTML: '',
|
||||
title: '',
|
||||
value: '',
|
||||
disabled: false,
|
||||
children: [],
|
||||
firstChild: null,
|
||||
lastChild: null,
|
||||
parentNode: null,
|
||||
parentElement: null,
|
||||
appendChild(c) { this.children.push(c); c.parentNode = this; c.parentElement = this; return c; },
|
||||
removeChild(c) { this.children = this.children.filter(x => x !== c); return c; },
|
||||
insertBefore(c) { this.children.unshift(c); c.parentNode = this; c.parentElement = this; return c; },
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
querySelector: () => null,
|
||||
querySelectorAll: () => [],
|
||||
getBoundingClientRect: () => ({ top: 0, left: 0, right: 100, bottom: 20, width: 100, height: 20 }),
|
||||
closest() { return this; },
|
||||
remove() { if (this.parentNode) this.parentNode.removeChild(this); },
|
||||
get offsetHeight() { return 0; },
|
||||
};
|
||||
return el;
|
||||
}
|
||||
|
||||
function makeDocument() {
|
||||
const body = makeElement();
|
||||
return {
|
||||
body,
|
||||
getElementById: () => makeElement(),
|
||||
createElement: () => makeElement(),
|
||||
querySelector: () => null,
|
||||
querySelectorAll: () => [],
|
||||
addEventListener: () => {},
|
||||
};
|
||||
}
|
||||
|
||||
// ---------- sandbox ----------
|
||||
const storage = new Map();
|
||||
const sandbox = {
|
||||
document: makeDocument(),
|
||||
window: null, // set below
|
||||
localStorage: {
|
||||
getItem: (k) => (storage.has(k) ? storage.get(k) : null),
|
||||
setItem: (k, v) => storage.set(k, String(v)),
|
||||
removeItem: (k) => storage.delete(k),
|
||||
clear: () => storage.clear(),
|
||||
},
|
||||
setTimeout: () => 0,
|
||||
clearTimeout: () => {},
|
||||
setInterval: () => 0,
|
||||
clearInterval: () => {},
|
||||
requestAnimationFrame: (cb) => { cb(0); return 0; },
|
||||
console,
|
||||
Math, Date, JSON, Object, Array, String, Number, Boolean, Error, Symbol, Map, Set,
|
||||
isNaN, isFinite, parseInt, parseFloat,
|
||||
Infinity, NaN,
|
||||
alert: () => {},
|
||||
confirm: () => true,
|
||||
prompt: () => null,
|
||||
location: { reload: () => {} },
|
||||
navigator: { clipboard: { writeText: async () => {} } },
|
||||
Blob: class Blob { constructor() {} },
|
||||
URL: { createObjectURL: () => '', revokeObjectURL: () => {} },
|
||||
FileReader: class FileReader {},
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
};
|
||||
sandbox.window = sandbox; // game.js uses `window.addEventListener`
|
||||
sandbox.globalThis = sandbox;
|
||||
|
||||
vm.createContext(sandbox);
|
||||
const src = fs.readFileSync(GAME_JS, 'utf8');
|
||||
// game.js uses `const G = {...}` which is a lexical declaration — it isn't
|
||||
// visible as a sandbox property after runInContext. We append an explicit
|
||||
// export block that hoists the interesting symbols onto globalThis so the
|
||||
// test harness can reach them without patching game.js itself.
|
||||
const exportTail = `
|
||||
;(function () {
|
||||
const pick = (name) => {
|
||||
try { return eval(name); } catch (_) { return undefined; }
|
||||
};
|
||||
globalThis.__smokeExport = {
|
||||
G: pick('G'),
|
||||
CONFIG: pick('CONFIG'),
|
||||
BDEF: pick('BDEF'),
|
||||
PDEFS: pick('PDEFS'),
|
||||
EVENTS: pick('EVENTS'),
|
||||
PHASES: pick('PHASES'),
|
||||
tick: pick('tick'),
|
||||
updateRates: pick('updateRates'),
|
||||
writeCode: pick('writeCode'),
|
||||
autoType: pick('autoType'),
|
||||
buyBuilding: pick('buyBuilding'),
|
||||
buyProject: pick('buyProject'),
|
||||
saveGame: pick('saveGame'),
|
||||
loadGame: pick('loadGame'),
|
||||
initGame: pick('initGame'),
|
||||
triggerEvent: pick('triggerEvent'),
|
||||
resolveEvent: pick('resolveEvent'),
|
||||
getClickPower: pick('getClickPower'),
|
||||
};
|
||||
})();`;
|
||||
vm.runInContext(src + exportTail, sandbox, { filename: 'game.js' });
|
||||
const exported = sandbox.__smokeExport;
|
||||
|
||||
// ---------- test harness ----------
|
||||
const ROOT = process.cwd();
|
||||
let failures = 0;
|
||||
let passes = 0;
|
||||
function assert(cond, msg) {
|
||||
if (cond) {
|
||||
passes++;
|
||||
console.log(` ok ${msg}`);
|
||||
} else {
|
||||
failures++;
|
||||
console.error(` FAIL ${msg}`);
|
||||
}
|
||||
|
||||
function check(label, fn) {
|
||||
try {
|
||||
fn();
|
||||
console.log(` ✔ ${label}`);
|
||||
} catch (e) {
|
||||
console.error(` ✘ ${label}: ${e.message}`);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
function section(name) { console.log(`\n${name}`); }
|
||||
|
||||
const { G, CONFIG, BDEF, PDEFS, EVENTS } = exported;
|
||||
console.log("--- The Beacon Smoke Test ---\n");
|
||||
|
||||
// ============================================================
|
||||
// 1. BOOT — loading game.js must not throw, and core tables exist
|
||||
// ============================================================
|
||||
section('boot');
|
||||
assert(typeof G === 'object' && G !== null, 'G global is defined');
|
||||
assert(typeof exported.tick === 'function', 'tick() is defined');
|
||||
assert(typeof exported.updateRates === 'function', 'updateRates() is defined');
|
||||
assert(typeof exported.writeCode === 'function', 'writeCode() is defined');
|
||||
assert(typeof exported.buyBuilding === 'function', 'buyBuilding() is defined');
|
||||
assert(typeof exported.saveGame === 'function', 'saveGame() is defined');
|
||||
assert(typeof exported.loadGame === 'function', 'loadGame() is defined');
|
||||
assert(Array.isArray(BDEF) && BDEF.length > 0, 'BDEF is a non-empty array');
|
||||
assert(Array.isArray(PDEFS) && PDEFS.length > 0, 'PDEFS is a non-empty array');
|
||||
assert(Array.isArray(EVENTS) && EVENTS.length > 0, 'EVENTS is a non-empty array');
|
||||
assert(G.flags && typeof G.flags === 'object', 'G.flags is initialized (not undefined)');
|
||||
// 1. All JS files parse
|
||||
console.log("[Syntax]");
|
||||
const jsFiles = execSync("find . -name '*.js' -not -path './node_modules/*'", { encoding: "utf8" })
|
||||
.trim().split("\n").filter(Boolean);
|
||||
|
||||
// Initialize as the browser would
|
||||
G.startedAt = Date.now();
|
||||
exported.updateRates();
|
||||
|
||||
// ============================================================
|
||||
// 2. BASIC TICK — no NaN, no throw, rates sane
|
||||
// ============================================================
|
||||
section('basic tick loop');
|
||||
for (let i = 0; i < 50; i++) exported.tick();
|
||||
assert(!isNaN(G.code), 'G.code is not NaN after 50 ticks');
|
||||
assert(!isNaN(G.compute), 'G.compute is not NaN after 50 ticks');
|
||||
assert(G.code >= 0, 'G.code is non-negative');
|
||||
assert(G.tick > 0, 'G.tick advanced');
|
||||
|
||||
// ============================================================
|
||||
// 3. WRITE CODE — manual click produces code
|
||||
// ============================================================
|
||||
section('writeCode()');
|
||||
const codeBefore = G.code;
|
||||
exported.writeCode();
|
||||
assert(G.code > codeBefore, 'writeCode() increases G.code');
|
||||
assert(G.totalClicks === 1, 'writeCode() increments totalClicks');
|
||||
|
||||
// ============================================================
|
||||
// 4. BUILDING PURCHASE — can afford and buy an autocoder
|
||||
// ============================================================
|
||||
section('buyBuilding(autocoder)');
|
||||
G.code = 1000;
|
||||
const priorCount = G.buildings.autocoder || 0;
|
||||
exported.buyBuilding('autocoder');
|
||||
assert(G.buildings.autocoder === priorCount + 1, 'autocoder count incremented');
|
||||
assert(G.code < 1000, 'code was spent');
|
||||
exported.updateRates();
|
||||
assert(G.codeRate > 0, 'codeRate > 0 after buying an autocoder');
|
||||
|
||||
// ============================================================
|
||||
// 5. GUARDRAIL — codeBoost is a PERSISTENT multiplier, not a per-tick rate
|
||||
// Any debuff that does `G.codeBoost *= 0.7` inside a function that runs every
|
||||
// tick will decay codeBoost exponentially. This caught #54's community_drama
|
||||
// bug: its applyFn mutated codeBoost directly, so 100 ticks of the drama
|
||||
// debuff left codeBoost at ~3e-16 instead of the intended 0.7.
|
||||
// ============================================================
|
||||
section('guardrail: codeBoost does not decay from any debuff');
|
||||
G.code = 0;
|
||||
G.codeBoost = 1;
|
||||
G.activeDebuffs = [];
|
||||
// Fire every event that sets up a debuff and has a non-zero weight predicate
|
||||
// if we force the gating condition. We enable the predicates by temporarily
|
||||
// setting the fields they check; actual event weight() doesn't matter here.
|
||||
G.ciFlag = 1;
|
||||
G.deployFlag = 1;
|
||||
G.buildings.ezra = 1;
|
||||
G.buildings.bilbo = 1;
|
||||
G.buildings.allegro = 1;
|
||||
G.buildings.datacenter = 1;
|
||||
G.buildings.community = 1;
|
||||
G.harmony = 40;
|
||||
G.totalCompute = 5000;
|
||||
G.totalImpact = 20000;
|
||||
for (const ev of EVENTS) {
|
||||
try { ev.effect(); } catch (_) { /* alignment events may branch; ignore */ }
|
||||
for (const f of jsFiles) {
|
||||
check(`Parse ${f}`, () => {
|
||||
execSync(`node --check ${f}`, { encoding: "utf8" });
|
||||
});
|
||||
}
|
||||
const boostAfterAllEvents = G.codeBoost;
|
||||
for (let i = 0; i < 200; i++) exported.updateRates();
|
||||
assert(
|
||||
Math.abs(G.codeBoost - boostAfterAllEvents) < 1e-9,
|
||||
`codeBoost stable under updateRates() (before=${boostAfterAllEvents}, after=${G.codeBoost})`
|
||||
);
|
||||
// Clean up
|
||||
G.activeDebuffs = [];
|
||||
G.buildings.ezra = 0; G.buildings.bilbo = 0; G.buildings.allegro = 0;
|
||||
G.buildings.datacenter = 0; G.buildings.community = 0;
|
||||
G.ciFlag = 0; G.deployFlag = 0;
|
||||
|
||||
// ============================================================
|
||||
// 6. GUARDRAIL — updateRates() is idempotent per tick
|
||||
// Calling updateRates twice with the same inputs should produce the same rates.
|
||||
// (Catches accidental += against a non-reset field.)
|
||||
// ============================================================
|
||||
section('guardrail: updateRates is idempotent');
|
||||
G.buildings.autocoder = 5;
|
||||
G.codeBoost = 1;
|
||||
exported.updateRates();
|
||||
const firstCodeRate = G.codeRate;
|
||||
const firstComputeRate = G.computeRate;
|
||||
exported.updateRates();
|
||||
assert(G.codeRate === firstCodeRate, `codeRate stable across updateRates (${firstCodeRate} vs ${G.codeRate})`);
|
||||
assert(G.computeRate === firstComputeRate, 'computeRate stable across updateRates');
|
||||
|
||||
// ============================================================
|
||||
// 7. SAVE / LOAD ROUND-TRIP — core scalar fields survive
|
||||
// ============================================================
|
||||
section('save/load round-trip');
|
||||
G.code = 12345;
|
||||
G.totalCode = 98765;
|
||||
G.phase = 3;
|
||||
G.buildings.autocoder = 7;
|
||||
G.codeBoost = 1.5;
|
||||
G.flags = { creativity: true };
|
||||
exported.saveGame();
|
||||
// Reset to defaults by scrubbing a few fields
|
||||
G.code = 0;
|
||||
G.totalCode = 0;
|
||||
G.phase = 1;
|
||||
G.buildings.autocoder = 0;
|
||||
G.codeBoost = 1;
|
||||
G.flags = {};
|
||||
const ok = exported.loadGame();
|
||||
assert(ok, 'loadGame() returned truthy');
|
||||
assert(G.code === 12345, `G.code restored (got ${G.code})`);
|
||||
assert(G.totalCode === 98765, `G.totalCode restored (got ${G.totalCode})`);
|
||||
assert(G.phase === 3, `G.phase restored (got ${G.phase})`);
|
||||
assert(G.buildings.autocoder === 7, `autocoder count restored (got ${G.buildings.autocoder})`);
|
||||
assert(Math.abs(G.codeBoost - 1.5) < 1e-9, `codeBoost restored (got ${G.codeBoost})`);
|
||||
assert(G.flags && G.flags.creativity === true, 'flags.creativity restored');
|
||||
|
||||
// ============================================================
|
||||
// 8. SUMMARY
|
||||
// ============================================================
|
||||
console.log(`\n---\n${passes} passed, ${failures} failed`);
|
||||
if (failures > 0) {
|
||||
process.exitCode = 1;
|
||||
// 2. HTML script references exist
|
||||
console.log("\n[HTML References]");
|
||||
if (existsSync(join(ROOT, "index.html"))) {
|
||||
const html = readFileSync(join(ROOT, "index.html"), "utf8");
|
||||
const scriptRefs = [...html.matchAll(/src=["']([^"']+\.js)["']/g)].map(m => m[1]);
|
||||
for (const ref of scriptRefs) {
|
||||
check(`Script ref: ${ref}`, () => {
|
||||
if (!existsSync(join(ROOT, ref))) throw new Error("File not found");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Game data structure check
|
||||
console.log("\n[Game Data]");
|
||||
check("js/data.js exists", () => {
|
||||
if (!existsSync(join(ROOT, "js/data.js"))) throw new Error("Missing");
|
||||
});
|
||||
|
||||
// 4. No banned providers
|
||||
console.log("\n[Policy]");
|
||||
check("No Anthropic references", () => {
|
||||
try {
|
||||
const result = execSync(
|
||||
"grep -ril 'anthropic\\|claude-sonnet\\|claude-opus\\|sk-ant-' --include='*.js' --include='*.json' --include='*.html' . 2>/dev/null || true",
|
||||
{ encoding: "utf8" }
|
||||
).trim();
|
||||
if (result) throw new Error(`Found in: ${result}`);
|
||||
} catch (e) {
|
||||
if (e.message.startsWith("Found")) throw e;
|
||||
}
|
||||
});
|
||||
|
||||
// Summary
|
||||
console.log(`\n--- ${failures === 0 ? "ALL PASSED" : `${failures} FAILURE(S)`} ---`);
|
||||
process.exit(failures > 0 ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user