Added heroClass and gem fields to the ThangTypes, and a new Hero kind. Fixed adding new ThangType properties in the Thang Editor.

This commit is contained in:
Nick Winter 2014-10-29 15:34:04 -07:00
parent a123fb4b08
commit 98fe639010
3 changed files with 13 additions and 5 deletions
app
schemas/models
views/editor/thang
server/levels/thangs

View file

@ -105,9 +105,10 @@ _.extend ThangTypeSchema.properties,
shapes: c.object {title: 'Shapes', additionalProperties: ShapeObjectSchema}
containers: c.object {title: 'Containers', additionalProperties: ContainerObjectSchema}
animations: c.object {title: 'Animations', additionalProperties: RawAnimationObjectSchema}
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark', 'Item'], default: 'Misc', title: 'Kind'}
kind: c.shortString {enum: ['Unit', 'Floor', 'Wall', 'Doodad', 'Misc', 'Mark', 'Item', 'Hero'], default: 'Misc', title: 'Kind'}
terrains: c.array {title: 'Terrains', description: 'If specified, limits this ThangType to levels with matching terrains.', uniqueItems: true}, c.terrainString
gems: {type: 'integer', minimum: 0, title: 'Gem Cost', description: 'How many gems this item or hero costs.'}
heroClass: {type: 'string', enum: ['Warrior', 'Ranger', 'Wizard'], title: 'Hero Class', description: 'What class this is (if a hero) or is restricted to (if an item). Leave undefined for most items.'}
actions: c.object {title: 'Actions', additionalProperties: {$ref: '#/definitions/action'}}
soundTriggers: c.object {title: 'Sound Triggers', additionalProperties: c.array({}, {$ref: '#/definitions/sound'})},
say: c.object {format: 'slug-props', additionalProperties: {$ref: '#/definitions/sound'}},

View file

@ -354,7 +354,7 @@ module.exports = class ThangTypeEditView extends RootView
newThangType = if e.major then @thangType.cloneNewMajorVersion() else @thangType.cloneNewMinorVersion()
newThangType.set('commitMessage', e.commitMessage)
newThangType.updateI18NCoverage() if newThangType.get('i18nCoverage')
res = newThangType.save()
return unless res
modal = $('#save-version-modal')
@ -406,9 +406,14 @@ module.exports = class ThangTypeEditView extends RootView
pushChangesToPreview: =>
return if @temporarilyIgnoringChanges
keysProcessed = {}
for key of @thangType.attributes
keysProcessed[key] = true
continue if key is 'components'
@thangType.set(key, @treema.data[key])
for key, value of @treema.data when not keysProcessed[key]
@thangType.set(key, value)
@updateSelectBox()
@refreshAnimation()
@updateDots()

View file

@ -38,6 +38,8 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
'i18nCoverage'
'i18n'
'description'
'gems'
'heroClass'
]
hasAccess: (req) ->
@ -45,7 +47,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
hasAccessToDocument: (req, document, method=null) ->
method = (method or req.method).toLowerCase()
return true if method is 'get'
return true if method is 'get'
return true if req.user?.isAdmin()
return true if method is 'put' and @isJustFillingTranslations(req, document)
return
@ -63,7 +65,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
query.original = {$in: _.values heroes} # TODO: replace with some sort of ThangType property later
else if req.query.view is 'i18n-coverage'
query.i18nCoverage = {$exists: true}
q = ThangType.find(query, projection)
skip = parseInt(req.query.skip)
if skip? and skip < 1000000