(orderedLevels, campaign = this.campaign)
| 1217 | } |
| 1218 | |
| 1219 | annotateLevels (orderedLevels, campaign = this.campaign) { |
| 1220 | if (this.isClassroom()) { return } |
| 1221 | |
| 1222 | for (let levelIndex = 0; levelIndex < orderedLevels.length; levelIndex++) { |
| 1223 | const level = orderedLevels[levelIndex] |
| 1224 | level.position = level.position ?? { x: 10, y: 10 } |
| 1225 | level.locked = !me.ownsLevel(level.original) |
| 1226 | if ((level.slug === 'kithgard-mastery') && (this.calculateExperienceScore() === 0)) { level.locked = true } |
| 1227 | if (level.requiresSubscription && this.requiresSubscription && me.isInHourOfCode()) { level.locked = true } |
| 1228 | if ([STARTED_STATUS, COMPLETE_STATUS].includes(this.levelStatusMap[level.slug])) { level.locked = false } |
| 1229 | if (this.editorMode) { level.locked = false } |
| 1230 | if (['Auditions', 'Intro'].includes(campaign?.get('name'))) { level.locked = false } |
| 1231 | if (me.isInGodMode()) { level.locked = false } |
| 1232 | if (this.courseInstanceID && level.hasAccessByTeacher(this.courseTeacher)) { level.locked = false } |
| 1233 | if (level.adminOnly && ![STARTED_STATUS, COMPLETE_STATUS].includes(this.levelStatusMap[level.slug])) { level.disabled = true } |
| 1234 | if (me.isInGodMode()) { level.disabled = false } |
| 1235 | |
| 1236 | level.color = colors.jayBlue |
| 1237 | if (this.editorMode && !level.requiresSubscription) { |
| 1238 | level.color = colors.lightBlue |
| 1239 | } |
| 1240 | if (level.locked) { |
| 1241 | level.color = colors.sparkySilver |
| 1242 | } else if (this.isLevelCompleted(level)) { |
| 1243 | level.color = colors.darkGreen |
| 1244 | } |
| 1245 | level.unlocksHero = level.rewards?.find(r => r.hero)?.hero |
| 1246 | if (level.unlocksHero) { |
| 1247 | level.purchasedHero = me.get('purchased')?.heroes?.includes(level.unlocksHero) |
| 1248 | } |
| 1249 | |
| 1250 | level.unlocksItem = level.rewards?.find(r => r.item)?.item |
| 1251 | level.unlocksPet = utils.petThangIDs.indexOf(level.unlocksItem) !== -1 |
| 1252 | |
| 1253 | if (this.classroom) { |
| 1254 | level.unlocksItem = false |
| 1255 | level.unlocksPet = false |
| 1256 | } |
| 1257 | |
| 1258 | level.hidden = level.locked && (campaign?.get('type') !== 'hoc') |
| 1259 | if (level.concepts?.length) { |
| 1260 | level.displayConcepts = level.concepts |
| 1261 | const maxConcepts = 6 |
| 1262 | if (level.displayConcepts.length > maxConcepts) { |
| 1263 | level.displayConcepts = level.displayConcepts.slice(-maxConcepts) |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | level.unlockedInSameCampaign = levelIndex < 5 // First few are always counted (probably unlocked in previous campaign) |
| 1268 | for (const otherLevel of orderedLevels) { |
| 1269 | if (!level.unlockedInSameCampaign && (otherLevel !== level)) { |
| 1270 | for (const reward of otherLevel.rewards ?? []) { |
| 1271 | if (reward.level) { |
| 1272 | if (!level.unlockedInSameCampaign) { level.unlockedInSameCampaign = reward.level === level.original } |
| 1273 | } |
| 1274 | } |
| 1275 | } |
| 1276 | } |
no test coverage detected