mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Hide Kithgard Mastery from slow/young players, and highlight it once for fast/old players. Fix clan button link.
This commit is contained in:
parent
66212b0559
commit
69e7c68784
2 changed files with 23 additions and 3 deletions
|
@ -90,7 +90,7 @@ else
|
|||
|
||||
.game-controls.header-font
|
||||
button.btn.poll.hidden(data-i18n="[title]play.poll")
|
||||
button.btn.clans(href="/clans", data-i18n="[title]clans.clans")
|
||||
a.btn.clans(href="/clans", data-i18n="[title]clans.clans")
|
||||
button.btn.items(data-toggle='coco-modal', data-target='play/modal/PlayItemsModal', data-i18n="[title]play.items")
|
||||
button.btn.heroes(data-toggle='coco-modal', data-target='play/modal/PlayHeroesModal', data-i18n="[title]play.heroes")
|
||||
button.btn.achievements(data-toggle='coco-modal', data-target='play/modal/PlayAchievementsModal', data-i18n="[title]play.achievements")
|
||||
|
|
|
@ -30,7 +30,7 @@ class LevelSessionsCollection extends CocoCollection
|
|||
|
||||
constructor: (model) ->
|
||||
super()
|
||||
@url = "/db/user/#{me.id}/level.sessions?project=state.complete,levelID,state.difficulty"
|
||||
@url = "/db/user/#{me.id}/level.sessions?project=state.complete,levelID,state.difficulty,playtime"
|
||||
|
||||
class CampaignsCollection extends CocoCollection
|
||||
url: '/db/campaign'
|
||||
|
@ -261,6 +261,7 @@ module.exports = class CampaignView extends RootView
|
|||
annotateLevel: (level) ->
|
||||
level.position ?= { x: 10, y: 10 }
|
||||
level.locked = not me.ownsLevel level.original
|
||||
level.locked = true if level.slug is 'kithgard-mastery' and @calculateExperienceScore() is 0
|
||||
level.locked = false if @levelStatusMap[level.slug] in ['started', 'complete']
|
||||
level.locked = false if @editorMode
|
||||
level.locked = false if @campaign?.get('name') is 'Auditions'
|
||||
|
@ -302,12 +303,22 @@ module.exports = class CampaignView extends RootView
|
|||
|
||||
determineNextLevel: (levels) ->
|
||||
foundNext = false
|
||||
dontPointTo = ['lost-viking', 'kithgard-mastery'] # Challenge levels we don't want most players bashing heads against
|
||||
for level in levels
|
||||
# Iterate through all levels in order and look to find the first unlocked one that meets all our criteria for being pointed out as the next level.
|
||||
level.nextLevels = (reward.level for reward in level.rewards ? [] when reward.level)
|
||||
unless foundNext
|
||||
for nextLevelOriginal in level.nextLevels
|
||||
nextLevel = _.find levels, original: nextLevelOriginal
|
||||
dontPointTo = ['lost-viking','kithgard-mastery']
|
||||
|
||||
# If it's a challenge level, we efficiently determine whether we actually do want to point it out.
|
||||
if nextLevel and nextLevel.slug is 'kithgard-mastery' and not nextLevel.locked and not @levelStatusMap[nextLevel.slug] and @calculateExperienceScore() >= 3
|
||||
unless (timesPointedOut = storage.load("pointed-out-#{nextLevel.slug}") or 0) > 3
|
||||
# We may determineNextLevel more than once per render, so we can't just do this once. But we do give up after a couple highlights.
|
||||
dontPointTo = _.without dontPointTo, nextLevel.slug
|
||||
storage.save "pointed-out-#{nextLevel.slug}", timesPointedOut + 1
|
||||
|
||||
# Should we point this level out?
|
||||
if nextLevel and not nextLevel.locked and not nextLevel.disabled and @levelStatusMap[nextLevel.slug] isnt 'complete' and nextLevel.slug not in dontPointTo and not nextLevel.replayable and (
|
||||
me.isPremium() or
|
||||
not nextLevel.requiresSubscription or
|
||||
|
@ -320,6 +331,15 @@ module.exports = class CampaignView extends RootView
|
|||
if not foundNext and levels[0] and not levels[0].locked and @levelStatusMap[levels[0].slug] isnt 'complete'
|
||||
levels[0].next = true
|
||||
|
||||
calculateExperienceScore: ->
|
||||
adultPoint = me.get('ageRange') in ['18-24', '25-34', '35-44', '45-100'] # They have to have answered the poll for this, likely after Shadow Guard.
|
||||
speedPoints = 0
|
||||
for [levelSlug, speedThreshold] in [['dungeons-of-kithgard', 50], ['gems-in-the-deep', 55], ['shadow-guard', 55], ['forgetful-gemsmith', 40], ['true-names', 40]]
|
||||
if _.find(@sessions.models, (session) -> session.get('levelID') is levelSlug)?.attributes.playtime <= speedThreshold
|
||||
++speedPoints
|
||||
experienceScore = adultPoint + speedPoints # 0-6 score of how likely we think they are to be experienced and ready for Kithgard Mastery
|
||||
return experienceScore
|
||||
|
||||
createLine: (o1, o2) ->
|
||||
p1 = x: o1.x, y: 0.66 * o1.y + 0.5
|
||||
p2 = x: o2.x, y: 0.66 * o2.y + 0.5
|
||||
|
|
Loading…
Reference in a new issue