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

View file

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

View file

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

View file

@ -28,22 +28,13 @@ module.exports = class NewAchievementModal extends NewModelModal
createQuery: ->
checked = @$el.find('[name=queryOptions]:checked')
checkedValues = ($(check).val() for check in checked)
subQueries = []
query = {}
for id in checkedValues
switch id
when 'misc-level-completion'
subQueries.push 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
query = $or: subQueries
query['state.complete'] = true
else
query["state.goalStates.#{id}.status"] = 'success'
query['level.original'] = @level.get 'original'
query

View file

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

View file

@ -265,7 +265,7 @@ module.exports = class LevelHUDView extends CocoView
return null # included in the bar
context =
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']
$(prop_template(context))