({ level, session })
| 127 | } |
| 128 | |
| 129 | static getTopScores ({ level, session }) { |
| 130 | let score |
| 131 | const Level = require('models/Level') |
| 132 | const scores = ((() => { |
| 133 | const result = [] |
| 134 | for (score of Array.from((session.state != null ? session.state.topScores : undefined) != null ? (session.state != null ? session.state.topScores : undefined) : [])) { |
| 135 | result.push(_.clone(score)) |
| 136 | } |
| 137 | return result |
| 138 | })()) |
| 139 | for (score of Array.from(scores)) { if (Array.from(LevelConstants.lowerIsBetterScoreTypes).includes(score.type)) { score.score *= -1 } } // Undo negative storage for display |
| 140 | if (level) { |
| 141 | for (const sessionScore of Array.from(scores)) { |
| 142 | const thresholdAchieved = Level.thresholdForScore(_.assign(_.pick(sessionScore, 'score', 'type'), { level })) |
| 143 | if (thresholdAchieved) { |
| 144 | sessionScore.thresholdAchieved = thresholdAchieved |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | return scores // 24 characters like other IDs for schema validation |
| 149 | } |
| 150 | |
| 151 | isFake () { return this.id === LevelSession.fakeID } |
| 152 |
no test coverage detected