codecombat/app/models/Campaign.coffee

26 lines
889 B
CoffeeScript
Raw Normal View History

CocoModel = require './CocoModel'
schema = require 'schemas/models/campaign.schema'
Level = require 'models/Level'
2016-03-30 16:57:19 -04:00
Levels = require 'collections/Levels'
2015-11-29 13:27:40 -05:00
CocoCollection = require 'collections/CocoCollection'
module.exports = class Campaign extends CocoModel
@className: 'Campaign'
@schema: schema
urlRoot: '/db/campaign'
2014-12-22 16:21:57 -05:00
@denormalizedLevelProperties: _.keys(_.omit(schema.properties.levels.additionalProperties.properties, ['unlocks', 'position', 'rewards']))
@denormalizedCampaignProperties: ['name', 'i18n', 'slug']
2016-03-30 16:57:19 -04:00
getLevels: ->
levels = new Levels(_.values(@get('levels')))
levels.comparator = 'campaignIndex'
levels.sort()
return levels
getNonLadderLevels: ->
levels = new Levels(_.values(@get('levels')))
levels.reset(levels.reject (level) -> level.isLadder())
levels.comparator = 'campaignIndex'
levels.sort()
return levels