增加单人游戏结束后星星的获取

This commit is contained in:
zhl 2021-05-12 17:46:58 +08:00
parent e71accb7b9
commit dcf7a0be44
4 changed files with 13 additions and 6 deletions

View File

@ -93,6 +93,7 @@
"comboCount": 0, // 当前连续答对的数量
"maxCombo": 1, // 当局连续答对的最大数量
"score": 10, // 当局胜利后的得分
"star": 1, // 当局胜利后获得的星星
"gameResult": 0 // 当局的游戏结果, 单人的话和上一层gameResult相同
}
}

View File

@ -143,7 +143,7 @@ class PuzzleController extends BaseController {
if (gameResult) {
history.status = 9
if (gameResult === 1) {
let score = calcSingleScore(history, accountid)
let { score } = calcSingleScore(history, accountid)
let rankObj = {
shop: history.shop,
level: history.level,

View File

@ -50,6 +50,9 @@ export class PuzzleStatusClass {
@prop({default: 0})
score: number
@prop({default: 0})
star: number
/**
*
* @type {number}

View File

@ -208,12 +208,15 @@ export function calcSingleScore(history: any, accountId: string) {
hp = hp < 0 ? 0 : hp
time = time < 0 ? 0 : time
let cfg = new GameEnv()
let score = time * cfg.singleTimeRate + hp * cfg.singleHpRate + combo * cfg.singleComboRate
if (history.difficultyMode) {
score *= cfg.singleLowLvlRate
}
let score = time * cfg.singleTimeRate + hp * cfg.singleHpRate + combo * cfg.singleComboRate;
(history.difficultyMode) && (score *= cfg.singleLowLvlRate)
stat.score = score
return score
let star = 0;
(time >= cfgLevel.timestar) && star++;
(stat.maxCombo >= cfgLevel.enemystar) && star++;
(hp >= cfgLevel.hpstar) && star ++;
stat.star = star
return { score, star }
}
/**