From 8b8e49595d61b5ed716848286cefa802cd6af59f Mon Sep 17 00:00:00 2001 From: Renan LE CARO Date: Mon, 24 Mar 2025 12:52:42 +0100 Subject: [PATCH] N hits : reset as soon as you break more bricks that demanded --- dist/index.html | 3 ++- src/gameStateMutators.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/index.html b/dist/index.html index fe775d4..ed0efea 100644 --- a/dist/index.html +++ b/dist/index.html @@ -2754,6 +2754,7 @@ function explodeBrick(gameState, index, ball, isExplosion) { else gameState.combo += gameState.perks.reach; } if (gameState.lastPuckMove && gameState.perks.passive_income && gameState.lastPuckMove > gameState.levelTime - 500 * gameState.perks.passive_income) resetCombo(gameState, x, y); + if (gameState.perks.nbricks && ball.brokenSinceBounce == gameState.perks.nbricks + 1) resetCombo(gameState, ball.x, ball.y); if (!isExplosion) { // color change if ((gameState.perks.picky_eater || gameState.perks.pierce_color) && color !== gameState.ballsColor && color) { @@ -3212,7 +3213,7 @@ function ballTick(gameState, ball, delta) { } if (gameState.perks.streak_shots) resetCombo(gameState, ball.x, ball.y); if (gameState.perks.trampoline) gameState.combo += gameState.perks.trampoline; - if (gameState.perks.nbricks && gameState.perks.nbricks !== ball.brokenSinceBounce) resetCombo(gameState, ball.x, ball.y); + if (gameState.perks.nbricks && ball.brokenSinceBounce < gameState.perks.nbricks) resetCombo(gameState, ball.x, ball.y); if (gameState.perks.respawn) ball.hitItem.slice(0, -1).slice(0, gameState.perks.respawn).forEach(({ index, color })=>{ if (!gameState.bricks[index] && color !== "black") // respawns with full hp setBrick(gameState, index, color); diff --git a/src/gameStateMutators.ts b/src/gameStateMutators.ts index d893f94..deb96bf 100644 --- a/src/gameStateMutators.ts +++ b/src/gameStateMutators.ts @@ -436,6 +436,14 @@ export function explodeBrick( resetCombo(gameState, x, y); } + if ( + gameState.perks.nbricks && + ball.brokenSinceBounce == gameState.perks.nbricks+1 + ) { + resetCombo(gameState, ball.x, ball.y); + } + + if (!isExplosion) { // color change if ( @@ -1437,7 +1445,7 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) { } if ( gameState.perks.nbricks && - gameState.perks.nbricks !== ball.brokenSinceBounce + ball.brokenSinceBounce< gameState.perks.nbricks ) { resetCombo(gameState, ball.x, ball.y); } @@ -1553,6 +1561,7 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) { const initialBrickColor = gameState.bricks[hitBrick]; ball.brokenSinceBounce++; + explodeBrick(gameState, hitBrick, ball, false); if ( ball.sapperUses < gameState.perks.sapper &&