Skip to content

Commit 6d40d53

Browse files
mf4633claude
andcommitted
Bug fixes across 16 games
2048: persist won flag so 2048-reached message shows only once Apoapsis: fuel init uses def.fuel!==undefined (not hardcoded type list) Aresia: reset _surgeLeft on newGame to prevent surge state leak BiosphereBlue: declare cont var before use (ReferenceError fix) Bisque: remove 4-player-only remainder distribution inconsistency BonnevilleSpillwayOperator: panels bring-to-front on mousedown, not just on drag handle Cliffwalkers: reset fallDist when transitioning to FLOATER state Doctrine: advance year before checkEnd so win condition sees correct year; annotate streak resets Floodline: survive label uses _effectiveDuration; undo restores reinforced state Mancala: AI evaluates end-game for both sides (not only side 0) Metropolis2K: pension debt actually applies 10% income haircut; _disasters re-init after load (Set doesn't JSON-roundtrip); _disastersSurvived uses max to avoid regressing; riot burnTime only set on burning tiles Odyssey: network bonus correctly not awarded on tie; block temple placement on flooded hexes PenteGrammai: set phase=wait during no-valid-moves delay to block re-roll Senet: pieces past sq 30 require exact rolls to land 28-30, can't overshoot directly to bear-off Tidelands: fix title showing "ODYSSEY"; tighten trireme adjacency to require player structure at neighbor Wordform: fix stale-save loading guard; only record win/loss in daily mode Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 62fa366 commit 6d40d53

16 files changed

Lines changed: 75 additions & 49 deletions

2048.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,26 +127,26 @@ <h2>Strategy</h2>
127127
<script>
128128
(() => {
129129
const N = 4;
130-
let grid, score, best, history;
130+
let grid, score, best, history, won;
131131
const $ = id => document.getElementById(id);
132132

133133
function load() {
134134
best = +(localStorage.getItem('g2048_best') || 0);
135135
$('best').textContent = best;
136136
const saved = localStorage.getItem('g2048_state');
137137
if (saved) {
138-
try { const s = JSON.parse(saved); grid = s.grid; score = s.score; history = s.history || []; render(); return; }
138+
try { const s = JSON.parse(saved); grid = s.grid; score = s.score; history = s.history || []; won = s.won || false; render(); return; }
139139
catch(e){}
140140
}
141141
newGame();
142142
}
143143
function save() {
144-
localStorage.setItem('g2048_state', JSON.stringify({grid, score, history: history.slice(-20)}));
144+
localStorage.setItem('g2048_state', JSON.stringify({grid, score, history: history.slice(-20), won}));
145145
if (score > best) { best = score; localStorage.setItem('g2048_best', best); $('best').textContent = best; }
146146
}
147147
function newGame() {
148148
grid = Array.from({length: N}, () => Array(N).fill(0));
149-
score = 0; history = [];
149+
score = 0; history = []; won = false;
150150
addRandom(); addRandom();
151151
render(); save();
152152
$('msg').textContent = '';
@@ -206,7 +206,7 @@ <h2>Strategy</h2>
206206
score += gained;
207207
addRandom();
208208
render(); save();
209-
if (gridHas(2048)) $('msg').textContent = 'YOU REACHED 2048 — KEEP GOING';
209+
if (!won && gridHas(2048)) { won = true; $('msg').textContent = 'YOU REACHED 2048 — KEEP GOING'; }
210210
if (!canMove()) $('msg').textContent = 'GAME OVER — NEW GAME?';
211211
return true;
212212
}

Apoapsis.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ <h2 id="resultTitle">Orbit Achieved!</h2>
13221322
function addPart(key) {
13231323
var def = PARTS[key];
13241324
var p = { id: partIdCounter++, key: key, stage: maxStage() };
1325-
if (def.type === 'tank' || def.type === 'srb') p.fuel = def.fuel;
1325+
if (def.fuel !== undefined) p.fuel = def.fuel;
13261326
rocket.parts.push(p);
13271327
renderBuilder();
13281328
}
@@ -1335,7 +1335,7 @@ <h2 id="resultTitle">Orbit Achieved!</h2>
13351335
for (var i = 0; i < preset.length; i++) {
13361336
var def = PARTS[preset[i].key];
13371337
var p = { id: partIdCounter++, key: preset[i].key, stage: preset[i].stage };
1338-
if (def.type === 'tank' || def.type === 'srb') p.fuel = def.fuel;
1338+
if (def.fuel !== undefined) p.fuel = def.fuel;
13391339
rocket.parts.push(p);
13401340
}
13411341
selectedPart = -1;

Aresia.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ <h2 id="overlay-title">Game Over</h2>
870870
devCardPlayedThisTurn = false;
871871
pendingAction = null;
872872
discardQueue = [];
873+
window._surgeLeft = 0;
873874

874875
generateBoard();
875876
initPlayers();

BiosphereBlue.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4595,6 +4595,7 @@ <h4>LEGEND</h4>
45954595
dismiss();
45964596
maybeShowFirstRun();
45974597
});
4598+
var cont = document.getElementById('mmContinue');
45984599
if (cont) cont.addEventListener('click', function() {
45994600
dismiss();
46004601
setTimeout(function() { openSlotPicker('load'); }, 400);

Bisque.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,10 +910,6 @@ <h2 id="olTitle"></h2>
910910
/* Assign to each player */
911911
for (var pi = 1; pi <= playerCount; pi++) {
912912
var count = perPlayer;
913-
/* For 4 players, distribute remainder: first (totalTerritories % playerCount) players get an extra */
914-
if (playerCount === 4 && pi <= (totalTerritories % playerCount)) {
915-
count = perPlayer + 1;
916-
}
917913
for (var c = 0; c < count; c++) {
918914
state.territories[ids[idx]] = {
919915
owner: pi,

BonnevilleSpillwayOperator.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2887,6 +2887,7 @@ <h2 id="vic-title" style="color:var(--good);">CAMPAIGN COMPLETE — BONNEVILLE O
28872887
if (!el) continue;
28882888
const handle = el.querySelector('h2');
28892889
if (!handle) continue;
2890+
el.addEventListener('mousedown', () => { el.style.zIndex = (++z); });
28902891
handle.addEventListener('mousedown', e => {
28912892
if (e.button !== 0) return;
28922893
e.preventDefault();
@@ -2895,7 +2896,7 @@ <h2 id="vic-title" style="color:var(--good);">CAMPAIGN COMPLETE — BONNEVILLE O
28952896
const offX = e.clientX - panelRect.left;
28962897
const offY = e.clientY - panelRect.top;
28972898
el.classList.add('dragging');
2898-
el.style.zIndex = (++z);
2899+
el.style.zIndex = z; // already bumped by the el mousedown above
28992900
const onMove = ev => {
29002901
const nx = ev.clientX - wsRect.left + workspace.scrollLeft - offX;
29012902
const ny = ev.clientY - wsRect.top + workspace.scrollTop - offY;

Cliffwalkers.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@
839839
this.fallDist++;
840840
if (this.canFloat && this.fallDist > 16) {
841841
this.state = ST.FLOATER;
842+
this.fallDist = 0; // reset so a later re-fall doesn't carry stale distance
842843
return;
843844
}
844845
if (this.y >= t.h) return; // drown handled in update()
@@ -850,7 +851,7 @@
850851
const t = game.terrain;
851852
if (t.isSolid(this.x, this.y + 1)) {
852853
this.state = ST.WALKER;
853-
this.fallDist = 0;
854+
this.fallDist = 0; // reset so a subsequent fall starts fresh
854855
return;
855856
}
856857
this.y += FLOAT_SPEED;

Doctrine.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ <h2 id="end-title">CAMPAIGN COMPLETE</h2>
351351
tempo: {}, // power -> remaining tempo this turn
352352
selected: null,
353353
budget: {}, // power -> {mil, soc, infra} (% of GDP)
354-
lowApprovalStreak: 0,
355-
holdStreak: 0,
354+
lowApprovalStreak: 0, // reset each newGame — was leaking between games
355+
holdStreak: 0, // reset each newGame — was leaking between games
356356
score: { USA: 0, CHN: 0, RUS: 0, EU: 0 },
357357
over: false,
358358
lastEventYear: 0,
@@ -772,10 +772,10 @@ <h2 id="end-title">CAMPAIGN COMPLETE</h2>
772772
annualEconomy();
773773
// Scoring
774774
for (const p of POWERS) S.score[p] = computeScore(p);
775+
// Advance year first so checkEnd sees the correct year
776+
S.year += 1;
775777
// Win/lose
776778
checkEnd();
777-
// Advance
778-
S.year += 1;
779779
for (const p of POWERS) S.tempo[p] = S.powers[p].tempoMax;
780780
render();
781781
}

Floodline.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ <h1 id="resultsTitle">Scenario Complete</h1>
12171217
const sc = state.scenario;
12181218
state.objectives = [
12191219
{ id: 'damage', label: `Keep town damage below ${sc.winDamage}%`, check: () => getDamagePct() < sc.winDamage },
1220-
{ id: 'survive', label: `Survive ${formatTime(sc.duration)}`, check: () => state.time >= sc.duration },
1220+
{ id: 'survive', label: `Survive ${formatTime(sc._effectiveDuration ?? sc.duration)}`, check: () => state.time >= (sc._effectiveDuration ?? sc.duration) },
12211221
];
12221222
if (sc.hospital) state.objectives.push({
12231223
id: 'hospital', label: 'Protect the hospital',
@@ -3297,6 +3297,7 @@ <h1 id="resultsTitle">Scenario Complete</h1>
32973297
type: state.type[i], elev: state.elev[i], structH: state.structH[i],
32983298
stress: state.stress[i], budget: state.budget, spent: state.spent,
32993299
evacuated: state.stats.evacuated,
3300+
reinforced: state.reinforced[i],
33003301
});
33013302
if (undoStack.length > 50) undoStack.shift();
33023303
}
@@ -3308,6 +3309,7 @@ <h1 id="resultsTitle">Scenario Complete</h1>
33083309
state.elev[u.i] = u.elev;
33093310
state.structH[u.i] = u.structH;
33103311
state.stress[u.i] = u.stress;
3312+
state.reinforced[u.i] = u.reinforced ?? 0;
33113313
state.budget = u.budget;
33123314
state.spent = u.spent;
33133315
state.stats.evacuated = u.evacuated;

Mancala.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ <h2 id="overlay-title">Game Over</h2>
586586
var score = board[13] - board[6];
587587
if (result.extraTurn) score += 3;
588588
if (result.captured) score += 2;
589-
if (sideEmpty(0)) {
589+
if (sideEmpty(0) || sideEmpty(1)) {
590590
// Game would end — sum remaining for each side
591591
var p1sum = 0, p2sum = 0;
592592
for (var j = 0; j < 6; j++) p1sum += board[j];

0 commit comments

Comments
 (0)