2016-04-04 14:03:07 -04:00
|
|
|
RootView = require 'views/core/RootView'
|
2016-04-21 12:17:54 -04:00
|
|
|
template = require 'templates/artisans/solutionProblemsView'
|
2016-04-04 14:03:07 -04:00
|
|
|
Level = require 'models/Level'
|
|
|
|
Campaign = require 'models/Campaign'
|
2016-04-07 17:48:40 -04:00
|
|
|
Level = require 'models/Level'
|
2016-04-04 14:03:07 -04:00
|
|
|
CocoCollection = require 'collections/CocoCollection'
|
|
|
|
|
2016-04-21 12:17:54 -04:00
|
|
|
module.exports = class SolutionProblemsView extends RootView
|
2016-04-04 14:03:07 -04:00
|
|
|
template: template
|
2016-04-21 12:17:54 -04:00
|
|
|
id: 'solution-problems-view'
|
2016-04-07 17:48:40 -04:00
|
|
|
excludedCampaigns = [
|
|
|
|
"picoctf"
|
|
|
|
"auditions"
|
2016-04-20 14:15:26 -04:00
|
|
|
|
2016-04-29 18:58:30 -04:00
|
|
|
#"dungeon"
|
|
|
|
#"forest"
|
|
|
|
#"desert"
|
|
|
|
#"mountain"
|
|
|
|
#"glacier"
|
2016-04-20 14:15:26 -04:00
|
|
|
|
|
|
|
"dungeon-branching-test"
|
|
|
|
"forest-branching-test"
|
|
|
|
"desert-branching-test"
|
|
|
|
|
2016-04-29 18:58:30 -04:00
|
|
|
#"intro"
|
|
|
|
#"course-2"
|
|
|
|
#"course-3"
|
|
|
|
#"course-4"
|
|
|
|
#"course-5"
|
|
|
|
#"course-6"
|
2016-04-20 14:15:26 -04:00
|
|
|
]
|
|
|
|
excludedSimulationLevels = [
|
2016-04-29 18:58:30 -04:00
|
|
|
# Course Arenas
|
2016-04-20 14:15:26 -04:00
|
|
|
"wakka-maul"
|
|
|
|
"cross-bones"
|
2016-04-07 17:48:40 -04:00
|
|
|
]
|
2016-04-29 18:58:30 -04:00
|
|
|
excludedSolutionLevels = [
|
|
|
|
# Multiplayer Levels
|
|
|
|
"cavern-survival"
|
|
|
|
|
|
|
|
"dueling-grounds"
|
|
|
|
"multiplayer-treasure-grove"
|
|
|
|
|
|
|
|
"harrowland"
|
|
|
|
|
|
|
|
"zero-sum"
|
|
|
|
|
|
|
|
"ace-of-coders"
|
|
|
|
"capture-their-flag"
|
|
|
|
]
|
2016-04-20 14:15:26 -04:00
|
|
|
levelOffset: 0
|
|
|
|
isReady: 0
|
2016-04-29 18:58:30 -04:00
|
|
|
requiresSubs: 0
|
|
|
|
rob: []
|
2016-04-04 14:03:07 -04:00
|
|
|
constructor: (options) ->
|
|
|
|
super options
|
|
|
|
@campaigns = new CocoCollection([],
|
2016-04-21 12:17:54 -04:00
|
|
|
url: '/db/campaign?project=slug'
|
2016-04-04 14:03:07 -04:00
|
|
|
model: Campaign
|
|
|
|
)
|
|
|
|
@campaigns.fetch()
|
|
|
|
@listenTo(@campaigns, 'sync', @onCampaignsLoaded)
|
|
|
|
@supermodel.loadCollection(@campaigns, 'campaigns')
|
2016-04-21 12:17:54 -04:00
|
|
|
###
|
2016-04-20 14:15:26 -04:00
|
|
|
@levels = new CocoCollection([],
|
|
|
|
url: '/db/level?project=slug,thangs&limit=100&skip=' + @levelOffset
|
|
|
|
model: Level
|
|
|
|
)
|
2016-04-07 17:48:40 -04:00
|
|
|
@levels.fetch()
|
|
|
|
@listenTo(@levels, 'sync', @onLevelsLoaded)
|
|
|
|
@supermodel.loadCollection(@levels, 'levels')
|
2016-04-21 12:17:54 -04:00
|
|
|
###
|
2016-04-07 17:48:40 -04:00
|
|
|
|
2016-04-04 14:03:07 -04:00
|
|
|
onCampaignsLoaded: ->
|
2016-04-07 17:48:40 -04:00
|
|
|
@levelSlugs = []
|
2016-04-21 12:17:54 -04:00
|
|
|
@test = {}
|
|
|
|
@loadedLevels = {}
|
|
|
|
count = 0
|
2016-04-07 17:48:40 -04:00
|
|
|
for campaign in @campaigns.models
|
|
|
|
continue unless excludedCampaigns.indexOf(campaign.get 'slug') is -1
|
2016-04-21 12:17:54 -04:00
|
|
|
count++
|
|
|
|
@test[campaign.get('slug')] = new CocoCollection([],
|
2016-04-29 18:58:30 -04:00
|
|
|
url: '/db/campaign/' + campaign.get('slug') + '/levels?project=thangs,slug,requiresSubscription'
|
2016-04-20 14:15:26 -04:00
|
|
|
model: Level
|
|
|
|
)
|
2016-04-21 12:17:54 -04:00
|
|
|
@test[campaign.get('slug')].fetch()
|
|
|
|
@listenTo(@test[campaign.get('slug')], 'sync', (e) ->
|
|
|
|
#@loadedLevels = _uniq(_.union(@loadedLevels, e.models))
|
|
|
|
for level in e.models
|
2016-04-29 18:58:30 -04:00
|
|
|
if not @loadedLevels[level.get('slug')]? and level.get('requiresSubscription')
|
|
|
|
@requiresSubs++
|
2016-04-21 12:17:54 -04:00
|
|
|
@loadedLevels[level.get('slug')] = level
|
|
|
|
count--
|
|
|
|
if count is 0
|
|
|
|
@readyUp()
|
|
|
|
)
|
|
|
|
@supermodel.loadCollection(@test[campaign.get('slug')], 'levels')
|
2016-04-08 18:50:04 -04:00
|
|
|
|
2016-04-07 17:48:40 -04:00
|
|
|
readyUp: ->
|
2016-04-21 12:17:54 -04:00
|
|
|
console.log("Count of levels: " + _.size(@loadedLevels))
|
2016-04-29 18:58:30 -04:00
|
|
|
console.log("Count requires sub: " + @requiresSubs)
|
2016-04-08 18:50:04 -04:00
|
|
|
@parsedLevels = []
|
2016-04-21 12:17:54 -04:00
|
|
|
|
|
|
|
@problemCount = 0
|
|
|
|
for levelSlug, level of @loadedLevels
|
2016-04-07 17:48:40 -04:00
|
|
|
unless level?
|
|
|
|
continue
|
|
|
|
thangs = level.get('thangs')
|
2016-04-08 18:50:04 -04:00
|
|
|
component = null
|
|
|
|
thang = _.findWhere(thangs, (elem) ->
|
2016-04-20 14:15:26 -04:00
|
|
|
return elem.id is "Hero Placeholder" and _.findWhere(elem.components, (elem2) ->
|
2016-04-08 18:50:04 -04:00
|
|
|
if elem2.config?.programmableMethods?.plan?
|
|
|
|
component = elem2
|
|
|
|
return true
|
|
|
|
)
|
|
|
|
)
|
2016-04-29 18:58:30 -04:00
|
|
|
thangs = _.filter(thangs, (elem) ->
|
|
|
|
return _.findWhere(elem.components, (elem2) ->
|
|
|
|
if elem2.config?.programmableMethods?
|
|
|
|
return true
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if thangs.length > 1
|
|
|
|
console.log levelSlug + ":" + thangs.length + " " + thangs.map((elem) -> return elem.id)
|
2016-04-20 14:15:26 -04:00
|
|
|
unless thang? and component
|
2016-04-08 18:50:04 -04:00
|
|
|
console.log("Cannot find programmableMethods component in: " + levelSlug)
|
|
|
|
continue
|
|
|
|
unless component?.config?.programmableMethods?.plan?
|
|
|
|
console.log("Cannot find plannable method inside component: " + levelSlug)
|
|
|
|
continue
|
2016-04-20 14:15:26 -04:00
|
|
|
plan = component.config.programmableMethods.plan
|
|
|
|
solutions = plan.solutions
|
|
|
|
|
2016-04-08 18:50:04 -04:00
|
|
|
|
|
|
|
problems = []
|
2016-04-29 18:58:30 -04:00
|
|
|
if excludedSolutionLevels.indexOf(levelSlug) is -1
|
|
|
|
for lang in ["python", "javascript", "lua", "java"]
|
|
|
|
if _.findWhere(solutions, (elem) -> return elem.language is lang)
|
|
|
|
@rob.push language: lang, level: levelSlug
|
|
|
|
else if lang not in ["lua", "java"]
|
|
|
|
problems.push {
|
|
|
|
"type":"Missing Solution Language",
|
|
|
|
"value":lang
|
|
|
|
}
|
|
|
|
@problemCount++
|
|
|
|
else
|
|
|
|
# monitor lua/java when we care about it here
|
2016-04-20 14:15:26 -04:00
|
|
|
|
2016-04-08 18:50:04 -04:00
|
|
|
for solutionIndex of solutions
|
|
|
|
solution = solutions[solutionIndex]
|
2016-04-20 14:15:26 -04:00
|
|
|
if excludedSimulationLevels.indexOf(levelSlug) is -1
|
2016-04-29 18:58:30 -04:00
|
|
|
for req in ["seed", "succeeds", "heroConfig", 'frameCount', 'goals'] # Implement a fix for lastHash
|
2016-04-20 14:15:26 -04:00
|
|
|
unless solution[req]?
|
2016-04-29 18:58:30 -04:00
|
|
|
console.log levelSlug, req
|
2016-04-20 14:15:26 -04:00
|
|
|
problems.push {
|
|
|
|
"type":"Solution is not simulatable",
|
|
|
|
"value":solution.language
|
|
|
|
}
|
2016-04-21 12:17:54 -04:00
|
|
|
@problemCount++
|
2016-04-20 14:15:26 -04:00
|
|
|
break
|
2016-04-29 18:58:30 -04:00
|
|
|
if solution.source.indexOf("pass") isnt -1
|
2016-04-20 14:15:26 -04:00
|
|
|
problems.push {
|
2016-04-29 18:58:30 -04:00
|
|
|
"type":"Solution contains pass",
|
2016-04-20 14:15:26 -04:00
|
|
|
"value":solution.language
|
|
|
|
}
|
2016-04-21 12:17:54 -04:00
|
|
|
@problemCount++
|
2016-04-29 18:58:30 -04:00
|
|
|
if solution.source.indexOf("<%=") is -1
|
2016-04-20 14:15:26 -04:00
|
|
|
problems.push {
|
2016-04-29 18:58:30 -04:00
|
|
|
"type":"Solution is not i18n'd",
|
2016-04-20 14:15:26 -04:00
|
|
|
"value":solution.language
|
|
|
|
}
|
2016-04-21 12:17:54 -04:00
|
|
|
@problemCount++
|
2016-04-20 14:15:26 -04:00
|
|
|
if solution.language is 'javascript'
|
|
|
|
if solution.source is plan.source
|
2016-04-08 18:50:04 -04:00
|
|
|
problems.push {
|
2016-04-20 14:15:26 -04:00
|
|
|
"type":"Solution is identical to source",
|
|
|
|
"value":solution.language
|
|
|
|
}
|
2016-04-21 12:17:54 -04:00
|
|
|
@problemCount++
|
2016-04-20 14:15:26 -04:00
|
|
|
else
|
2016-04-21 12:17:54 -04:00
|
|
|
#console.log solution.source
|
|
|
|
#console.log plan.languages[solution.language]
|
2016-04-20 14:15:26 -04:00
|
|
|
if solution.source is plan.languages[solution.language]
|
|
|
|
problems.push {
|
|
|
|
"type":"Solution is identical to source",
|
2016-04-08 18:50:04 -04:00
|
|
|
"value":solution.language
|
|
|
|
}
|
2016-04-21 12:17:54 -04:00
|
|
|
@problemCount++
|
2016-04-08 18:50:04 -04:00
|
|
|
@parsedLevels.push {
|
|
|
|
level: level
|
|
|
|
problems: problems
|
|
|
|
}
|
2016-04-20 14:15:26 -04:00
|
|
|
@renderSelectors '#levelTable'
|