mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
Give Campaigns types so that course campaigns can share hero levels
This commit is contained in:
parent
f7f7cd683e
commit
fe05e66458
5 changed files with 8 additions and 9 deletions
|
@ -57,10 +57,8 @@ module.exports = class LevelLoader extends CocoClass
|
|||
@listenToOnce @level, 'sync', @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']
|
||||
# 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
|
||||
@level.get = ->
|
||||
return 'course' if arguments[0] is 'type'
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
c = require './../schemas'
|
||||
|
||||
CampaignSchema = c.object()
|
||||
CampaignSchema = c.object
|
||||
default:
|
||||
type: 'hero'
|
||||
c.extendNamedProperties CampaignSchema # name first
|
||||
|
||||
_.extend CampaignSchema.properties, {
|
||||
i18n: {type: 'object', title: 'i18n', format: 'i18n', props: ['name', 'fullName', 'description']}
|
||||
fullName: { type: 'string', title: 'Full Name', description: 'Ex.: "Kithgard Dungeon"' }
|
||||
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 {},
|
||||
mp3: { type: 'string', format: 'sound-file' }
|
||||
|
|
|
@ -127,7 +127,8 @@ module.exports = class CampaignEditorView extends RootView
|
|||
rewards.push rewardObject
|
||||
campaignLevel.rewards = rewards
|
||||
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
|
||||
|
||||
@campaign.set('levels', campaignLevels)
|
||||
|
|
|
@ -11,6 +11,7 @@ CampaignHandler = class CampaignHandler extends Handler
|
|||
'name'
|
||||
'fullName'
|
||||
'description'
|
||||
'type'
|
||||
'i18n'
|
||||
'i18nCoverage'
|
||||
'ambientSound'
|
||||
|
|
|
@ -17,10 +17,6 @@ UserSchema = new mongoose.Schema({
|
|||
dateCreated:
|
||||
type: Date
|
||||
'default': Date.now
|
||||
currentCourse: {
|
||||
courseID: mongoose.Schema.Types.ObjectId
|
||||
courseInstanceID: mongoose.Schema.Types.ObjectId
|
||||
}
|
||||
}, {strict: false})
|
||||
|
||||
UserSchema.index({'dateCreated': 1})
|
||||
|
@ -323,7 +319,7 @@ UserSchema.statics.editableProperties = [
|
|||
'firstName', 'lastName', 'gender', 'ageRange', 'facebookID', 'gplusID', 'emails',
|
||||
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
|
||||
'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile', 'savedEmployerFilterAlerts',
|
||||
'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer', 'currentCourse'
|
||||
'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer'
|
||||
]
|
||||
|
||||
UserSchema.plugin plugins.NamedPlugin
|
||||
|
|
Loading…
Reference in a new issue