Merge pull request #1 from codecombat/master

test request
This commit is contained in:
Darredevil 2014-03-12 03:53:44 +02:00
commit cd4fa9b8c2
12 changed files with 86 additions and 19 deletions

View file

@ -105,7 +105,6 @@ module.exports = class GoalManager extends CocoClass
notifyGoalChanges: -> notifyGoalChanges: ->
overallStatus = @checkOverallStatus() overallStatus = @checkOverallStatus()
event = {goalStates: @goalStates, goals: @goals, overallStatus: overallStatus} event = {goalStates: @goalStates, goals: @goals, overallStatus: overallStatus}
#console.log JSON.stringify(event), "new goal states"
Backbone.Mediator.publish('goal-manager:new-goal-states', event) Backbone.Mediator.publish('goal-manager:new-goal-states', event)
checkOverallStatus: (ignoreIncomplete=false) -> checkOverallStatus: (ignoreIncomplete=false) ->
@ -126,6 +125,10 @@ module.exports = class GoalManager extends CocoClass
keyFrame: 0 # when it became a 'success' or 'failure' keyFrame: 0 # when it became a 'success' or 'failure'
} }
@initGoalState(state, [goal.killThangs, goal.saveThangs], 'killed') @initGoalState(state, [goal.killThangs, goal.saveThangs], 'killed')
for getTo in goal.getAllToLocations ? []
@initGoalState(state,[ getTo.getToLocation?.who , [] ], 'arrived')
for keepFrom in goal.keepAllFromLocations ? []
@initGoalState(state,[ [] , keepFrom.keepFromLocation?.who], 'arrived')
@initGoalState(state, [goal.getToLocations?.who, goal.keepFromLocations?.who], 'arrived') @initGoalState(state, [goal.getToLocations?.who, goal.keepFromLocations?.who], 'arrived')
@initGoalState(state, [goal.leaveOffSides?.who, goal.keepFromLeavingOffSides?.who], 'left') @initGoalState(state, [goal.leaveOffSides?.who, goal.keepFromLeavingOffSides?.who], 'left')
@initGoalState(state, [goal.collectThangs?.who, goal.keepFromCollectingThangs?.who], 'collected') @initGoalState(state, [goal.collectThangs?.who, goal.keepFromCollectingThangs?.who], 'collected')
@ -143,7 +146,13 @@ module.exports = class GoalManager extends CocoClass
onThangTouchedGoal: (e, frameNumber) -> onThangTouchedGoal: (e, frameNumber) ->
for goal in @goals ? [] for goal in @goals ? []
@checkArrived(goal.id, goal.getToLocations.who, goal.getToLocations.targets, e.actor, e.touched.id, frameNumber) if goal.getToLocations? @checkArrived(goal.id, goal.getToLocations.who, goal.getToLocations.targets, e.actor, e.touched.id, frameNumber) if goal.getToLocations?
if goal.getAllToLocations?
for getTo in goal.getAllToLocations
@checkArrived(goal.id, getTo.getToLocation.who, getTo.getToLocation.targets, e.actor, e.touched.id, frameNumber)
@checkArrived(goal.id, goal.keepFromLocations.who, goal.keepFromLocations.targets, e.actor, e.touched.id, frameNumber) if goal.keepFromLocations? @checkArrived(goal.id, goal.keepFromLocations.who, goal.keepFromLocations.targets, e.actor, e.touched.id, frameNumber) if goal.keepFromLocations?
if goal.keepAllFromLocations?
for keepFrom in goal.keepAllFromLocations
@checkArrived(goal.id, keepFrom.keepFromLocation.who , keepFrom.keepFromLocation.targets, e.actor, e.touched.id, frameNumber )
checkArrived: (goalID, who, targets, thang, touchedID, frameNumber) -> checkArrived: (goalID, who, targets, thang, touchedID, frameNumber) ->
return unless touchedID in targets return unless touchedID in targets
@ -191,6 +200,7 @@ module.exports = class GoalManager extends CocoClass
initGoalState: (state, whos, progressObjectName) -> initGoalState: (state, whos, progressObjectName) ->
# 'whos' is an array of goal 'who' values. # 'whos' is an array of goal 'who' values.
# This inits the progress object for the goal tracking. # This inits the progress object for the goal tracking.
arrays = (prop for prop in whos when prop?.length) arrays = (prop for prop in whos when prop?.length)
return unless arrays.length return unless arrays.length
state[progressObjectName] = {} state[progressObjectName] = {}
@ -240,7 +250,9 @@ module.exports = class GoalManager extends CocoClass
killThangs: 1 killThangs: 1
saveThangs: 0 saveThangs: 0
getToLocations: 1 getToLocations: 1
getAllToLocations: 1
keepFromLocations: 0 keepFromLocations: 0
keepAllFromLocations: 0
leaveOffSides: 1 leaveOffSides: 1
keepFromLeavingOffSides: 0 keepFromLeavingOffSides: 0
collectThangs: 1 collectThangs: 1

