This commit is contained in:
Your Name
2026-06-02 18:33:25 +08:00
parent 62f74888f3
commit 15e9c486f9
11 changed files with 731 additions and 674 deletions
+16 -15
View File
@@ -1,5 +1,6 @@
/**
* 关卡配置:难度随关卡递增,驱动“再闯一关”动力
* 关卡配置:面向 45+ 的认知练习,节奏放慢、无失败惩罚。
* 每组目标只比上一组略增,步数充裕(仅展示,不会因耗尽判负)。
*/
export function getLevelConfig(levelId) {
const lv = Math.max(1, Math.min(999, Number(levelId) || 1))
@@ -7,26 +8,26 @@ export function getLevelConfig(levelId) {
return {
id: lv,
moves: Math.max(14, 26 - tier * 2 - (lv % 3)),
goalTargets: [8 + tier * 2 + (lv % 2), 10 + tier * 2 + Math.floor(lv / 4)],
scoreTarget: 2800 + lv * 450,
// 步数充裕:仅作展示,认全目标即可通关
moves: Math.max(40, 60 - tier * 2),
// 认识目标平缓增长,避免给老人压力
goalTargets: [6 + tier, 8 + tier],
scoreTarget: 2000 + lv * 300,
startGlucose: 50,
/** 餐后消化倒计时(秒):归零时按棋盘上剩余食物升糖 */
digestIntervalSec: Math.max(5, 10 - tier),
digestMultiplier: 1 + tier * 0.12,
boosters: {
insulin: Math.max(1, 3 - Math.floor(tier / 2)),
fiber: tier >= 3 ? 0 : 1,
meal: Math.max(2, 5 - tier)
insulin: 3,
fiber: 1,
meal: 5
}
}
}
/** 根据本局表现计算 1~3 星 */
export function calcLevelStars({ movesLeft, glucoseLevel, score, levelConfig }) {
/** 根据本局表现计算 1~3 星:完成即得星,步数越省星越多(不依赖血糖) */
export function calcLevelStars({ movesLeft, levelConfig }) {
const totalMoves = levelConfig?.moves || 1
const ratio = totalMoves > 0 ? movesLeft / totalMoves : 0
let stars = 1
const stable = glucoseLevel >= 30 && glucoseLevel <= 70
if (stable && movesLeft >= 2) stars = 2
if (stars >= 2 && score >= (levelConfig?.scoreTarget ?? 3000) && movesLeft >= 4) stars = 3
if (ratio >= 0.3) stars = 2
if (ratio >= 0.55) stars = 3
return stars
}