mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 20:16:16 -04:00
Adjustments to creative mode
Don't add the random upgrade in creative
This commit is contained in:
parent
504fd6649c
commit
39d1fad481
2 changed files with 25 additions and 22 deletions
21
dist/index.html
vendored
21
dist/index.html
vendored
|
@ -1099,7 +1099,7 @@ function addToScore(coin) {
|
||||||
coin.destroyed = true;
|
coin.destroyed = true;
|
||||||
score += coin.points;
|
score += coin.points;
|
||||||
addToTotalScore(coin.points);
|
addToTotalScore(coin.points);
|
||||||
if (score > highScore && !ignoreThisRunInStats) {
|
if (score > highScore && !isCreativeModeRun) {
|
||||||
highScore = score;
|
highScore = score;
|
||||||
localStorage.setItem("breakout-3-hs", score.toString());
|
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;
|
for (let u of (0, _loadGameData.upgrades))perks[u.id] = 0;
|
||||||
const giftable = getPossibleUpgrades().filter((u)=>u.giftable);
|
const giftable = getPossibleUpgrades().filter((u)=>u.giftable);
|
||||||
const randomGift = nextRunOverrides?.perk || isSettingOn("easy") && "slow_down" || giftable[Math.floor(Math.random() * giftable.length)].id;
|
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;
|
delete nextRunOverrides.perk;
|
||||||
return randomGift;
|
return randomGift;
|
||||||
}
|
}
|
||||||
|
@ -1322,13 +1322,13 @@ function pickRandomUpgrades(count) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
let nextRunOverrides = {};
|
let nextRunOverrides = {};
|
||||||
let ignoreThisRunInStats = false;
|
let isCreativeModeRun = false;
|
||||||
let pauseUsesDuringRun = 0;
|
let pauseUsesDuringRun = 0;
|
||||||
function restart() {
|
function restart() {
|
||||||
// When restarting, we want to avoid restarting with the same level we're on, so we exclude from the next
|
// When restarting, we want to avoid restarting with the same level we're on, so we exclude from the next
|
||||||
// run's level list
|
// run's level list
|
||||||
totalScoreAtRunStart = getTotalScore();
|
totalScoreAtRunStart = getTotalScore();
|
||||||
ignoreThisRunInStats = false;
|
isCreativeModeRun = false;
|
||||||
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
|
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
|
||||||
resetRunStatistics();
|
resetRunStatistics();
|
||||||
score = 0;
|
score = 0;
|
||||||
|
@ -1817,7 +1817,7 @@ function getTotalScore() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function addToTotalScore(points) {
|
function addToTotalScore(points) {
|
||||||
if (ignoreThisRunInStats) return;
|
if (isCreativeModeRun) return;
|
||||||
try {
|
try {
|
||||||
localStorage.setItem("breakout_71_total_score", JSON.stringify(getTotalScore() + points));
|
localStorage.setItem("breakout_71_total_score", JSON.stringify(getTotalScore() + points));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
@ -1879,7 +1879,7 @@ function gameOver(title, intro) {
|
||||||
allowClose: true,
|
allowClose: true,
|
||||||
title,
|
title,
|
||||||
text: `
|
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>
|
<p>${intro}</p>
|
||||||
${unlocksInfo}
|
${unlocksInfo}
|
||||||
`,
|
`,
|
||||||
|
@ -1908,7 +1908,7 @@ function getHistograms() {
|
||||||
appVersion: (0, _loadGameData.appVersion)
|
appVersion: (0, _loadGameData.appVersion)
|
||||||
});
|
});
|
||||||
// Generate some histogram
|
// 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)=>{
|
const makeHistogram = (title, getter, unit)=>{
|
||||||
let values = runsHistory.map((h)=>getter(h) || 0);
|
let values = runsHistory.map((h)=>getter(h) || 0);
|
||||||
let min = Math.min(...values);
|
let min = Math.min(...values);
|
||||||
|
@ -2264,7 +2264,6 @@ function renderAllBricks() {
|
||||||
bricks.forEach((color, index)=>{
|
bricks.forEach((color, index)=>{
|
||||||
const x = brickCenterX(index), y = brickCenterY(index);
|
const x = brickCenterX(index), y = brickCenterY(index);
|
||||||
if (!color) return;
|
if (!color) return;
|
||||||
canctx.globalAlpha = perks.pierce_color && ballsColor === color && 0.6 || 1;
|
|
||||||
const borderColor = ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red" || color;
|
const borderColor = ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red" || color;
|
||||||
drawBrick(canctx, color, borderColor, x, y);
|
drawBrick(canctx, color, borderColor, x, y);
|
||||||
if (color === "black") {
|
if (color === "black") {
|
||||||
|
@ -2710,7 +2709,7 @@ async function openScorePanel() {
|
||||||
const cb = await asyncAlert({
|
const cb = await asyncAlert({
|
||||||
title: ` ${score} points at level ${currentLevel + 1} / ${max_levels()}`,
|
title: ` ${score} points at level ${currentLevel + 1} / ${max_levels()}`,
|
||||||
text: `
|
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>Upgrades picked so far : </p>
|
||||||
<p>${pickedUpgradesHTMl()}</p>
|
<p>${pickedUpgradesHTMl()}</p>
|
||||||
`,
|
`,
|
||||||
|
@ -2810,8 +2809,10 @@ async function openSettingsPanel() {
|
||||||
})){
|
})){
|
||||||
if (choice === "start") {
|
if (choice === "start") {
|
||||||
restart();
|
restart();
|
||||||
ignoreThisRunInStats = true;
|
isCreativeModeRun = true;
|
||||||
Object.assign(perks, creativeModePerks);
|
Object.assign(perks, creativeModePerks);
|
||||||
|
resetCombo(undefined, undefined);
|
||||||
|
resetBalls();
|
||||||
break;
|
break;
|
||||||
} else if (choice) creativeModePerks[choice.id] = ((creativeModePerks[choice.id] || 0) + 1) % (choice.max + 1);
|
} else if (choice) creativeModePerks[choice.id] = ((creativeModePerks[choice.id] || 0) + 1) % (choice.max + 1);
|
||||||
}
|
}
|
||||||
|
|
22
src/game.ts
22
src/game.ts
|
@ -269,7 +269,7 @@ function addToScore(coin: Coin) {
|
||||||
score += coin.points;
|
score += coin.points;
|
||||||
|
|
||||||
addToTotalScore(coin.points);
|
addToTotalScore(coin.points);
|
||||||
if (score > highScore && !ignoreThisRunInStats) {
|
if (score > highScore && !isCreativeModeRun) {
|
||||||
highScore = score;
|
highScore = score;
|
||||||
localStorage.setItem("breakout-3-hs", score.toString());
|
localStorage.setItem("breakout-3-hs", score.toString());
|
||||||
}
|
}
|
||||||
|
@ -481,7 +481,9 @@ function reset_perks(): PerkId {
|
||||||
(isSettingOn("easy") && "slow_down") ||
|
(isSettingOn("easy") && "slow_down") ||
|
||||||
giftable[Math.floor(Math.random() * giftable.length)].id;
|
giftable[Math.floor(Math.random() * giftable.length)].id;
|
||||||
|
|
||||||
|
if(!isCreativeModeRun){
|
||||||
perks[randomGift] = 1;
|
perks[randomGift] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
delete nextRunOverrides.perk;
|
delete nextRunOverrides.perk;
|
||||||
return randomGift as PerkId;
|
return randomGift as PerkId;
|
||||||
|
@ -565,7 +567,7 @@ function pickRandomUpgrades(count: number) {
|
||||||
type RunOverrides = { level?: PerkId; perk?: string };
|
type RunOverrides = { level?: PerkId; perk?: string };
|
||||||
|
|
||||||
let nextRunOverrides = {} as RunOverrides;
|
let nextRunOverrides = {} as RunOverrides;
|
||||||
let ignoreThisRunInStats = false;
|
let isCreativeModeRun = false;
|
||||||
|
|
||||||
let pauseUsesDuringRun = 0;
|
let pauseUsesDuringRun = 0;
|
||||||
|
|
||||||
|
@ -573,7 +575,7 @@ function restart() {
|
||||||
// When restarting, we want to avoid restarting with the same level we're on, so we exclude from the next
|
// When restarting, we want to avoid restarting with the same level we're on, so we exclude from the next
|
||||||
// run's level list
|
// run's level list
|
||||||
totalScoreAtRunStart = getTotalScore();
|
totalScoreAtRunStart = getTotalScore();
|
||||||
ignoreThisRunInStats = false;
|
isCreativeModeRun = false;
|
||||||
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
|
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
|
||||||
resetRunStatistics();
|
resetRunStatistics();
|
||||||
score = 0;
|
score = 0;
|
||||||
|
@ -1304,7 +1306,7 @@ function getTotalScore() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToTotalScore(points: number) {
|
function addToTotalScore(points: number) {
|
||||||
if (ignoreThisRunInStats) return;
|
if (isCreativeModeRun) return;
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"breakout_71_total_score",
|
"breakout_71_total_score",
|
||||||
|
@ -1388,7 +1390,7 @@ function gameOver(title: string, intro: string) {
|
||||||
allowClose: true,
|
allowClose: true,
|
||||||
title,
|
title,
|
||||||
text: `
|
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>
|
<p>${intro}</p>
|
||||||
${unlocksInfo}
|
${unlocksInfo}
|
||||||
`,
|
`,
|
||||||
|
@ -1418,7 +1420,7 @@ function getHistograms() {
|
||||||
runsHistory.push({ ...runStatistics, perks, appVersion });
|
runsHistory.push({ ...runStatistics, perks, appVersion });
|
||||||
|
|
||||||
// Generate some histogram
|
// Generate some histogram
|
||||||
if (!ignoreThisRunInStats)
|
if (!isCreativeModeRun)
|
||||||
localStorage.setItem(
|
localStorage.setItem(
|
||||||
"breakout_71_runs_history",
|
"breakout_71_runs_history",
|
||||||
JSON.stringify(runsHistory, null, 2),
|
JSON.stringify(runsHistory, null, 2),
|
||||||
|
@ -1985,8 +1987,6 @@ function renderAllBricks() {
|
||||||
|
|
||||||
if (!color) return;
|
if (!color) return;
|
||||||
|
|
||||||
canctx.globalAlpha = (perks.pierce_color && ballsColor === color && 0.6) || 1;
|
|
||||||
|
|
||||||
const borderColor = (ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red") ||
|
const borderColor = (ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red") ||
|
||||||
color;
|
color;
|
||||||
|
|
||||||
|
@ -2699,7 +2699,7 @@ async function openScorePanel() {
|
||||||
const cb = await asyncAlert({
|
const cb = await asyncAlert({
|
||||||
title: ` ${score} points at level ${currentLevel + 1} / ${max_levels()}`,
|
title: ` ${score} points at level ${currentLevel + 1} / ${max_levels()}`,
|
||||||
text: `
|
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>Upgrades picked so far : </p>
|
||||||
<p>${pickedUpgradesHTMl()}</p>
|
<p>${pickedUpgradesHTMl()}</p>
|
||||||
`,
|
`,
|
||||||
|
@ -2821,8 +2821,10 @@ async function openSettingsPanel() {
|
||||||
) {
|
) {
|
||||||
if (choice === "start") {
|
if (choice === "start") {
|
||||||
restart();
|
restart();
|
||||||
ignoreThisRunInStats = true;
|
isCreativeModeRun = true;
|
||||||
Object.assign(perks, creativeModePerks);
|
Object.assign(perks, creativeModePerks);
|
||||||
|
resetCombo(undefined, undefined);
|
||||||
|
resetBalls();
|
||||||
break;
|
break;
|
||||||
} else if (choice) {
|
} else if (choice) {
|
||||||
creativeModePerks[choice.id] =
|
creativeModePerks[choice.id] =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue