diff --git a/doc/api.md b/doc/api.md index 5f858d5..cc8c8fa 100644 --- a/doc/api.md +++ b/doc/api.md @@ -93,6 +93,7 @@ "comboCount": 0, // 当前连续答对的数量 "maxCombo": 1, // 当局连续答对的最大数量 "score": 10, // 当局胜利后的得分 + "star": 1, // 当局胜利后获得的星星 "gameResult": 0 // 当局的游戏结果, 单人的话和上一层gameResult相同 } } diff --git a/src/api/controllers/puzzle.controller.ts b/src/api/controllers/puzzle.controller.ts index f5197f9..2d7bf75 100644 --- a/src/api/controllers/puzzle.controller.ts +++ b/src/api/controllers/puzzle.controller.ts @@ -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, diff --git a/src/models/match/PuzzleSession.ts b/src/models/match/PuzzleSession.ts index 27a9f72..08dc2c3 100644 --- a/src/models/match/PuzzleSession.ts +++ b/src/models/match/PuzzleSession.ts @@ -50,6 +50,9 @@ export class PuzzleStatusClass { @prop({default: 0}) score: number + @prop({default: 0}) + star: number + /** * 游戏结果 * @type {number} diff --git a/src/services/GameLogic.ts b/src/services/GameLogic.ts index 27be482..f835cbb 100644 --- a/src/services/GameLogic.ts +++ b/src/services/GameLogic.ts @@ -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 } } /**