diff --git a/app/lib/simulator/Simulator.coffee b/app/lib/simulator/Simulator.coffee index fbc235d02..314ead42b 100644 --- a/app/lib/simulator/Simulator.coffee +++ b/app/lib/simulator/Simulator.coffee @@ -56,8 +56,8 @@ module.exports = class Simulator extends CocoClass simulateSingleGame: -> return if @destroyed - @trigger 'statusUpdate', 'Simulating...' @assignWorldAndLevelFromLevelLoaderAndDestroyIt() + @trigger 'statusUpdate', 'Simulating...' @setupGod() try @commenceSingleSimulation() @@ -174,8 +174,8 @@ module.exports = class Simulator extends CocoClass return if @destroyed info = 'All resources loaded, simulating!' console.log info - @trigger 'statusUpdate', info, @task.getSessions() @assignWorldAndLevelFromLevelLoaderAndDestroyIt() + @trigger 'statusUpdate', info, @task.getSessions() @setupGod() try @@ -227,6 +227,7 @@ module.exports = class Simulator extends CocoClass @hd = new @memwatch.HeapDiff() onInfiniteLoop: -> + return if @destroyed console.warn 'Skipping infinitely looping game.' @trigger 'statusUpdate', "Infinite loop detected; grabbing a new game in #{@retryDelayInSeconds} seconds." _.delay @cleanupAndSimulateAnotherTask, @retryDelayInSeconds * 1000 @@ -240,7 +241,11 @@ module.exports = class Simulator extends CocoClass @sendResultsBackToServer taskResults sendResultsBackToServer: (results) -> - @trigger 'statusUpdate', 'Simulation completed, sending results back to server!' + status = 'Recording:' + for session in results.sessions + states = ['wins', if _.find(results.sessions, (s) -> s.metrics.rank is 0) then 'loses' else 'draws'] + status += " #{session.name} #{states[session.metrics.rank]}" + @trigger 'statusUpdate', status console.log 'Sending result back to server:' console.log JSON.stringify results diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 8f34232a1..13af9444b 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -874,6 +874,7 @@ tournament_ended: "Tournament ended" tournament_rules: "Tournament Rules" tournament_blurb: "Write code, collect gold, build armies, crush foes, win prizes, and upgrade your career in our $40,000 Greed tournament! Check out the details" + tournament_blurb_criss_cross: "Win bids, construct paths, outwit opponents, grab gems, and upgrade your career in our Criss-Cross tournament! Check out the details" tournament_blurb_blog: "on our blog" rules: "Rules" winners: "Winners" diff --git a/app/templates/play/ladder/ladder.jade b/app/templates/play/ladder/ladder.jade index 3e042df50..f031954ed 100644 --- a/app/templates/play/ladder/ladder.jade +++ b/app/templates/play/ladder/ladder.jade @@ -11,7 +11,6 @@ block content if level.get('name') == 'Greed' .tournament-blurb h2 - //span(data-i18n="ladder.tournament_ends") Tournament ends span(data-i18n="ladder.tournament_ended") Tournament ended | #{tournamentTimeLeft} p @@ -46,6 +45,17 @@ block content a(href="http://aws.amazon.com/") img(src=base + "aws.png") + if level.get('name') == 'Criss-Cross' + .tournament-blurb + h2 + span(data-i18n="ladder.tournament_ends") Tournament ends + | #{tournamentTimeLeft} + p + span(data-i18n="ladder.tournament_blurb_criss_cross") Win bids, construct paths, outwit opponents, grab gems, and upgrade your career in our Criss-Cross tournament! Check out the details + | + a(href="http://blog.codecombat.com/6-programming-languages-one-victor-codecombats-newest-tournament", data-i18n="ladder.tournament_blurb_blog") on our blog + | . + div#columns.row div.column.col-md-2 for team in teams @@ -73,8 +83,10 @@ block content if level.get('name') == 'Greed' li a(href="#prizes", data-toggle="tab", data-i18n="ladder_prizes.prizes") Prizes + if level.get('name') == 'Greed' li a(href="#rules", data-toggle="tab", data-i18n="ladder.rules") Rules + if level.get('name') == 'Greed' || (level.get('name') == 'Criss-Cross!!!') li a(href="#winners", data-toggle="tab", data-i18n="ladder.winners") Winners @@ -651,6 +663,7 @@ block content | - $50 td $50 + if level.get('name') == 'Greed' .tab-pane.well#rules h1(data-i18n="ladder.tournament_rules") Tournament Rules h2 General @@ -712,6 +725,7 @@ block content a(href="http://discourse.codecombat.com/") Discourse forum | . + if level.get('name') == 'Greed' || level.get('name') == 'Criss-Cross!!!' .tab-pane.well#winners h1(data-i18n="ladder.winners") Winners diff --git a/app/templates/play/ladder/ladder_tab.jade b/app/templates/play/ladder/ladder_tab.jade index 00982e8c6..1bf74e730 100644 --- a/app/templates/play/ladder/ladder_tab.jade +++ b/app/templates/play/ladder/ladder_tab.jade @@ -8,8 +8,7 @@ div#columns.row th(colspan=2) th(colspan=3, style="color: #{team.primaryColor}") span= team.name - span - span(data-i18n="ladder.leaderboard") Leaderboard + span.spl(data-i18n="ladder.leaderboard") Leaderboard tr th(colspan=2) th(data-i18n="general.score") Score diff --git a/app/templates/play/level/control_bar.jade b/app/templates/play/level/control_bar.jade index 745a16411..436c177a0 100644 --- a/app/templates/play/level/control_bar.jade +++ b/app/templates/play/level/control_bar.jade @@ -4,7 +4,10 @@ h4.home i.icon-home.icon-white span(data-i18n="play_level.home") Home -h4.title #{worldName} +h4.title + | #{worldName} + | - + a(href=editorLink, data-i18n="nav.editor", title="Open " + worldName + " in the Level Editor") Editor button.btn.btn-xs.btn-inverse.banner#game-menu-button(title="Show game menu", data-i18n="play_level.game_menu") Game Menu diff --git a/app/templates/play/level/level_loading.jade b/app/templates/play/level/level_loading.jade index 33de4253e..03d357f75 100644 --- a/app/templates/play/level/level_loading.jade +++ b/app/templates/play/level/level_loading.jade @@ -16,7 +16,6 @@ strong.tip(data-i18n='play_level.tip_open_source') CodeCombat is 100% open source! strong.tip(data-i18n='play_level.tip_beta_launch') CodeCombat launched its beta in October, 2013. strong.tip(data-i18n='play_level.tip_js_beginning') JavaScript is just the beginning. - strong.tip(data-i18n='play_level.tip_autocast_setting') Adjust autocast settings by clicking the gear on the cast button. strong.tip(data-i18n='play_level.tip_think_solution') Think of the solution, not the problem. strong.tip(data-i18n='play_level.tip_theory_practice') In theory there is no difference between theory and practice; in practice there is. - Yogi Berra strong.tip(data-i18n='play_level.tip_error_free') There are two ways to write error-free programs; only the third one works. - Alan Perlis diff --git a/app/views/play/MainPlayView.coffee b/app/views/play/MainPlayView.coffee index c2e557d1a..4797ddf6f 100644 --- a/app/views/play/MainPlayView.coffee +++ b/app/views/play/MainPlayView.coffee @@ -143,14 +143,14 @@ module.exports = class MainPlayView extends RootView ] arenas = [ - #{ - # name: 'Criss-Cross' - # difficulty: 4 - # id: 'criss-cross' - # image: '/file/db/level/528aea2d7f37fc4e0700016b/its_a_trap_icon.png' - # description: 'Participate in a bidding war with opponents to reach the other side!' - # levelPath: 'ladder' - #} + { + name: 'Criss-Cross' + difficulty: 5 + id: 'criss-cross' + image: '/file/db/level/528aea2d7f37fc4e0700016b/its_a_trap_icon.png' + description: 'Participate in a bidding war with opponents to reach the other side!' + levelPath: 'ladder' + } { name: 'Greed' difficulty: 4 @@ -192,7 +192,7 @@ module.exports = class MainPlayView extends RootView levelPath: 'ladder' } ] - + classicAlgorithms = [ { name: 'Bubble Sort Bootcamp Battle' diff --git a/app/views/play/ladder/LadderView.coffee b/app/views/play/ladder/LadderView.coffee index 0e2d03e25..2c70f3ba6 100644 --- a/app/views/play/ladder/LadderView.coffee +++ b/app/views/play/ladder/LadderView.coffee @@ -52,13 +52,13 @@ module.exports = class LadderView extends RootView ctx.levelID = @levelID ctx.levelDescription = marked(@level.get('description')) if @level.get('description') ctx._ = _ - ctx.tournamentTimeLeft = moment(new Date(1402444800000)).fromNow() + if tournamentDate = {greed: 1402444800000, 'criss-cross': 1410912000000}[@levelID] + ctx.tournamentTimeLeft = moment(new Date(tournamentDate)).fromNow() ctx.winners = require('views/play/ladder/tournament_results')[@levelID] ctx afterRender: -> super() - # console.debug 'gintau', 'ladder_view-afterRender', @supermodel.finished() return unless @supermodel.finished() @insertSubView(@ladderTab = new LadderTabView({}, @level, @sessions)) @insertSubView(@myMatchesTab = new MyMatchesTabView({}, @level, @sessions)) diff --git a/app/views/play/ladder/MainLadderView.coffee b/app/views/play/ladder/MainLadderView.coffee index 502bbd877..8cb593036 100644 --- a/app/views/play/ladder/MainLadderView.coffee +++ b/app/views/play/ladder/MainLadderView.coffee @@ -30,6 +30,13 @@ module.exports = class LadderHomeView extends RootView getRenderData: (context={}) -> context = super(context) arenas = [ + { + name: 'Criss-Cross' + difficulty: 5 + id: 'criss-cross' + image: '/file/db/level/5391f3d519dc22b8082159b2/banner2.png' + description: 'Participate in a bidding war with opponents to reach the other side!' + } { name: 'Greed' difficulty: 4 @@ -37,6 +44,13 @@ module.exports = class LadderHomeView extends RootView image: '/file/db/level/53558b5a9914f5a90d7ccddb/greed_banner.jpg' description: 'Liked Dungeon Arena and Gold Rush? Put them together in this economic arena!' } + { + name: 'Sky Span (Testing)' + difficulty: 3 + id: 'sky-span' + image: '/file/db/level/53c80fce0ddbef000084c667/sky-Span-banner.jpg' + description: 'Preview version of an upgraded Dungeon Arena. Help us with hero balance before release!' + } { name: 'Dungeon Arena' difficulty: 3 diff --git a/app/views/play/ladder/SimulateTabView.coffee b/app/views/play/ladder/SimulateTabView.coffee index ddb28030c..5993c2f22 100644 --- a/app/views/play/ladder/SimulateTabView.coffee +++ b/app/views/play/ladder/SimulateTabView.coffee @@ -18,9 +18,6 @@ module.exports = class SimulateTabView extends CocoView @simulatorsLeaderboardDataRes = @supermodel.addModelResource(@simulatorsLeaderboardData, 'top_simulators') @simulatorsLeaderboardDataRes.load() - @simulator = new Simulator() - @listenTo(@simulator, 'statusUpdate', @updateSimulationStatus) - onLoaded: -> super() @render() @@ -42,7 +39,21 @@ module.exports = class SimulateTabView extends CocoView application.tracker?.trackEvent 'Simulate Button Click', {} $('#simulate-button').prop 'disabled', true $('#simulate-button').text 'Simulating...' + @simulateNextGame() + simulateNextGame: -> + unless @simulator + @simulator = new Simulator() + @listenTo @simulator, 'statusUpdate', @updateSimulationStatus + # Work around simulator getting super slow on Chrome + fetchAndSimulateTaskOriginal = @simulator.fetchAndSimulateTask + @simulator.fetchAndSimulateTask = => + if @simulator.simulatedByYou >= 5 + @simulator.destroy() + @simulator = null + @simulateNextGame() + else + fetchAndSimulateTaskOriginal.apply @simulator @simulator.fetchAndSimulateTask() refresh: -> @@ -51,20 +62,23 @@ module.exports = class SimulateTabView extends CocoView $.ajax '/queue/messagesInQueueCount', {success} updateSimulationStatus: (simulationStatus, sessions) -> + if simulationStatus is 'Fetching simulation data!' + @simulationMatchDescription = '' + @simulationSpectateLink = '' @simulationStatus = simulationStatus try if sessions? - #TODO: Fetch names from Redis, the creatorName is denormalized - creatorNames = (session.creatorName for session in sessions) - @simulationStatus = 'Simulating game between ' - for index in [0...creatorNames.length] - unless creatorNames[index] - creatorNames[index] = 'Anonymous' - @simulationStatus += (if index != 0 then ' and ' else '') + creatorNames[index] - @simulationStatus += '...' + @simulationMatchDescription = '' + @simulationSpectateLink = "/play/spectate/#{@simulator.level.get('slug')}?" + for session, index in sessions + # TODO: Fetch names from Redis, the creatorName is denormalized + @simulationMatchDescription += "#{if index then ' vs ' else ''}#{session.creatorName or 'Anonymous'} (#{sessions[index].team})" + @simulationSpectateLink += "session-#{if index then 'two' else 'one'}=#{session.sessionID}" + @simulationMatchDescription += " on #{@simulator.level.get('name')}" catch e console.log "There was a problem with the named simulation status: #{e}" - $('#simulation-status-text').text @simulationStatus + link = if @simulationSpectateLink then "#{_.string.escapeHTML(@simulationMatchDescription)}" else '' + $('#simulation-status-text').html "