Build 29095000

This commit is contained in:
Renan LE CARO 2025-04-26 22:40:32 +02:00
parent 096f7d4abd
commit 4c324d211c
27 changed files with 500 additions and 1350 deletions

View file

View file

@ -30,6 +30,7 @@ Break colourful bricks, catch bouncing coins and select powerful upgrades !
## Done
- hardcoded the levels unlock conditions so that they wouldn't change at each update
- hide any tooltip on page scroll
- added a "display level code" button in editor
- passive income : paddle transparent for a much shorter time
@ -573,6 +574,7 @@ Here are a few interesting games in the breakout genre :
- Wizorb : https://store.steampowered.com/app/207420/Wizorb/
- Ricochet infinity : https://www.myabandonware.com/game/ricochet-infinity-dxm
- Whackerball : https://store.steampowered.com/app/2192170/Whackerball/
- Arkanoid Archive lists many, many more https://www.youtube.com/@ArkanoidGame
# PC game suggestions

View file

@ -29,8 +29,8 @@ android {
applicationId = "me.lecaro.breakout"
minSdk = 21
targetSdk = 34
versionCode = 29092809
versionName = "29092809"
versionCode = 29095000
versionName = "29095000"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true

File diff suppressed because one or more lines are too long

22
dist/index.html vendored

File diff suppressed because one or more lines are too long

View file

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

View file

@ -9,11 +9,7 @@ import {
restart,
} from "./game";
import { asyncAlert, requiredAsyncAlert } from "./asyncAlert";
import {
describeLevel,
highScoreText,
sumOfValues,
} from "./game_utils";
import { describeLevel, highScoreText, sumOfValues } from "./game_utils";
import { getHistory } from "./gameOver";
import { noCreative } from "./upgrades";
import { levelIconHTML } from "./levelIcon";
@ -46,7 +42,8 @@ export async function openCreativeModePerksPicker() {
while (true) {
const levelOptions = [
...allLevels.map((l, li) => {
const problem = reasonLevelIsLocked(li, l.name,getHistory(), true)?.text || "";
const problem =
reasonLevelIsLocked(li, l.name, getHistory(), true)?.text || "";
return {
icon: icons[l.name],
text: l.name,

File diff suppressed because it is too large Load diff

View file

@ -1,38 +1,43 @@
import conditions from "./unlockConditions.json"
import levels from "./levels.json"
import conditions from "./unlockConditions.json";
import levels from "./levels.json";
import { rawUpgrades } from "../upgrades";
import { getLevelUnlockCondition } from "../get_level_unlock_condition";
import { UnlockCondition } from "../types";
describe("conditions", () => {
it("defines conditions for existing levels only", () => {
const conditionForMissingLevel=Object.keys(conditions).filter(levelName=>!levels.find(l=>l.name===levelName))
const conditionForMissingLevel = Object.keys(conditions).filter(
(levelName) => !levels.find((l) => l.name === levelName),
);
expect(conditionForMissingLevel).toEqual([]);
});
it("defines conditions with existing upgrades only", () => {
const existingIds :Set<string>= new Set(rawUpgrades.map(u=>u.id));
const existingIds: Set<string> = new Set(rawUpgrades.map((u) => u.id));
const missing: Set<string> = new Set();
Object.values(conditions).forEach(({ required, forbidden }) => {
[...required,...forbidden].forEach(id=> {
if(!existingIds.has(id))
missing.add(id)
})
})
[...required, ...forbidden].forEach((id) => {
if (!existingIds.has(id)) missing.add(id);
});
});
expect([...missing]).toEqual([]);
});
it("defines conditions for all levels", () => {
const toAdd : Record<string,UnlockCondition>= {}
levels.filter(l=>!l.name.startsWith('icon:')).forEach((l,li)=> {
if(l.name in conditions) return
toAdd[l.name]= getLevelUnlockCondition(li, l.name)
})
const toAdd: Record<string, UnlockCondition> = {};
levels
.filter((l) => !l.name.startsWith("icon:"))
.forEach((l, li) => {
if (l.name in conditions) return;
toAdd[l.name] = getLevelUnlockCondition(li, l.name);
});
if (Object.keys(toAdd).length) {
console.debug('Missing hardcoded conditons\n\n'+ JSON.stringify(toAdd).slice(1,-1)+'\n\n')
console.debug(
"Missing hardcoded conditons\n\n" +
JSON.stringify(toAdd).slice(1, -1) +
"\n\n",
);
}
expect(Object.keys(toAdd)).toEqual([]);
});
})
});

View file

@ -1 +1 @@
"29092809"
"29095000"

View file

@ -451,9 +451,7 @@ h2.histogram-title strong {
opacity: 1;
border: 1px solid white;
&.desktop {
max-width: 300px;
}
&.mobile {
width: 95vw;

View file

@ -6,7 +6,6 @@ import {
currentLevelInfo,
describeLevel,
pickedUpgradesHTMl,
} from "./game_utils";
import {
askForPersistentStorage,
@ -18,7 +17,10 @@ import { stopRecording } from "./recording";
import { asyncAlert } from "./asyncAlert";
import { editRawLevelList } from "./levelEditor";
import { openCreativeModePerksPicker } from "./creative";
import {isLevelLocked, reasonLevelIsLocked} from "./get_level_unlock_condition";
import {
isLevelLocked,
reasonLevelIsLocked,
} from "./get_level_unlock_condition";
export function addToTotalPlayTime(ms: number) {
setSettingValue(

View file

@ -1265,7 +1265,6 @@ export function gameStateTick(
// If you dont have buoy, we directly declare the coin "lost" to make it clear
resetCombo(gameState, coin.x, coin.y);
}
}
if (

View file

@ -1,4 +1,4 @@
import {Ball, Coin, GameState, Level, PerkId, PerksMap,} from "./types";
import { Ball, Coin, GameState, Level, PerkId, PerksMap } from "./types";
import { icons, upgrades } from "./loadGameData";
import { t } from "./i18n/i18n";
import { clamp } from "./pure_functions";
@ -192,10 +192,13 @@ export function telekinesisEffectRate(gameState: GameState, ball: Ball) {
}
export function yoyoEffectRate(gameState: GameState, ball: Ball) {
if(ball.vy < 0) return 0
if(!gameState.perks.yoyo) return 0
return Math.abs(gameState.puckPosition - ball.x)/gameState.gameZoneWidth * gameState.perks.yoyo/2
if (ball.vy < 0) return 0;
if (!gameState.perks.yoyo) return 0;
return (
((Math.abs(gameState.puckPosition - ball.x) / gameState.gameZoneWidth) *
gameState.perks.yoyo) /
2
);
}
export function findLast<T>(

View file

@ -3,9 +3,12 @@ import {upgrades} from "./loadGameData";
import { hashCode } from "./getLevelBackground";
import { t } from "./i18n/i18n";
import _hardCodedCondition from './data/unlockConditions.json'
import _hardCodedCondition from "./data/unlockConditions.json";
const hardCodedCondition = _hardCodedCondition as Record<string, UnlockCondition>
const hardCodedCondition = _hardCodedCondition as Record<
string,
UnlockCondition
>;
let excluded: Set<PerkId>;
@ -26,28 +29,29 @@ function isExcluded(id: PerkId) {
return excluded.has(id);
}
export function getLevelUnlockCondition(levelIndex: number, levelName:string):UnlockCondition {
if(hardCodedCondition[levelName]) return hardCodedCondition[levelName]
export function getLevelUnlockCondition(
levelIndex: number,
levelName: string,
): UnlockCondition {
if (hardCodedCondition[levelName]) return hardCodedCondition[levelName];
const result: UnlockCondition = {
required: [],
forbidden: [],
minScore : Math.max(-1000 + 100 * levelIndex, 0)
}
minScore: Math.max(-1000 + 100 * levelIndex, 0),
};
if (levelIndex > 20) {
const possibletargets = [...upgrades]
.slice(0, Math.floor(levelIndex / 2))
.filter((u) => !isExcluded(u.id))
.sort(
(a, b) => hashCode(levelIndex + a.id) - hashCode(levelIndex + b.id),
).map(u => u.id);
.sort((a, b) => hashCode(levelIndex + a.id) - hashCode(levelIndex + b.id))
.map((u) => u.id);
const length = Math.min(3, Math.ceil(levelIndex / 30));
result.required = possibletargets.slice(0, length);
result.forbidden = possibletargets.slice(length, length + length);
}
return result
return result;
}
export function getBestScoreMatching(
@ -70,19 +74,25 @@ export function getBestScoreMatching(
export function isLevelLocked(
levelIndex: number,
levelName: string,
history: RunHistoryItem[]){
const {required, forbidden, minScore} = getLevelUnlockCondition(levelIndex, levelName);
return getBestScoreMatching(history, required, forbidden) < minScore
history: RunHistoryItem[],
) {
const { required, forbidden, minScore } = getLevelUnlockCondition(
levelIndex,
levelName,
);
return getBestScoreMatching(history, required, forbidden) < minScore;
}
export function reasonLevelIsLocked(
levelIndex: number,levelName:string,
levelIndex: number,
levelName: string,
history: RunHistoryItem[],
mentionBestScore: boolean,
): null | { reached: number; minScore: number; text: string } {
const {required, forbidden, minScore} = getLevelUnlockCondition(levelIndex, levelName);
const { required, forbidden, minScore } = getLevelUnlockCondition(
levelIndex,
levelName,
);
const reached = getBestScoreMatching(history, required, forbidden);
let reachedText =
reached && mentionBestScore ? t("unlocks.reached", { reached }) : "";
@ -109,5 +119,5 @@ export function reasonLevelIsLocked(
}
export function upgradeName(id: PerkId) {
return upgrades.find(u=>u.id==id)!.name
return upgrades.find((u) => u.id == id)!.name;
}

View file

@ -234,7 +234,7 @@ export async function editRawLevelList(nth: number, color = "W") {
});
return;
}
if (action === "copy" || action ==='show_code') {
if (action === "copy" || action === "show_code") {
let text =
"```\n[" +
(level.name || "unnamed level")?.replace(/\[|\]/gi, " ") +
@ -251,19 +251,21 @@ export async function editRawLevelList(nth: number, color = "W") {
if (action === "copy") {
try {
await navigator.clipboard.writeText(text);
toast(t('editor.editing.copied'))
toast(t("editor.editing.copied"));
} catch (e) {
if('message' in e) {
toast(e.message)
if ("message" in e) {
toast(e.message);
}
}
} else {
await asyncAlert({
title:t('editor.editing.show_code'),
content:[`
title: t("editor.editing.show_code"),
content: [
`
<pre>${text}</pre>
`]
})
`,
],
});
}
// return
}

View file

@ -4,7 +4,10 @@ import _appVersion from "./data/version.json";
import { generateSaveFileContent } from "./generateSaveFileContent";
import { allLevels } from "./loadGameData";
import { toast } from "./toast";
import {isLevelLocked, reasonLevelIsLocked} from "./get_level_unlock_condition";
import {
isLevelLocked,
reasonLevelIsLocked,
} from "./get_level_unlock_condition";
// The page will be reloaded if any migrations were run
let migrationsRun = 0;

View file

@ -12,7 +12,7 @@ let list: {
forbidden: PerkId[];
required: PerkId[];
}[];
let unlocked : Set<string> |null = null
let unlocked: Set<string> | null = null;
export function monitorLevelsUnlocks(gameState: GameState) {
if (!unlocked) {

View file

@ -13,7 +13,10 @@ import { isOptionOn } from "./options";
import { getHistory } from "./gameOver";
import { getSettingValue, getTotalScore } from "./settings";
import { isBlackListedForStart, isStartingPerk } from "./startingPerks";
import {isLevelLocked, reasonLevelIsLocked} from "./get_level_unlock_condition";
import {
isLevelLocked,
reasonLevelIsLocked,
} from "./get_level_unlock_condition";
export function getRunLevels(
params: RunParams,

View file

@ -1,17 +1,17 @@
import { GameState } from "./types";
import { asyncAlert } from "./asyncAlert";
import { t } from "./i18n/i18n";
import {
levelsListHTMl,
max_levels,
pickedUpgradesHTMl,
} from "./game_utils";
import { levelsListHTMl, max_levels, pickedUpgradesHTMl } from "./game_utils";
import { getCreativeModeWarning, getHistory } from "./gameOver";
import { pause } from "./game";
import { allLevels, icons } from "./loadGameData";
import { firstWhere } from "./pure_functions";
import { getSettingValue, getTotalScore } from "./settings";
import {getLevelUnlockCondition, reasonLevelIsLocked, upgradeName} from "./get_level_unlock_condition";
import {
getLevelUnlockCondition,
reasonLevelIsLocked,
upgradeName,
} from "./get_level_unlock_condition";
export async function openScorePanel(gameState: GameState) {
pause(true);
@ -44,7 +44,10 @@ export function getNearestUnlockHTML(gameState: GameState) {
const reason = reasonLevelIsLocked(li, l.name, getHistory(), false);
if (!reason) return;
const { minScore, forbidden, required } = getLevelUnlockCondition(li, l.name);
const { minScore, forbidden, required } = getLevelUnlockCondition(
li,
l.name,
);
const missing = required.filter((id) => !gameState?.perks?.[id]);
// we can't have a forbidden perk
if (forbidden.find((id) => gameState?.perks?.[id])) {
@ -69,7 +72,9 @@ export function getNearestUnlockHTML(gameState: GameState) {
if (!firstUnlockable) return "";
let missingPoints = Math.max(0, firstUnlockable.minScore - gameState.score);
let missingUpgrades = firstUnlockable.missing.map((id) => upgradeName(id)).join(", ");
let missingUpgrades = firstUnlockable.missing
.map((id) => upgradeName(id))
.join(", ");
const title =
(missingUpgrades &&

View file

@ -12,8 +12,10 @@ export const options = {
help: t("settings.sounds_help"),
},
"mobile-mode": {
default: window.innerHeight > window.innerWidth ||('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0) ,
default:
window.innerHeight > window.innerWidth ||
"ontouchstart" in window ||
navigator.maxTouchPoints > 0,
name: t("settings.mobile"),
help: t("settings.mobile_help"),
},

View file

@ -19,7 +19,8 @@ import { isOptionOn } from "./options";
import {
ballTransparency,
catchRateBest,
catchRateGood, clamp,
catchRateGood,
clamp,
coinsBoostedCombo,
levelTimeBest,
levelTimeGood,
@ -405,7 +406,10 @@ export function render(gameState: GameState) {
Math.max(
telekinesisEffectRate(gameState, ball),
yoyoEffectRate(gameState, ball),
) * ballAlpha,0,1);
) * ballAlpha,
0,
1,
);
ctx.strokeStyle = gameState.puckColor;
ctx.bezierCurveTo(
gameState.puckPosition,

View file

@ -14,9 +14,9 @@ export function hideAnyTooltip() {
const tooltip = document.getElementById("tooltip") as HTMLDivElement;
function setupMobileTooltips(tooltip: HTMLDivElement) {
tooltip.className='mobile'
tooltip.className = "mobile";
function openTooltip(e: Event) {
hideAnyTooltip()
hideAnyTooltip();
const hovering = e.target as HTMLElement;
if (!hovering?.hasAttribute("data-help-content")) {
return;
@ -27,7 +27,6 @@ function setupMobileTooltips(tooltip: HTMLDivElement) {
tooltip.style.display = "";
const { top } = hovering.getBoundingClientRect();
tooltip.style.transform = `translate(0,${top}px) translate(0,-100%)`;
}
document.body.addEventListener("touchstart", openTooltip, true);
@ -62,7 +61,7 @@ function setupMobileTooltips(tooltip: HTMLDivElement) {
}
function setupDesktopTooltips(tooltip: HTMLDivElement) {
tooltip.className='desktop'
tooltip.className = "desktop";
function updateTooltipPosition(e: { clientX: number; clientY: number }) {
tooltip.style.transform = `translate(${e.clientX}px,${e.clientY}px) translate(${e.clientX > window.innerWidth / 2 ? "-100%" : "0"},${e.clientY > (window.innerHeight * 2) / 3 ? "-100%" : "20px"})`;
}

9
src/types.d.ts vendored
View file

@ -301,14 +301,9 @@ export type OptionDef = {
help: string;
};
export type OptionId = keyof typeof options;
export type UpgradeLike = {
id: PerkId;
name: string;
requires: string;
threshold: number;
};
export type UnlockCondition = {
required: PerkId[];
forbidden: PerkId[];
minScore: number;
}
};

View file

@ -926,10 +926,10 @@ export const rawUpgrades = [
max: 4,
name: t("upgrades.passive_income.name"),
help: (lvl: number) =>
t("upgrades.passive_income.tooltip", { time: lvl * 0.10-0.05, lvl }),
t("upgrades.passive_income.tooltip", { time: lvl * 0.1 - 0.05, lvl }),
fullHelp: (lvl: number) =>
t("upgrades.passive_income.verbose_description", {
time: lvl * 0.10-0.05,
time: lvl * 0.1 - 0.05,
lvl,
}),
},