From 9f0ae9ff09e32bd1874c2a922ab40f5729e7357f Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Sun, 7 Dec 2014 14:57:23 -0800 Subject: [PATCH] Ditched dependency on index 0 as first unlocked level, instead explicitly granting Dungeons of Kithgard. --- app/models/Level.coffee | 3 +++ app/models/User.coffee | 3 ++- app/views/play/WorldMapView.coffee | 15 ++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/models/Level.coffee b/app/models/Level.coffee index 17bc517b4..8bde6ede4 100644 --- a/app/models/Level.coffee +++ b/app/models/Level.coffee @@ -6,6 +6,9 @@ ThangType = require './ThangType' module.exports = class Level extends CocoModel @className: 'Level' @schema: require 'schemas/models/level' + @levels: + 'dungeons-of-kithgard': '5411cb3769152f1707be029c' + 'defense-of-plainswood': '541b67f71ccc8eaae19f3c62' urlRoot: '/db/level' serialize: (supermodel, session, otherSession, cached=false) -> diff --git a/app/models/User.coffee b/app/models/User.coffee index 90a7264fa..e3bf5e798 100644 --- a/app/models/User.coffee +++ b/app/models/User.coffee @@ -3,6 +3,7 @@ cache = {} CocoModel = require './CocoModel' util = require 'core/utils' ThangType = require './ThangType' +Level = require './Level' module.exports = class User extends CocoModel @className: 'User' @@ -90,7 +91,7 @@ module.exports = class User extends CocoModel #heroes = _.values ThangType.heroes if me.isAdmin() heroes items: -> (me.get('earned')?.items ? []).concat(me.get('purchased')?.items ? []).concat([ThangType.items['simple-boots']]) - levels: -> (me.get('earned')?.levels ? []).concat(me.get('purchased')?.levels ? []) + levels: -> (me.get('earned')?.levels ? []).concat(me.get('purchased')?.levels ? []).concat(Level.levels['dungeons-of-kithgard']) ownsHero: (heroOriginal) -> heroOriginal in @heroes() ownsItem: (itemOriginal) -> itemOriginal in @items() ownsLevel: (levelOriginal) -> levelOriginal in @levels() diff --git a/app/views/play/WorldMapView.coffee b/app/views/play/WorldMapView.coffee index a628d3b45..0fb1199a1 100644 --- a/app/views/play/WorldMapView.coffee +++ b/app/views/play/WorldMapView.coffee @@ -10,6 +10,7 @@ MusicPlayer = require 'lib/surface/MusicPlayer' storage = require 'core/storage' AuthModal = require 'views/core/AuthModal' SubscribeModal = require 'views/play/modal/SubscribeModal' +Level = require 'models/Level' trackedHourOfCode = false @@ -126,10 +127,10 @@ module.exports = class WorldMapView extends RootView getRenderData: (context={}) -> context = super(context) context.campaign = _.find campaigns, { id: @terrain } - for level, index in context.campaign.levels + for level in context.campaign.levels level.x ?= 10 + 80 * Math.random() level.y ?= 10 + 80 * Math.random() - level.locked = index > 0 and not me.ownsLevel level.original + level.locked = not me.ownsLevel level.original window.levelUnlocksNotWorking = true if level.locked and level.id is @nextLevel # Temporary level.locked = false if window.levelUnlocksNotWorking # Temporary; also possible in HeroVictoryModal level.locked = false if @levelStatusMap[level.id] in ['started', 'complete'] @@ -139,16 +140,16 @@ module.exports = class WorldMapView extends RootView if level.requiresSubscription level.color = 'rgb(80, 130, 200)' level.hidden = level.locked or level.disabled - - # put lower levels in last, so in the world map they layer over one another properly. + + # put lower levels in last, so in the world map they layer over one another properly. context.campaign.levels = (_.sortBy context.campaign.levels, 'y').reverse() - + context.levelStatusMap = @levelStatusMap context.levelPlayCountMap = @levelPlayCountMap context.isIPadApp = application.isIPadApp context.mapType = _.string.slugify @terrain context.nextLevel = @nextLevel - context.forestIsAvailable = @startedForestLevel or '541b67f71ccc8eaae19f3c62' in (me.get('earned')?.levels or []) + context.forestIsAvailable = @startedForestLevel or (Level.levels['defense-of-plainswood'] in (me.get('earned')?.levels or [])) context.requiresSubscription = @requiresSubscription context @@ -350,7 +351,7 @@ dungeon = [ name: 'Dungeons of Kithgard' type: 'hero' id: 'dungeons-of-kithgard' - original: '528110f30268d018e3000001' + original: '5411cb3769152f1707be029c' description: 'Grab the gem, but touch nothing else. Start here.' x: 14 y: 15.5