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

This commit is contained in:
2026-09-22 12:04:30 +00:00
parent 351d5f1cca
commit bd314730ff
7 changed files with 247 additions and 33 deletions
+45 -2
View File
@@ -117,7 +117,20 @@ window.PvZAuth = (function () {
lastVisit: Date.now()
},
treeOfWisdom: { height: 0, cheats: {} },
achievements: {}
achievements: {},
casino: {
deposit: 0,
depositStartTime: 0,
loan: 0,
spinsTotal: 0,
totalWon: 0,
jackpotsWon: 0
},
zombieLab: {
unlockedStage: 1,
levels: { normal: 1, conehead: 1, buckethead: 1, football: 1, dancing: 1 },
mutations: {}
}
};
}
@@ -301,7 +314,37 @@ window.PvZAuth = (function () {
achievements: {
...(loc.achievements || {}),
...(base.achievements || {})
}
},
casino: (base.casino || loc.casino)
? {
...def.casino,
...(loc.casino || {}),
...(base.casino || {}),
deposit: (base.casino && base.casino.deposit !== undefined) ? Number(base.casino.deposit) : (Number(loc.casino?.deposit) || 0),
depositStartTime: (base.casino && base.casino.depositStartTime) ? Number(base.casino.depositStartTime) : (Number(loc.casino?.depositStartTime) || 0),
loan: (base.casino && base.casino.loan !== undefined) ? Number(base.casino.loan) : (Number(loc.casino?.loan) || 0),
spinsTotal: Math.max(Number(base.casino?.spinsTotal) || 0, Number(loc.casino?.spinsTotal) || 0),
totalWon: Math.max(Number(base.casino?.totalWon) || 0, Number(loc.casino?.totalWon) || 0),
jackpotsWon: Math.max(Number(base.casino?.jackpotsWon) || 0, Number(loc.casino?.jackpotsWon) || 0)
}
: def.casino,
zombieLab: (base.zombieLab || loc.zombieLab)
? {
...def.zombieLab,
...(loc.zombieLab || {}),
...(base.zombieLab || {}),
unlockedStage: Math.max(Number(base.zombieLab?.unlockedStage) || 1, Number(loc.zombieLab?.unlockedStage) || 1),
levels: {
...def.zombieLab.levels,
...(loc.zombieLab?.levels || {}),
...(base.zombieLab?.levels || {})
},
mutations: {
...(loc.zombieLab?.mutations || {}),
...(base.zombieLab?.mutations || {})
}
}
: def.zombieLab
};
}
+1
View File
@@ -138,6 +138,7 @@ window.CasinoSystem = class CasinoSystem {
}
}
this.isSpinning = false;
this.saveToAuth();
return {
+14 -1
View File
@@ -130,11 +130,21 @@ window.EconomySystem = class EconomySystem {
this.selectedDeck = deckIds.filter(id => this.isPlantUnlocked(id)).slice(0, this.getMaxSlots());
this.saveProfileData();
}
const chosen = this.selectedDeck.length > 0 ? this.selectedDeck : this.defaultUnlocked;
const chosen = (this.selectedDeck && this.selectedDeck.length > 0) ? this.selectedDeck : this.defaultUnlocked;
this.cards = chosen.map(id => {
const found = this.allCards.find(c => c.id === id);
return found ? { ...found, timer: 0 } : null;
}).filter(Boolean);
// Guaranteed fallback: If this.cards is empty, restore default starter cards so top menu never disappears
if (!this.cards || this.cards.length === 0) {
this.selectedDeck = [...this.defaultUnlocked];
this.cards = this.defaultUnlocked.map(id => {
const found = this.allCards.find(c => c.id === id);
return found ? { ...found, timer: 0 } : null;
}).filter(Boolean);
this.saveProfileData();
}
}
reloadProfileData() {
@@ -720,6 +730,9 @@ window.EconomySystem = class EconomySystem {
}
// 2. Draw Cards
if (!this.isConveyor && !this.isIZombie && (!this.cards || this.cards.length === 0)) {
this.setDeckFromSelection();
}
const cardStartX = 105;
const cardY = 8;
const cardW = 66;