From 69e7c68784d99554b052ae0524e1f41722492487 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 7 Aug 2015 07:33:30 -0700 Subject: [PATCH] Hide Kithgard Mastery from slow/young players, and highlight it once for fast/old players. Fix clan button link. --- app/templates/play/campaign-view.jade | 2 +- app/views/play/CampaignView.coffee | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/templates/play/campaign-view.jade b/app/templates/play/campaign-view.jade index b1d35b33f..53bb2bb36 100644 --- a/app/templates/play/campaign-view.jade +++ b/app/templates/play/campaign-view.jade @@ -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") diff --git a/app/views/play/CampaignView.coffee b/app/views/play/CampaignView.coffee index f5d50e172..f0eb003b6 100644 --- a/app/views/play/CampaignView.coffee +++ b/app/views/play/CampaignView.coffee @@ -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