(orderedLevels, campaign, ignorePracticeLevels = false)
| 1285 | } |
| 1286 | |
| 1287 | countLevels (orderedLevels, campaign, ignorePracticeLevels = false) { |
| 1288 | const count = { total: 0, completed: 0, unlocked: 0 } |
| 1289 | |
| 1290 | if (campaign?.get('type') === 'hoc') { |
| 1291 | // HoC: Just order left-to-right instead of looking at unlocks, which we don't use for this copycat campaign |
| 1292 | orderedLevels = _.sortBy(orderedLevels, level => level.position.x) |
| 1293 | for (const level of orderedLevels) { |
| 1294 | if (ignorePracticeLevels && level.practice) { continue } |
| 1295 | if (this.levelStatusMap[level.slug] === COMPLETE_STATUS) { count.completed++ } |
| 1296 | if (!level.locked) { ++count.unlocked } |
| 1297 | ++count.total |
| 1298 | } |
| 1299 | return count |
| 1300 | } |
| 1301 | |
| 1302 | for (let levelIndex = 0; levelIndex < orderedLevels.length; levelIndex++) { |
| 1303 | const level = orderedLevels[levelIndex] |
| 1304 | if (level.locked == null) { this.annotateLevels(orderedLevels, campaign) } // Annotate if we haven't already. |
| 1305 | if (ignorePracticeLevels && level.practice) { continue } |
| 1306 | if (!level.locked) { ++count.unlocked } |
| 1307 | if (level.disabled) { continue } |
| 1308 | const completed = this.levelStatusMap[level.slug] === COMPLETE_STATUS |
| 1309 | const started = this.levelStatusMap[level.slug] === STARTED_STATUS |
| 1310 | if ((level.unlockedInSameCampaign || !level.locked) && (started || completed || !(level.locked && level.practice && /-[a-z]$/.test(level.slug)))) { |
| 1311 | ++count.total |
| 1312 | } |
| 1313 | if (completed) { ++count.completed } |
| 1314 | } |
| 1315 | |
| 1316 | return count |
| 1317 | } |
| 1318 | |
| 1319 | showLeaderboard (levelSlug) { |
| 1320 | const leaderboardModal = new LeaderboardModal({ supermodel: this.supermodel, levelSlug }) |
no test coverage detected