fix(gameplay & db): fix casino spin freeze, bank deposit sync, and plant selection menu (fixes #8, #9, #10)

This commit is contained in:
Antigravity committed 2026-09-22 12:04:30 +00:00
1 parent 351d5f1cca
commit bd314730ff
7 files changed
+247 -33

No files matched your search

+35 -20
View File
@@ -448,7 +448,8 @@ window.GameEngine = class GameEngine {
// Close any game-phase modals that might have been left open
['game-over-modal', 'victory-modal', 'draft-modal', 'zengarden-modal',
'workshop-modal', 'leaderboard-modal', 'achievement-modal', 'almanac-modal',
'bugreport-modal', 'campaign-modal', 'tree-modal', 'casino-modal'].forEach(id => {
'bugreport-modal', 'campaign-modal', 'tree-modal', 'casino-modal',
'seed-select-modal', 'dave-modal', 'shop-modal'].forEach(id => {
const el = document.getElementById(id);
if (el) el.classList.add('hidden');
});
@@ -492,6 +493,12 @@ window.GameEngine = class GameEngine {
this.currentLevel = level;
this.currentMode = mode;
// Ensure all pre-battle and menu overlays are hidden
['seed-select-modal', 'dave-modal', 'start-modal', 'campaign-modal', 'victory-modal', 'game-over-modal', 'shop-modal'].forEach(id => {
const el = document.getElementById(id);
if (el) el.classList.add('hidden');
});
// Pre-set economy mode flags BEFORE reset() so economy.reset() computes
// the correct baseSun (avoids stale isConveyor/isIZombie from previous game)
this.economy.isConveyor = (mode === 'bowling' || mode === 'boss' || mode === 'bossrush');
@@ -1876,6 +1883,7 @@ window.GameEngine = class GameEngine {
}
// Animate spin
this.casino.isSpinning = true;
[reel1, reel2, reel3].forEach(r => { if (r) r.classList.add('spinning'); });
if (btnSpin) btnSpin.disabled = true;
if (resultBanner) {
@@ -1884,27 +1892,34 @@ window.GameEngine = class GameEngine {
}
setTimeout(() => {
if (this.casino) {
this.casino.isSpinning = false;
const res = this.casino.spin(bet);
try {
if (this.casino) {
this.casino.isSpinning = false;
const res = this.casino.spin(bet);
this.casino.isSpinning = false;
if (res && res.icons) {
if (reel1) reel1.innerHTML = `<span class="reel-symbol">${res.icons[0]}</span>`;
if (reel2) reel2.innerHTML = `<span class="reel-symbol">${res.icons[1]}</span>`;
if (reel3) reel3.innerHTML = `<span class="reel-symbol">${res.icons[2]}</span>`;
}
if (resultBanner && res) {
resultBanner.textContent = res.message || '';
if (res.isJackpot) resultBanner.style.color = '#ffd700';
else if (res.payout > 0) resultBanner.style.color = '#69f0ae';
else resultBanner.style.color = '#b0bec5';
}
this.updateCasinoUI();
this.updateRecordDisplay();
}
} catch (e) {
console.error('Casino spin error:', e);
} finally {
if (this.casino) this.casino.isSpinning = false;
[reel1, reel2, reel3].forEach(r => { if (r) r.classList.remove('spinning'); });
if (btnSpin) btnSpin.disabled = false;
if (res.icons) {
if (reel1) reel1.innerHTML = `<span class="reel-symbol">${res.icons[0]}</span>`;
if (reel2) reel2.innerHTML = `<span class="reel-symbol">${res.icons[1]}</span>`;
if (reel3) reel3.innerHTML = `<span class="reel-symbol">${res.icons[2]}</span>`;
}
if (resultBanner) {
resultBanner.textContent = res.message || '';
if (res.isJackpot) resultBanner.style.color = '#ffd700';
else if (res.payout > 0) resultBanner.style.color = '#69f0ae';
else resultBanner.style.color = '#b0bec5';
}
this.updateCasinoUI();
this.updateRecordDisplay();
}
}, 500);
});