This commit is contained in:
George Saines 2014-09-04 16:59:52 -07:00
commit d1f6b6ef51
7 changed files with 30 additions and 34 deletions

View file

@ -42,3 +42,14 @@ module.exports = class LevelSession extends CocoModel
completed: -> completed: ->
@get('state')?.complete || false @get('state')?.complete || false
shouldAvoidCorruptData: (attrs) ->
return false unless me.team is 'humans'
if _.string.startsWith (attrs?.code ? @get('code'))?.anya?.makeBid ? '', 'var __interceptThis'
noty text: "Not saving session--it's trying to overwrite Anya's code with transpiled output. Please let us know and help us reproduce this bug!", layout: 'topCenter', type: 'error', killer: false, timeout: 120000
return true
false
save: (attrs, options) ->
return if @shouldAvoidCorruptData attrs
super attrs, options

View file

@ -2,8 +2,7 @@ c = require './../schemas'
# TODO add these: http://docs.mongodb.org/manual/reference/operator/query/ # TODO add these: http://docs.mongodb.org/manual/reference/operator/query/
MongoQueryOperatorSchema = MongoQueryOperatorSchema =
title: 'MongoDB Query operator' title: 'Query Operator'
id: 'mongoQueryOperator'
type: 'object' type: 'object'
properties: properties:
'$gt': type: 'number' '$gt': type: 'number'
@ -13,26 +12,23 @@ MongoQueryOperatorSchema =
'$lte': type: 'number' '$lte': type: 'number'
'$ne': type: ['number', 'string'] '$ne': type: ['number', 'string']
'$nin': type: 'array' '$nin': type: 'array'
additionalProperties: true # TODO set to false when the schema's done '$exists': type: 'boolean'
additionalProperties: false
MongoFindQuerySchema = MongoFindQuerySchema =
title: 'MongoDB Query' title: 'Query'
id: 'mongoFindQuery'
type: 'object' type: 'object'
patternProperties: patternProperties:
#'^[-a-zA-Z0-9_]*$': '^[-a-zA-Z0-9.]*$':
'^[-a-zA-Z0-9\.]*$': anyOf: [
oneOf: [ {$ref: '#/definitions/mongoQueryOperator'},
#{$ref: '#/definitions/' + MongoQueryOperatorSchema.id},
{type: 'string'} {type: 'string'}
{type: 'object'} {type: 'object'}
{type: 'boolean'} {type: 'boolean'}
] ]
additionalProperties: true # TODO make Treema accept new pattern matched keys additionalProperties: false
definitions: {} definitions: {}
MongoFindQuerySchema.definitions[MongoQueryOperatorSchema.id] = MongoQueryOperatorSchema
AchievementSchema = c.object() AchievementSchema = c.object()
c.extendNamedProperties AchievementSchema c.extendNamedProperties AchievementSchema
c.extendBasicProperties AchievementSchema, 'achievement' c.extendBasicProperties AchievementSchema, 'achievement'
@ -48,7 +44,7 @@ AchievementSchema.default =
_.extend AchievementSchema.properties, _.extend AchievementSchema.properties,
query: query:
#type:'object' #type:'object'
$ref: '#/definitions/' + MongoFindQuerySchema.id $ref: '#/definitions/mongoFindQuery'
worth: c.float worth: c.float
collection: {type: 'string'} collection: {type: 'string'}
description: c.shortString() description: c.shortString()
@ -93,6 +89,7 @@ _.extend AchievementSchema, # Let's have these on the bottom
additionalProperties: false additionalProperties: false
AchievementSchema.definitions = {} AchievementSchema.definitions = {}
AchievementSchema.definitions[MongoFindQuerySchema.id] = MongoFindQuerySchema AchievementSchema.definitions['mongoQueryOperator'] = MongoQueryOperatorSchema
AchievementSchema.definitions['mongoFindQuery'] = MongoFindQuerySchema
module.exports = AchievementSchema module.exports = AchievementSchema

View file

@ -148,10 +148,7 @@ _.extend LevelComponentSchema.properties,
type: 'boolean' type: 'boolean'
title: 'Official' title: 'Official'
description: 'Whether this is an official CodeCombat Component.' description: 'Whether this is an official CodeCombat Component.'
searchStrings: { searchStrings: {type: 'string'}
type: 'array'
items: { type: 'string' }
}
c.extendBasicProperties LevelComponentSchema, 'level.component' c.extendBasicProperties LevelComponentSchema, 'level.component'
c.extendSearchableProperties LevelComponentSchema c.extendSearchableProperties LevelComponentSchema

View file

@ -121,7 +121,7 @@
background-position-x: -4 * $iconSize background-position-x: -4 * $iconSize
&.prop-label-icon-attackDamage &.prop-label-icon-attackDamage
background-position-x: -5 * $iconSize background-position-x: -5 * $iconSize
&.prop-label-icon-attackRange &.prop-label-icon-attackRange, &.prop-label-icon-attackNearbyEnemyRange
background-position-x: -6 * $iconSize background-position-x: -6 * $iconSize
&.prop-label-icon-maxSpeed &.prop-label-icon-maxSpeed
background-position-x: -7 * $iconSize background-position-x: -7 * $iconSize

View file

@ -28,22 +28,13 @@ module.exports = class NewAchievementModal extends NewModelModal
createQuery: -> createQuery: ->
checked = @$el.find('[name=queryOptions]:checked') checked = @$el.find('[name=queryOptions]:checked')
checkedValues = ($(check).val() for check in checked) checkedValues = ($(check).val() for check in checked)
subQueries = [] query = {}
for id in checkedValues for id in checkedValues
switch id switch id
when 'misc-level-completion' when 'misc-level-completion'
subQueries.push state: complete: true query['state.complete'] = true
else # It's a goal
q = state: goalStates: {}
q.state.goalStates[id] = {}
q.state.goalStates[id].status = 'success'
subQueries.push q
unless subQueries.length
query = {}
else if subQueries.length is 1
query = subQueries[0]
else else
query = $or: subQueries query["state.goalStates.#{id}.status"] = 'success'
query['level.original'] = @level.get 'original' query['level.original'] = @level.get 'original'
query query

View file

@ -217,7 +217,7 @@ module.exports = class SpectateLevelView extends RootView
initScriptManager: -> initScriptManager: ->
if @world.scripts if @world.scripts
nonVictoryPlaybackScripts = _.reject @world.scripts, (script) -> nonVictoryPlaybackScripts = _.reject @world.scripts, (script) ->
script.id.indexOf('Set Camera Boundaries and Goals') == -1 script.id.indexOf('Set Camera Boundaries') is -1
else else
console.log 'World scripts don\'t exist!' console.log 'World scripts don\'t exist!'
nonVictoryPlaybackScripts = [] nonVictoryPlaybackScripts = []

View file

@ -265,7 +265,7 @@ module.exports = class LevelHUDView extends CocoView
return null # included in the bar return null # included in the bar
context = context =
prop: prop prop: prop
hasIcon: prop in ['health', 'pos', 'target', 'collectedThangIDs', 'gold', 'bountyGold', 'visualRange', 'attackDamage', 'attackRange', 'maxSpeed'] hasIcon: prop in ['health', 'pos', 'target', 'collectedThangIDs', 'gold', 'bountyGold', 'visualRange', 'attackDamage', 'attackRange', 'maxSpeed', 'attackNearbyEnemyRange']
hasBar: prop in ['health'] hasBar: prop in ['health']
$(prop_template(context)) $(prop_template(context))