mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 12:36:15 -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;
|
||||
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);
|
||||
}
|
||||
|
|
26
src/game.ts
26
src/game.ts
|
@ -269,7 +269,7 @@ function addToScore(coin: Coin) {
|
|||
score += coin.points;
|
||||
|
||||
addToTotalScore(coin.points);
|
||||
if (score > highScore && !ignoreThisRunInStats) {
|
||||
if (score > highScore && !isCreativeModeRun) {
|
||||
highScore = score;
|
||||
localStorage.setItem("breakout-3-hs", score.toString());
|
||||
}
|
||||
|
@ -481,7 +481,9 @@ function reset_perks(): PerkId {
|
|||
(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 as PerkId;
|
||||
|
@ -565,7 +567,7 @@ function pickRandomUpgrades(count: number) {
|
|||
type RunOverrides = { level?: PerkId; perk?: string };
|
||||
|
||||
let nextRunOverrides = {} as RunOverrides;
|
||||
let ignoreThisRunInStats = false;
|
||||
let isCreativeModeRun = false;
|
||||
|
||||
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
|
||||
// run's level list
|
||||
totalScoreAtRunStart = getTotalScore();
|
||||
ignoreThisRunInStats = false;
|
||||
isCreativeModeRun = false;
|
||||
shuffleLevels(levelTime || score ? currentLevelInfo().name : null);
|
||||
resetRunStatistics();
|
||||
score = 0;
|
||||
|
@ -1304,7 +1306,7 @@ function getTotalScore() {
|
|||
}
|
||||
|
||||
function addToTotalScore(points: number) {
|
||||
if (ignoreThisRunInStats) return;
|
||||
if (isCreativeModeRun) return;
|
||||
try {
|
||||
localStorage.setItem(
|
||||
"breakout_71_total_score",
|
||||
|
@ -1388,7 +1390,7 @@ function gameOver(title: string, intro: string) {
|
|||
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}
|
||||
`,
|
||||
|
@ -1418,7 +1420,7 @@ function getHistograms() {
|
|||
runsHistory.push({ ...runStatistics, perks, appVersion });
|
||||
|
||||
// Generate some histogram
|
||||
if (!ignoreThisRunInStats)
|
||||
if (!isCreativeModeRun)
|
||||
localStorage.setItem(
|
||||
"breakout_71_runs_history",
|
||||
JSON.stringify(runsHistory, null, 2),
|
||||
|
@ -1985,8 +1987,6 @@ function renderAllBricks() {
|
|||
|
||||
if (!color) return;
|
||||
|
||||
canctx.globalAlpha = (perks.pierce_color && ballsColor === color && 0.6) || 1;
|
||||
|
||||
const borderColor = (ballsColor !== color && color !== "black" && redBorderOnBricksWithWrongColor && "red") ||
|
||||
color;
|
||||
|
||||
|
@ -2699,7 +2699,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>
|
||||
`,
|
||||
|
@ -2821,8 +2821,10 @@ async function openSettingsPanel() {
|
|||
) {
|
||||
if (choice === "start") {
|
||||
restart();
|
||||
ignoreThisRunInStats = true;
|
||||
Object.assign(perks, creativeModePerks);
|
||||
isCreativeModeRun = true;
|
||||
Object.assign(perks, creativeModePerks);
|
||||
resetCombo(undefined, undefined);
|
||||
resetBalls();
|
||||
break;
|
||||
} else if (choice) {
|
||||
creativeModePerks[choice.id] =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue