2016-05-10 18:20:16 -04:00
|
|
|
utils = require 'core/utils'
|
|
|
|
|
2016-04-07 22:06:57 -04:00
|
|
|
RootView = require 'views/core/RootView'
|
|
|
|
template = require 'templates/editor/verifier/verifier-view'
|
|
|
|
VerifierTest = require './VerifierTest'
|
2016-05-03 22:14:40 -04:00
|
|
|
SuperModel = require 'models/SuperModel'
|
2016-04-07 22:06:57 -04:00
|
|
|
|
|
|
|
module.exports = class VerifierView extends RootView
|
|
|
|
className: 'style-flat'
|
|
|
|
template: template
|
|
|
|
id: 'verifier-view'
|
|
|
|
|
|
|
|
constructor: (options, @levelID) ->
|
|
|
|
super options
|
|
|
|
# TODO: sort tests by unexpected result first
|
2016-05-03 14:46:10 -04:00
|
|
|
@passed = 0
|
|
|
|
@failed = 0
|
2016-05-03 22:14:40 -04:00
|
|
|
@problem = 0
|
|
|
|
|
2016-05-03 15:14:51 -04:00
|
|
|
testLevels = [
|
|
|
|
'dungeons-of-kithgard', 'gems-in-the-deep', 'shadow-guard', 'kounter-kithwise', 'crawlways-of-kithgard',
|
|
|
|
'enemy-mine', 'illusory-interruption', 'forgetful-gemsmith', 'signs-and-portents', 'favorable-odds',
|
|
|
|
'true-names', 'the-prisoner', 'banefire', 'the-raised-sword', 'kithgard-librarian', 'fire-dancing',
|
|
|
|
'loop-da-loop', 'haunted-kithmaze', 'riddling-kithmaze', 'descending-further', 'the-second-kithmaze',
|
|
|
|
'dread-door', 'cupboards-of-kithgard', 'hack-and-dash', 'known-enemy', 'master-of-names', 'lowly-kithmen',
|
|
|
|
'closing-the-distance', 'tactical-strike', 'the-skeleton', 'a-mayhem-of-munchkins', 'the-final-kithmaze',
|
2016-05-03 17:36:27 -04:00
|
|
|
'the-gauntlet', 'radiant-aura', 'kithgard-gates', 'destroying-angel', 'deadly-dungeon-rescue',
|
|
|
|
'breakout', 'attack-wisely', 'kithgard-mastery', 'kithgard-apprentice', 'robot-ragnarok',
|
|
|
|
'defense-of-plainswood', 'peasant-protection', 'forest-fire-dancing', 'course-winding-trail',
|
2016-05-03 15:14:51 -04:00
|
|
|
'patrol-buster', 'endangered-burl', 'thumb-biter', 'gems-or-death', 'village-guard', 'thornbush-farm',
|
|
|
|
'back-to-back', 'ogre-encampment', 'woodland-cleaver', 'shield-rush', 'range-finder', 'munchkin-swarm',
|
|
|
|
'stillness-in-motion', 'the-agrippa-defense', 'backwoods-bombardier', 'coinucopia', 'copper-meadows',
|
2016-05-03 22:14:40 -04:00
|
|
|
'drop-the-flag', 'mind-the-trap', 'signal-corpse', 'rich-forager',
|
|
|
|
|
2016-05-05 19:56:58 -04:00
|
|
|
'the-mighty-sand-yak', 'oasis', 'sarven-road', 'sarven-gaps', 'thunderhooves', 'minesweeper',
|
|
|
|
'medical-attention', 'sarven-sentry', 'keeping-time', 'hoarding-gold', 'decoy-drill', 'continuous-alchemy',
|
|
|
|
'dust', 'desert-combat', 'sarven-savior', 'lurkers', 'preferential-treatment', 'sarven-shepherd',
|
|
|
|
'shine-getter',
|
|
|
|
|
|
|
|
'a-fine-mint', 'borrowed-sword', 'cloudrip-commander', 'crag-tag',
|
|
|
|
'hunters-and-prey', 'hunting-party',
|
|
|
|
'leave-it-to-cleaver', 'library-tactician', 'mad-maxer', 'mad-maxer-strikes-back',
|
|
|
|
'mirage-maker', 'mixed-unit-tactics', 'mountain-mercenaries',
|
|
|
|
'noble-sacrifice', 'odd-sandstorm', 'ogre-gorge-gouger', 'reaping-fire',
|
|
|
|
'return-to-thornbush-farm', 'ring-bearer', 'sand-snakes',
|
|
|
|
'slalom', 'steelclaw-gap', 'the-geometry-of-flowers',
|
|
|
|
'the-two-flowers', 'timber-guard', 'toil-and-trouble', 'village-rover',
|
|
|
|
'vital-powers', 'zoo-keeper',
|
2016-05-03 15:14:51 -04:00
|
|
|
]
|
|
|
|
|
2016-05-03 22:14:40 -04:00
|
|
|
defaultCores = 2
|
|
|
|
cores = Math.max(window.navigator.hardwareConcurrency, defaultCores)
|
|
|
|
|
2016-04-07 22:06:57 -04:00
|
|
|
#testLevels = testLevels.slice 0, 15
|
2016-05-03 15:14:51 -04:00
|
|
|
@linksQueryString = window.location.search
|
2016-05-03 14:46:10 -04:00
|
|
|
@levelIDs = if @levelID then [@levelID] else testLevels
|
2016-05-10 18:20:16 -04:00
|
|
|
languages = utils.getQueryVariable 'languages', 'python,javascript'
|
2016-04-07 22:06:57 -04:00
|
|
|
#supermodel = if @levelID then @supermodel else undefined
|
|
|
|
@tests = []
|
2016-05-03 22:14:40 -04:00
|
|
|
@taskList = []
|
|
|
|
@tasksList = _.flatten _.map @levelIDs, (v) ->
|
2016-05-05 19:56:58 -04:00
|
|
|
# TODO: offer good interface for choosing which languages, better performance for skipping missing solutions
|
|
|
|
#_.map ['python', 'javascript', 'coffeescript', 'lua'], (l) ->
|
2016-05-10 18:20:16 -04:00
|
|
|
_.map languages.split(','), (l) ->
|
2016-05-05 19:56:58 -04:00
|
|
|
#_.map ['javascript'], (l) ->
|
2016-05-03 22:14:40 -04:00
|
|
|
level: v, language: l
|
|
|
|
|
|
|
|
@testCount = @tasksList.length
|
|
|
|
chunks = _.groupBy @tasksList, (v,i) -> i%cores
|
|
|
|
supermodels = [@supermodel]
|
|
|
|
|
2016-05-05 19:56:58 -04:00
|
|
|
_.forEach chunks, (chunk, i) =>
|
2016-05-03 22:14:40 -04:00
|
|
|
_.delay =>
|
|
|
|
parentSuperModel = supermodels[supermodels.length-1]
|
|
|
|
chunkSupermodel = new SuperModel()
|
|
|
|
chunkSupermodel.models = _.clone parentSuperModel.models
|
|
|
|
chunkSupermodel.collections = _.clone parentSuperModel.collections
|
|
|
|
supermodels.push chunkSupermodel
|
|
|
|
|
|
|
|
async.eachSeries chunk, (task, next) =>
|
|
|
|
test = new VerifierTest task.level, (e) =>
|
|
|
|
@update(e)
|
2016-05-05 19:56:58 -04:00
|
|
|
if e.state in ['complete', 'error', 'no-solution']
|
2016-05-03 22:14:40 -04:00
|
|
|
if e.state is 'complete'
|
2016-05-05 19:56:58 -04:00
|
|
|
if test.isSuccessful()
|
2016-05-03 22:14:40 -04:00
|
|
|
++@passed
|
|
|
|
else
|
|
|
|
++@failed
|
2016-05-05 19:56:58 -04:00
|
|
|
else if e.state is 'no-solution'
|
|
|
|
--@testCount
|
|
|
|
else
|
2016-05-03 22:14:40 -04:00
|
|
|
++@problem
|
|
|
|
|
|
|
|
next()
|
|
|
|
, chunkSupermodel, task.language
|
|
|
|
@tests.unshift test
|
|
|
|
@render()
|
|
|
|
, => @render()
|
|
|
|
, if i > 0 then 5000 + i * 1000 else 0
|
|
|
|
|
2016-04-07 22:06:57 -04:00
|
|
|
update: (event) =>
|
2016-05-05 19:56:58 -04:00
|
|
|
@render()
|