This commit is contained in:
Renan LE CARO 2025-02-17 14:31:43 +01:00
parent 5821716dc6
commit 20f540849c
3 changed files with 1002 additions and 673 deletions

View file

@ -12,7 +12,7 @@ At the end of each level, you get to select an upgrade.
[Donate](https://github.com/sponsors/renanlecaro) [Donate](https://github.com/sponsors/renanlecaro)
## TODO ## TODO
- automate itch update https://itch.io/docs/butler/pushing.html
- apply a minimum speed to the ball (when 2 slower balls picked it is crawling) - apply a minimum speed to the ball (when 2 slower balls picked it is crawling)
- Fdroid - Fdroid
- easily start a test game with specific upgrades or levels (with query string or through menu) - easily start a test game with specific upgrades or levels (with query string or through menu)

View file

@ -576,12 +576,14 @@ const upgrades = [
"threshold": 87000, "threshold": 87000,
"id": "ball_repulse_ball", "id": "ball_repulse_ball",
"name": "Balls repulse balls", "name": "Balls repulse balls",
requires:'multiball',
"max": 3, "max": 3,
"help": "Only has an effect with 2+ balls." "help": "Only has an effect with 2+ balls."
}, },
{ {
"threshold": 98000, "threshold": 98000,
"id": "ball_attract_ball", "id": "ball_attract_ball",
requires:'multiball',
"name": "Balls attract balls", "name": "Balls attract balls",
"max": 3, "max": 3,
"help": "Only has an effect with 2+ balls." "help": "Only has an effect with 2+ balls."
@ -601,6 +603,7 @@ function getPossibleUpgrades() {
return upgrades return upgrades
.filter(u => !(isSettingOn('color_blind') && u.color_blind_exclude)) .filter(u => !(isSettingOn('color_blind') && u.color_blind_exclude))
.filter(u => ts>=u.threshold) .filter(u => ts>=u.threshold)
.filter(u => !u.requires || perks[u.requires])
} }
@ -643,10 +646,12 @@ function getUpgraderUnlockPoints() {
} }
let lastOffered={}
function pickRandomUpgrades(count) { function pickRandomUpgrades(count) {
let list = getPossibleUpgrades() let list = getPossibleUpgrades()
.sort(() => Math.random() - 0.5) .map(u=>({...u, score:Math.random() + (lastOffered[u.id]||0) }))
.sort((a,b) => a.score-b.score)
.filter(u => perks[u.id] < u.max) .filter(u => perks[u.id] < u.max)
.slice(0, count) .slice(0, count)
.sort((a, b) => a.id > b.id ? 1 : -1) .sort((a, b) => a.id > b.id ? 1 : -1)
@ -663,6 +668,10 @@ function pickRandomUpgrades(count) {
}) })
list.forEach(u=> {
lastOffered[u.key] = Math.round(Date.now()/1000)
})
return list; return list;
} }
@ -2231,7 +2240,7 @@ async function openSettingsPanel() {
const avaliable = ts >= l.threshold const avaliable = ts >= l.threshold
return ({ return ({
text: l.name, text: l.name,
help: `A ${l.size}x${l.size} level` + (avaliable ? '' : `(${l.threshold} coins)`), help: `A ${l.size}x${l.size} level with ${l.bricks.filter(i => i).length} bricks` + (avaliable ? '' : `(${l.threshold} coins)`),
disabled: !avaliable, disabled: !avaliable,
value: {level: l.name} value: {level: l.name}

File diff suppressed because one or more lines are too long