View file

@ -63,6 +63,7 @@ module.exports.thangNames = thangNames =
"Annie" "Annie"
"Lukaz" "Lukaz"
"Gorgin" "Gorgin"
"Coco"
] ]
"Peasant": [ "Peasant": [
"Yorik" "Yorik"
@ -90,6 +91,7 @@ module.exports.thangNames = thangNames =
] ]
"Peasant F": [ "Peasant F": [
"Hilda" "Hilda"
"Icey"
] ]
"Archer F": [ "Archer F": [
"Phoebe" "Phoebe"
@ -115,6 +117,12 @@ module.exports.thangNames = thangNames =
"Alden" "Alden"
"Cairn" "Cairn"
"Jensen" "Jensen"
"Yilitha"
"Mirana"
"Lina"
"Luna"
"Alleria"
"Vereesa"
] ]
"Archer M": [ "Archer M": [
"Brian" "Brian"
@ -127,6 +135,14 @@ module.exports.thangNames = thangNames =
"Arty" "Arty"
"Gimsley" "Gimsley"
"Fidsdale" "Fidsdale"
"Slyvos"
"Logos"
"Denin"
"Lycan"
"Loco"
"Vican"
"Mars"
"Dev"
] ]
"Ogre Munchkin M": [ "Ogre Munchkin M": [
"Brack" "Brack"
@ -148,6 +164,7 @@ module.exports.thangNames = thangNames =
"Thabt" "Thabt"
"Snortt" "Snortt"
"Kog" "Kog"
"Ursa"
] ]
"Ogre Munchkin F": [ "Ogre Munchkin F": [
"Iyert" "Iyert"
@ -155,6 +172,9 @@ module.exports.thangNames = thangNames =
"Shmeal" "Shmeal"
"Gurzunn" "Gurzunn"
"Yugark" "Yugark"
"Dosha"
"Inski"
"Lacos"
] ]
"Ogre M": [ "Ogre M": [
"Krogg" "Krogg"
@ -168,6 +188,9 @@ module.exports.thangNames = thangNames =
"Vargutt" "Vargutt"
"Grumus" "Grumus"
"Gug" "Gug"
"Tarlok"
"Gurulax"
"Mokrul"
] ]
"Ogre F": [ "Ogre F": [
"Nareng" "Nareng"
@ -175,6 +198,11 @@ module.exports.thangNames = thangNames =
"Glonc" "Glonc"
"Marghurk" "Marghurk"
"Martha" "Martha"
"Holkam"
"Alkaz"
"Gar'ah"
"Mak'rah"
"Marnag"
] ]
"Ogre Brawler": [ "Ogre Brawler": [
"Grul'thock" "Grul'thock"
@ -190,6 +218,8 @@ module.exports.thangNames = thangNames =
"Grognar" "Grognar"
"Ironjaw" "Ironjaw"
"Tuguro" "Tuguro"
"York"
"Ork'han"
] ]
"Ogre Fangrider": [ "Ogre Fangrider": [
"Dreek" "Dreek"
@ -205,6 +235,7 @@ module.exports.thangNames = thangNames =
"Gurzthrot" "Gurzthrot"
"Murgark" "Murgark"
"Muttin" "Muttin"
"Bortrok"
] ]
"Ogre Shaman": [ "Ogre Shaman": [
"Sham'uk" "Sham'uk"
@ -224,6 +255,11 @@ module.exports.thangNames = thangNames =
"Zo'Goroth" "Zo'Goroth"
"Mogadishu" "Mogadishu"
"Nazgareth" "Nazgareth"
"Gror"
"Grek"
"Gom"
"Gogg"
"Ghuk"
] ]
"Ogre Thrower": [ "Ogre Thrower": [
"Kyrgg" "Kyrgg"

View file

@ -151,7 +151,7 @@ class CocoModel extends Backbone.Model
return null unless schema.links? return null unless schema.links?
linkObject = _.find schema.links, rel: "db" linkObject = _.find schema.links, rel: "db"
return null unless linkObject return null unless linkObject
return null if linkObject.href.match("thang_type") and not @isObjectID(data) # Skip loading hardcoded Thang Types for now (TODO) return null if linkObject.href.match("thang.type") and not @isObjectID(data) # Skip loading hardcoded Thang Types for now (TODO)
# not fully extensible, but we can worry about that later # not fully extensible, but we can worry about that later
link = linkObject.href link = linkObject.href

View file

@ -112,7 +112,7 @@ module.exports = class Level extends CocoModel
if path.match(/\/systems\/\d+\/config\//) and data?.indieSprites?.length if path.match(/\/systems\/\d+\/config\//) and data?.indieSprites?.length
# Ugh, we need to make sure we grab the IndieSprite ThangTypes # Ugh, we need to make sure we grab the IndieSprite ThangTypes
for indieSprite in data.indieSprites for indieSprite in data.indieSprites
link = "/db/thang_type/#{indieSprite.thangType}/version" link = "/db/thang.type/#{indieSprite.thangType}/version"
model = CocoModel.getOrMakeModelFromLink link, shouldLoadProjection model = CocoModel.getOrMakeModelFromLink link, shouldLoadProjection
models.push model if model models.push model if model
else if path is '/' else if path is '/'

View file

@ -218,7 +218,7 @@ module.exports = class ThangType extends CocoModel
@loadUniversalWizard: -> @loadUniversalWizard: ->
return @wizardType if @wizardType return @wizardType if @wizardType
wizOriginal = "52a00d55cf1818f2be00000b" wizOriginal = "52a00d55cf1818f2be00000b"
url = "/db/thang_type/#{wizOriginal}/version" url = "/db/thang.type/#{wizOriginal}/version"
@wizardType = new module.exports() @wizardType = new module.exports()
@wizardType.url = -> url @wizardType.url = -> url
@wizardType.fetch() @wizardType.fetch()

View file

@ -52,8 +52,9 @@ div#columns.row
if team.isRanking if team.isRanking
td(colspan=4).alert.alert-info td(colspan=4).alert.alert-info
| Your new code is being simulated by other players for ranking. | Your new code is being simulated by other players for ranking.
| This will refresh as new matches come in.
else else
td(colspan=4).alert.alert-warning td(colspan=4).alert.alert-warning
| No ranked matches for this team! | No ranked matches for the #{team.name} team!
| Play against some competitors and then come back here to get your game ranked. | Play against some competitors and then come back here to get your game ranked.

View file

@ -22,7 +22,7 @@ module.exports = class WizardSettingsView extends CocoView
loadWizard: -> loadWizard: ->
@wizardThangType = new ThangType() @wizardThangType = new ThangType()
@wizardThangType.url = -> '/db/thang_type/wizard' @wizardThangType.url = -> '/db/thang.type/wizard'
@wizardThangType.fetch() @wizardThangType.fetch()
@wizardThangType.once 'sync', @initCanvas, @ @wizardThangType.once 'sync', @initCanvas, @

View file

@ -19,7 +19,7 @@ componentOriginals =
"physics.Physical" : "524b75ad7fc0f6d519000001" "physics.Physical" : "524b75ad7fc0f6d519000001"
class ThangTypeSearchCollection extends CocoCollection class ThangTypeSearchCollection extends CocoCollection
url: '/db/thang_type/search?project=true' url: '/db/thang.type/search?project=true'
model: ThangType model: ThangType
module.exports = class ThangsTabView extends View module.exports = class ThangsTabView extends View

View file

@ -71,7 +71,7 @@ module.exports = class MyMatchesTabView extends CocoView
for team in @teams for team in @teams
team.session = (s for s in @sessions.models when s.get('team') is team.id)[0] team.session = (s for s in @sessions.models when s.get('team') is team.id)[0]
team.readyToRank = @readyToRank(team.session) team.readyToRank = @readyToRank(team.session)
team.isRanking = team.session.get('isRanking') team.isRanking = team.session?.get('isRanking')
team.matches = (convertMatch(match, team.session.get('submitDate')) for match in team.session?.get('matches') or []) team.matches = (convertMatch(match, team.session.get('submitDate')) for match in team.session?.get('matches') or [])
team.matches.reverse() team.matches.reverse()
team.score = (team.session?.get('totalScore') or 10).toFixed(2) team.score = (team.session?.get('totalScore') or 10).toFixed(2)

View file

@ -430,6 +430,7 @@ module.exports = class SpellView extends View
flow ?= @spellThang?.castAether?.flow flow ?= @spellThang?.castAether?.flow
return unless flow return unless flow
executed = [] executed = []
executedRows = {}
matched = false matched = false
states = flow.states ? [] states = flow.states ? []
currentCallIndex = null currentCallIndex = null
@ -445,20 +446,24 @@ module.exports = class SpellView extends View
matched = true matched = true
break break
_.last(executed).push state _.last(executed).push state
executedRows[state.range[0].row] = true
#state.executing = true if state.userInfo?.time is @thang.world.age # no work #state.executing = true if state.userInfo?.time is @thang.world.age # no work
currentCallIndex ?= callNumber - 1 currentCallIndex ?= callNumber - 1
#console.log "got call index", currentCallIndex, "for time", @thang.world.age, "out of", states.length #console.log "got call index", currentCallIndex, "for time", @thang.world.age, "out of", states.length
@decoratedGutter = @decoratedGutter || {}
# TODO: don't redo the markers if they haven't actually changed # TODO: don't redo the markers if they haven't actually changed
for markerRange in (@markerRanges ?= []) for markerRange in (@markerRanges ?= [])
markerRange.start.detach() markerRange.start.detach()
markerRange.end.detach() markerRange.end.detach()
@aceSession.removeMarker markerRange.id @aceSession.removeMarker markerRange.id
@markerRanges = [] @markerRanges = []
@aceSession.removeGutterDecoration row, 'executing' for row in [0 ... @aceSession.getLength()] for row in [0 ... @aceSession.getLength()]
@aceSession.removeGutterDecoration row, 'executed' for row in [0 ... @aceSession.getLength()] unless executedRows[row]
$(@ace.container).find('.ace_gutter-cell.executing').removeClass('executing') @aceSession.removeGutterDecoration row, 'executing'
$(@ace.container).find('.ace_gutter-cell.executed').removeClass('executed') @aceSession.removeGutterDecoration row, 'executed'
@decoratedGutter[row] = ''
if not executed.length or (@spell.name is "plan" and @spellThang.castAether.metrics.statementsExecuted < 20) if not executed.length or (@spell.name is "plan" and @spellThang.castAether.metrics.statementsExecuted < 20)
@toolbarView?.toggleFlow false @toolbarView?.toggleFlow false
@debugView.setVariableStates {} @debugView.setVariableStates {}
@ -486,7 +491,10 @@ module.exports = class SpellView extends View
markerRange.end = @aceDoc.createAnchor markerRange.end markerRange.end = @aceDoc.createAnchor markerRange.end
markerRange.id = @aceSession.addMarker markerRange, clazz, markerType markerRange.id = @aceSession.addMarker markerRange, clazz, markerType
@markerRanges.push markerRange @markerRanges.push markerRange
if executedRows[start.row] and @decoratedGutter[start.row] isnt clazz
@aceSession.removeGutterDecoration start.row, @decoratedGutter[start.row] if @decoratedGutter[start.row] isnt ''
@aceSession.addGutterDecoration start.row, clazz @aceSession.addGutterDecoration start.row, clazz
@decoratedGutter[start.row] = clazz
@debugView.setVariableStates {} unless gotVariableStates @debugView.setVariableStates {} unless gotVariableStates
null null

View file

@ -36,9 +36,19 @@ GoalSchema = c.object {title: "Goal", description: "A goal that the player can a
getToLocations: c.object {title: "Get To Locations", description: "Will be set off when any of the \"who\" touch any of the \"targets\" ", required: ["who", "targets"]}, getToLocations: c.object {title: "Get To Locations", description: "Will be set off when any of the \"who\" touch any of the \"targets\" ", required: ["who", "targets"]},
who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
getAllToLocations: c.array {title: "Get all to locations", description: "Similar to getToLocations but now a specific \"who\" can have a specific \"target\", also must be used with the HowMany property for desired effect",required: ["getToLocation"]},
c.object {title: "", description: ""},
getToLocation: c.object {title: "Get To Locations", description: "TODO: explain", required: ["who", "targets"]},
who: c.array {title: "Who", description: "The Thangs who must get to the target locations.", minItems: 1}, thang
targets: c.array {title: "Targets", description: "The target locations to which the Thangs must get.", minItems: 1}, thang
keepFromLocations: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]}, keepFromLocations: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang
targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang
keepAllFromLocations: c.array {title: "Keep ALL From Locations", description: "Similar to keepFromLocations but now a specific \"who\" can have a specific \"target\", also must be used with the HowMany property for desired effect", required: ["keepFromLocation"]},
c.object {title: "", description: ""},
keepFromLocation: c.object {title: "Keep From Locations", description: "TODO: explain", required: ["who", "targets"]},
who: c.array {title: "Who", description: "The Thangs who must not get to the target locations.", minItems: 1}, thang
targets: c.array {title: "Targets", description: "The target locations to which the Thangs must not get.", minItems: 1}, thang
leaveOffSides: c.object {title: "Leave Off Sides", description: "Sides of the level to get some Thangs to leave across.", required: ["who", "sides"]}, leaveOffSides: c.object {title: "Leave Off Sides", description: "Sides of the level to get some Thangs to leave across.", required: ["who", "sides"]},
who: c.array {title: "Who", description: "The Thangs which must leave off the sides of the level.", minItems: 1}, thang who: c.array {title: "Who", description: "The Thangs which must leave off the sides of the level.", minItems: 1}, thang
sides: c.array {title: "Sides", description: "The sides off which the Thangs must leave.", minItems: 1}, side sides: c.array {title: "Sides", description: "The sides off which the Thangs must leave.", minItems: 1}, side
@ -164,7 +174,7 @@ LevelThangSchema = c.object {
}, },
id: thang # TODO: figure out if we can make this unique and how to set dynamic defaults id: thang # TODO: figure out if we can make this unique and how to set dynamic defaults
# TODO: split thangType into "original" and "majorVersion" like the rest for consistency # TODO: split thangType into "original" and "majorVersion" like the rest for consistency
thangType: c.objectId(links: [{rel: "db", href: "/db/thang_type/{($)}/version"}], title: "Thang Type", description: "A reference to the original Thang template being configured.", format: 'thang-type') thangType: c.objectId(links: [{rel: "db", href: "/db/thang.type/{($)}/version"}], title: "Thang Type", description: "A reference to the original Thang template being configured.", format: 'thang-type')
components: c.array {title: "Components", description: "Thangs are configured by changing the Components attached to them.", uniqueItems: true, format: 'thang-components-array'}, ThangComponentSchema # TODO: uniqueness should be based on "original", not whole thing components: c.array {title: "Components", description: "Thangs are configured by changing the Components attached to them.", uniqueItems: true, format: 'thang-components-array'}, ThangComponentSchema # TODO: uniqueness should be based on "original", not whole thing
LevelSystemSchema = c.object { LevelSystemSchema = c.object {

View file

@ -61,4 +61,4 @@ LevelThangTypeSchema.plugin(plugins.PermissionsPlugin)
LevelThangTypeSchema.plugin(plugins.NamedPlugin) LevelThangTypeSchema.plugin(plugins.NamedPlugin)
LevelThangTypeSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']}) LevelThangTypeSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
module.exports = LevelThangType = mongoose.model('level.thang_type', LevelThangTypeSchema) module.exports = LevelThangType = mongoose.model('level.thang.type', LevelThangTypeSchema)