2014-12-11 14:26:28 -05:00
|
|
|
CocoModel = require './CocoModel'
|
2014-12-16 20:46:24 -05:00
|
|
|
schema = require 'schemas/models/campaign.schema'
|
2015-11-23 11:46:08 -05:00
|
|
|
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'
|
2014-12-11 14:26:28 -05:00
|
|
|
|
|
|
|
module.exports = class Campaign extends CocoModel
|
|
|
|
@className: 'Campaign'
|
2014-12-16 20:46:24 -05:00
|
|
|
@schema: schema
|
2014-12-11 14:26:28 -05:00
|
|
|
urlRoot: '/db/campaign'
|
2014-12-22 16:21:57 -05:00
|
|
|
@denormalizedLevelProperties: _.keys(_.omit(schema.properties.levels.additionalProperties.properties, ['unlocks', 'position', 'rewards']))
|
2015-12-03 15:47:28 -05:00
|
|
|
@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
|