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

View file

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

View file

@ -151,7 +151,7 @@ class CocoModel extends Backbone.Model
return null unless schema.links?
linkObject = _.find schema.links, rel: "db"
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
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
# Ugh, we need to make sure we grab the IndieSprite ThangTypes
for indieSprite in data.indieSprites
link = "/db/thang_type/#{indieSprite.thangType}/version"
link = "/db/thang.type/#{indieSprite.thangType}/version"
model = CocoModel.getOrMakeModelFromLink link, shouldLoadProjection
models.push model if model
else if path is '/'

View file

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

View file

@ -52,8 +52,9 @@ div#columns.row
if team.isRanking
td(colspan=4).alert.alert-info
| Your new code is being simulated by other players for ranking.
| This will refresh as new matches come in.
else
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.

View file

@ -22,7 +22,7 @@ module.exports = class WizardSettingsView extends CocoView
loadWizard: ->
@wizardThangType = new ThangType()
@wizardThangType.url = -> '/db/thang_type/wizard'
@wizardThangType.url = -> '/db/thang.type/wizard'
@wizardThangType.fetch()
@wizardThangType.once 'sync', @initCanvas, @
@ -67,7 +67,7 @@ module.exports = class WizardSettingsView extends CocoView
updateSwatchVisibility: (colorGroup) ->
enabled = colorGroup.find('.color-group-checkbox').prop('checked')
colorGroup.find('.minicolors-swatch').toggle Boolean(enabled)
updateColorSettings: (colorGroup) =>
wizardSettings = _.cloneDeep(me.get('wizard')) or {}
wizardSettings.colorConfig ?= {}
@ -108,4 +108,4 @@ module.exports = class WizardSettingsView extends CocoView
@movieClip.regX = reg.x
@movieClip.regY = reg.y
@stage.addChild @movieClip
@stage.update()
@stage.update()

View file

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

View file

@ -71,7 +71,7 @@ module.exports = class MyMatchesTabView extends CocoView
for team in @teams
team.session = (s for s in @sessions.models when s.get('team') is team.id)[0]
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.reverse()
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
return unless flow
executed = []
executedRows = {}
matched = false
states = flow.states ? []
currentCallIndex = null
@ -445,20 +446,24 @@ module.exports = class SpellView extends View
matched = true
break
_.last(executed).push state
executedRows[state.range[0].row] = true
#state.executing = true if state.userInfo?.time is @thang.world.age # no work
currentCallIndex ?= callNumber - 1
#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
for markerRange in (@markerRanges ?= [])
markerRange.start.detach()
markerRange.end.detach()
@aceSession.removeMarker markerRange.id
@markerRanges = []
@aceSession.removeGutterDecoration row, 'executing' for row in [0 ... @aceSession.getLength()]
@aceSession.removeGutterDecoration row, 'executed' for row in [0 ... @aceSession.getLength()]
$(@ace.container).find('.ace_gutter-cell.executing').removeClass('executing')
$(@ace.container).find('.ace_gutter-cell.executed').removeClass('executed')
for row in [0 ... @aceSession.getLength()]
unless executedRows[row]
@aceSession.removeGutterDecoration row, 'executing'
@aceSession.removeGutterDecoration row, 'executed'
@decoratedGutter[row] = ''
if not executed.length or (@spell.name is "plan" and @spellThang.castAether.metrics.statementsExecuted < 20)
@toolbarView?.toggleFlow false
@debugView.setVariableStates {}
@ -486,7 +491,10 @@ module.exports = class SpellView extends View
markerRange.end = @aceDoc.createAnchor markerRange.end
markerRange.id = @aceSession.addMarker markerRange, clazz, markerType
@markerRanges.push markerRange
@aceSession.addGutterDecoration start.row, clazz
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
@decoratedGutter[start.row] = clazz
@debugView.setVariableStates {} unless gotVariableStates
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"]},
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
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"]},
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
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"]},
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
@ -164,7 +174,7 @@ LevelThangSchema = c.object {
},
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
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
LevelSystemSchema = c.object {

View file

@ -61,4 +61,4 @@ LevelThangTypeSchema.plugin(plugins.PermissionsPlugin)
LevelThangTypeSchema.plugin(plugins.NamedPlugin)
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)