Adjustments to creative mode

Don't add the random upgrade in creative
This commit is contained in:
Renan LE CARO 2025-03-07 20:28:59 +01:00
parent 504fd6649c
commit 39d1fad481
2 changed files with 25 additions and 22 deletions

21
dist/index.html vendored
View file

@ -1099,7 +1099,7 @@ function addToScore(coin) {
coin.destroyed = true;
score += coin.points;
addToTotalScore(coin.points);
if (score > highScore && !ignoreThisRunInStats) {
if (score > highScore && !isCreativeModeRun) {
highScore = score;
localStorage.setItem("breakout-3-hs", score.toString());
}
@ -1272,7 +1272,7 @@ function reset_perks() {
for (let u of (0, _loadGameData.upgrades))perks[u.id] = 0;
const giftable = getPossibleUpgrades().filter((u)=>u.giftable);
const randomGift = nextRunOverrides?.perk || isSettingOn("easy") && "slow_down" || giftable[Math.floor(Math.random() * giftable.length)].id;
perks[randomGift] = 1;
if (!isCreativeModeRun) perks[randomGift] = 1;
delete nextRunOverrides.perk;
return randomGift;
}
@ -1322,13 +1322,13 @@ function pickRandomUpgrades(count) {
}));
}
let nextRunOverrides = {};
let ignoreThisRunInStats = false;
let isCreativeModeRun = false;
let pauseUsesDuringRun = 0;
function restart() {
// When restarting, we want to avoid restarting with the same level we're on, so we exclude from the next
// run's level list
totalScoreAtRunStart = getTotalScore();
ignoreThisRunInStats = false;
isCreativeModeRun = false;
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
resetRunStatistics();
score = 0;
@ -1817,7 +1817,7 @@ function getTotalScore() {
}
}
function addToTotalScore(points) {
if (ignoreThisRunInStats) return;
if (isCreativeModeRun) return;
try {
localStorage.setItem("breakout_71_total_score", JSON.stringify(getTotalScore() + points));
} catch (e) {}
@ -1879,7 +1879,7 @@ function gameOver(title, intro) {
allowClose: true,
title,
text: `
${ignoreThisRunInStats ? "<p>This test run and its score are not being recorded</p>" : ""}
${isCreativeModeRun ? "<p>This test run and its score are not being recorded</p>" : ""}
<p>${intro}</p>
${unlocksInfo}
`,
@ -1908,7 +1908,7 @@ function getHistograms() {
appVersion: (0, _loadGameData.appVersion)
});
// Generate some histogram
if (!ignoreThisRunInStats) localStorage.setItem("breakout_71_runs_history", JSON.stringify(runsHistory, null, 2));
if (!isCreativeModeRun) localStorage.setItem("breakout_71_runs_history", JSON.stringify(runsHistory, null, 2));
const makeHistogram = (title, getter, unit)=>{
let values = runsHistory.map((h)=>getter(h) || 0);
let min = Math.min(...values);
@ -2264,7 +2264,6 @@ function renderAllBricks() {
bricks.forEach((color, index)=>{
const x = brickCenterX(index), y = brickCenterY(index);
if (!color) return;
canctx.globalAlpha = perks.pierce_color && ballsColor === color && 0.6 || 1;
const borderColor = ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red" || color;
drawBrick(canctx, color, borderColor, x, y);
if (color === "black") {
@ -2710,7 +2709,7 @@ async function openScorePanel() {
const cb = await asyncAlert({
title: ` ${score} points at level ${currentLevel + 1} / ${max_levels()}`,
text: `
${ignoreThisRunInStats ? "<p>This is a test run, score is not recorded permanently</p>" : ""}
${isCreativeModeRun ? "<p>This is a test run, score is not recorded permanently</p>" : ""}
<p>Upgrades picked so far : </p>
<p>${pickedUpgradesHTMl()}</p>
`,
@ -2810,8 +2809,10 @@ async function openSettingsPanel() {
})){
if (choice === "start") {
restart();
ignoreThisRunInStats = true;
isCreativeModeRun = true;
Object.assign(perks, creativeModePerks);
resetCombo(undefined, undefined);
resetBalls();
break;
} else if (choice) creativeModePerks[choice.id] = ((creativeModePerks[choice.id] || 0) + 1) % (choice.max + 1);
}