mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-23 21:46:15 -04:00
Fixed enderman level background and level picker in unlock
This commit is contained in:
parent
f28ce15495
commit
e14e958686
6 changed files with 94 additions and 55 deletions
|
@ -495,13 +495,13 @@ function getPossibleUpgrades() {
|
|||
function shuffleLevels(nameToAvoid: string | null = null) {
|
||||
const target = nextRunOverrides?.level;
|
||||
delete nextRunOverrides.level;
|
||||
const firstLevel = nextRunOverrides?.level
|
||||
const firstLevel = target
|
||||
? allLevels.filter((l) => l.name === target)
|
||||
: [];
|
||||
|
||||
const restInRandomOrder = allLevels
|
||||
.filter((l) => totalScoreAtRunStart >= l.threshold)
|
||||
.filter((l) => l.name !== nextRunOverrides?.level)
|
||||
.filter((l) => l.name !== target)
|
||||
.filter((l) => l.name !== nameToAvoid || allLevels.length === 1)
|
||||
.sort(() => Math.random() - 0.5);
|
||||
|
||||
|
|
|
@ -151,8 +151,8 @@
|
|||
"name": "Enderman",
|
||||
"size": 10,
|
||||
"bricks": "___________gggggggg__gggggggg__gggggggg__gggggggg__vvvggvvv__gggggggg__gggggggg__gggggggg_____________________",
|
||||
"svg": null,
|
||||
"color": "#ffffff"
|
||||
"svg": "",
|
||||
"color": "#26a269"
|
||||
},
|
||||
{
|
||||
"name": "Mushroom",
|
||||
|
|
|
@ -11,7 +11,6 @@ const rawLevelsList = _rawLevelsList as RawLevel[];
|
|||
|
||||
export const appVersion = _appVersion as string;
|
||||
|
||||
let attributed = 0;
|
||||
|
||||
let levelIconHTMLCanvas = document.createElement("canvas");
|
||||
const levelIconHTMLCanvasCtx = levelIconHTMLCanvas.getContext("2d", {
|
||||
|
@ -69,8 +68,7 @@ export const allLevels = rawLevelsList
|
|||
let svg = level.svg!==null && backgrounds[level.svg]
|
||||
|
||||
if (!level.color && !svg) {
|
||||
svg = backgrounds[attributed % backgrounds.length];
|
||||
attributed++;
|
||||
svg = backgrounds[hashCode(level.name) % backgrounds.length];
|
||||
}
|
||||
return {
|
||||
...level,
|
||||
|
@ -95,3 +93,14 @@ export const upgrades = rawUpgrades.map((u) => ({
|
|||
...u,
|
||||
icon: icons["icon:" + u.id],
|
||||
})) as Upgrade[];
|
||||
|
||||
|
||||
function hashCode(string:string){
|
||||
let hash = 0;
|
||||
for (let i = 0; i < string.length; i++) {
|
||||
let code = string.charCodeAt(i);
|
||||
hash = ((hash<<5)-hash)+code;
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue