Give Campaigns types so that course campaigns can share hero levels

This commit is contained in:
Nick Winter 2015-11-12 10:25:05 -08:00
parent f7f7cd683e
commit fe05e66458
5 changed files with 8 additions and 9 deletions

View file

@ -57,10 +57,8 @@ module.exports = class LevelLoader extends CocoClass
@listenToOnce @level, 'sync', @onLevelLoaded @listenToOnce @level, 'sync', @onLevelLoaded
onLevelLoaded: -> onLevelLoaded: ->
console.log 'is course?', @isCourse, 'type', @level.get('type', true), @level.get('type', true) not in ['course', 'course-ladder']
if @isCourse and @level.get('type', true) not in ['course', 'course-ladder'] if @isCourse and @level.get('type', true) not in ['course', 'course-ladder']
# Because we now use original hero levels for both hero and course levels, we fake being a course level in this context. # Because we now use original hero levels for both hero and course levels, we fake being a course level in this context.
console.log 'doin it'
originalGet = @level.get originalGet = @level.get
@level.get = -> @level.get = ->
return 'course' if arguments[0] is 'type' return 'course' if arguments[0] is 'type'

View file

@ -1,12 +1,15 @@
c = require './../schemas' c = require './../schemas'
CampaignSchema = c.object() CampaignSchema = c.object
default:
type: 'hero'
c.extendNamedProperties CampaignSchema # name first c.extendNamedProperties CampaignSchema # name first
_.extend CampaignSchema.properties, { _.extend CampaignSchema.properties, {
i18n: {type: 'object', title: 'i18n', format: 'i18n', props: ['name', 'fullName', 'description']} i18n: {type: 'object', title: 'i18n', format: 'i18n', props: ['name', 'fullName', 'description']}
fullName: { type: 'string', title: 'Full Name', description: 'Ex.: "Kithgard Dungeon"' } fullName: { type: 'string', title: 'Full Name', description: 'Ex.: "Kithgard Dungeon"' }
description: { type: 'string', format: 'string', description: 'How long it takes and what players learn.' } description: { type: 'string', format: 'string', description: 'How long it takes and what players learn.' }
type: c.shortString(title: 'Type', description: 'What kind of campaign this is.', 'enum': ['hero', 'course'])
ambientSound: c.object {}, ambientSound: c.object {},
mp3: { type: 'string', format: 'sound-file' } mp3: { type: 'string', format: 'sound-file' }

View file

@ -127,7 +127,8 @@ module.exports = class CampaignEditorView extends RootView
rewards.push rewardObject rewards.push rewardObject
campaignLevel.rewards = rewards campaignLevel.rewards = rewards
delete campaignLevel.unlocks delete campaignLevel.unlocks
campaignLevel.campaign = @campaign.get 'slug' # Save campaign to level, unless it's a course campaign, since we reuse hero levels for course levels.
campaignLevel.campaign = @campaign.get 'slug' if @campaign.get('type', true) isnt 'course'
campaignLevels[levelOriginal] = campaignLevel campaignLevels[levelOriginal] = campaignLevel
@campaign.set('levels', campaignLevels) @campaign.set('levels', campaignLevels)

View file

@ -11,6 +11,7 @@ CampaignHandler = class CampaignHandler extends Handler
'name' 'name'
'fullName' 'fullName'
'description' 'description'
'type'
'i18n' 'i18n'
'i18nCoverage' 'i18nCoverage'
'ambientSound' 'ambientSound'

View file

@ -17,10 +17,6 @@ UserSchema = new mongoose.Schema({
dateCreated: dateCreated:
type: Date type: Date
'default': Date.now 'default': Date.now
currentCourse: {
courseID: mongoose.Schema.Types.ObjectId
courseInstanceID: mongoose.Schema.Types.ObjectId
}
}, {strict: false}) }, {strict: false})
UserSchema.index({'dateCreated': 1}) UserSchema.index({'dateCreated': 1})
@ -323,7 +319,7 @@ UserSchema.statics.editableProperties = [
'firstName', 'lastName', 'gender', 'ageRange', 'facebookID', 'gplusID', 'emails', 'firstName', 'lastName', 'gender', 'ageRange', 'facebookID', 'gplusID', 'emails',
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage', 'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile', 'savedEmployerFilterAlerts', 'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile', 'savedEmployerFilterAlerts',
'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer', 'currentCourse' 'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer'
] ]
UserSchema.plugin plugins.NamedPlugin UserSchema.plugin plugins.NamedPlugin