This commit is contained in:
Renan LE CARO 2025-03-22 16:47:02 +01:00
parent cb4b1ea49e
commit 60f94461e7
8 changed files with 32 additions and 23 deletions

View file

@ -1,5 +1,5 @@
// The version of the cache.
const VERSION = "29044264";
const VERSION = "29044306";
// The name of the cache
const CACHE_NAME = `breakout-71-${VERSION}`;

View file

@ -1 +1 @@
"29044264"
"29044306"

View file

@ -521,7 +521,7 @@ export async function setLevel(gameState: GameState, l: number) {
}
gameState.currentLevel = l;
gameState.levelTime = 0;
gameState.noBricksSince = 0;
gameState.winAt = 0;
gameState.levelWallBounces = 0;
gameState.autoCleanUses = 0;
gameState.lastTickDown = gameState.levelTime;
@ -814,18 +814,23 @@ export function gameStateTick(
const hasPendingBricks =
gameState.perks.respawn &&
gameState.balls.find((b) => b.hitItem.length > 1);
if (
gameState.running &&
!remainingBricks &&
gameState.noBricksSince == 0 &&
!hasPendingBricks
) {
gameState.noBricksSince ||= gameState.levelTime;
if (gameState.running && !remainingBricks && !hasPendingBricks) {
if (!gameState.winAt) {
gameState.winAt = gameState.levelTime + 5000;
}
} else {
gameState.winAt = 0;
}
if (
!remainingBricks &&
(!liveCount(gameState.coins) ||
gameState.levelTime > gameState.noBricksSince + 5000)
// Delayed win when coins are still flying
(gameState.winAt && gameState.levelTime > gameState.winAt) ||
// instant win condition
(gameState.running &&
gameState.levelTime &&
!remainingBricks &&
!liveCount(gameState.coins))
) {
if (gameState.currentLevel + 1 < max_levels(gameState)) {
if (gameState.running) {

View file

@ -94,7 +94,7 @@ export function newGameState(params: RunParams): GameState {
},
lastOffered: {},
levelTime: 0,
noBricksSince: 0,
winAt: 0,
levelWallBounces: 0,
needsRender: true,
autoCleanUses: 0,

2
src/types.d.ts vendored
View file

@ -251,7 +251,7 @@ export type GameState = {
runStatistics: RunStats;
lastOffered: Partial<{ [k in PerkId]: number }>;
levelTime: number;
noBricksSince: number;
winAt: number;
levelWallBounces: number;
autoCleanUses: number;
aboutToPlaySound: {