refactor: [EPIC] Phase 1 & 2 - Unslop The Beacon #55
Reference in New Issue
Block a user
Delete Branch "refactor/unslop-phase-1-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overview
This PR implements Phase 1 and key parts of Phase 2 from the [EPIC] Unslop The Beacon issue (#54).
Changes Implemented:
Phase 1: Quick Wins
flags: {}to the initial state to prevent undefined access.CONFIGobject and extracted magic numbers for harmony, Bilbo randomness, event probability, offline efficiency, and phase thresholds.updateRates,writeCode, andautoType.p_deployto ensure it can only be triggered if the system hasn't been deployed yet.Phase 2: Hardening
tick,writeCode,buyBuilding,buyProject,saveGame,loadGame,fmt,spellf, andupdateRates.Phase 4: Hygiene
PULL_REQUEST_TEMPLATE.mdto guide future contributions.Verification:
getClickPower()correctly handles all click-based production.G.flagsis safely initialized.Closes #54 (partially)
Approved.
Approved — CI fixes merged, re-running.
Nice progress on the Phase 1/2 work —
CONFIG,getClickPower(),G.flags = {}, and the save whitelist are all directionally right. A few things that should block the merge:1. Combo ordering regression in
writeCode().The refactor moved
G.comboCount++andG.comboTimer = G.comboDecayfrom before thecomboMultcalculation to after it. Result: the first click of a fresh combo now getscomboMult = 1.0instead of1.2, and every subsequent click is shifted by one step. This is a gameplay-facing change that isn't mentioned in the PR description. Either restore the original order or update themin(5, 1 + G.comboCount * 0.2)expression to compensate.2.
G.isLoadingis not protected by try/finally.In
loadGame(), ifupdateRates()or the sprint-restoration logic throws beforeG.isLoading = false, the game silently eats everylog()andshowToast()call forever. Wrap in try/finally:3. Save whitelist is duplicated against
saveGame()'s field list.The whole point of Task 5 is to make save/load symmetric. Right now you have two hand-maintained lists that can drift. Extract to a single top-level
const SAVE_FIELDS = [...]and use it in both directions. A save → load deep-equal round-trip test would also catch drift cheaply.4. This PR does not fix the critical bugs flagged in the parent issue #54.
See my independent review comment on #54 — specifically:
community_dramadebuff compound-decayscodeBoostevery tick (game.js:1474on main)codeBoostis persisted, offline credit is computed from boosted rates)resolveCostduplicated between eachEVENTSentry and theactiveDebuffspushThese are silent correctness bugs, not code-quality issues, so they deserve a slot in Phase 1 / the bugfix sweep. A refactor that leaves them intact is harder to verify later because code will move around.
5. PR description mentions
PULL_REQUEST_TEMPLATE.md(Task 11) but the file isn't in the diff.Either drop the mention or add the file.
Smaller:
CONFIG.COMBO_DECAYetc. are read once atconst Ginitialization; any future live change toCONFIGwon't propagate to the already-assignedG.comboDecay. Fine for a static constant, but worth a comment so nobody tries to tuneCONFIGat runtime and wonders why nothing happens.updateRates) only gets a one-line summary. A list of whichG.*Ratefields it writes would help future contributors.Happy to re-review once (1)–(4) are addressed.