2014-07-17 20:16:32 -04:00
RootView = require ' views/kinds/RootView '
2014-01-03 13:32:13 -05:00
template = require ' templates/play '
2014-03-31 18:48:22 -04:00
LevelSession = require ' models/LevelSession '
2014-04-22 15:42:26 -04:00
CocoCollection = require ' collections/CocoCollection '
2014-03-31 18:48:22 -04:00
class LevelSessionsCollection extends CocoCollection
url: ' '
model: LevelSession
constructor: (model) ->
super ( )
@url = " /db/user/ #{ me . id } /level.sessions?project=state.complete,levelID "
2014-01-03 13:32:13 -05:00
2014-07-18 20:06:20 -04:00
module.exports = class MainPlayView extends RootView
2014-06-30 22:16:26 -04:00
id: ' play-view '
2014-01-03 13:32:13 -05:00
template: template
2014-03-31 18:48:22 -04:00
constructor: (options) ->
super options
@levelStatusMap = { }
2014-08-26 20:34:00 -04:00
@sessions = @ supermodel . loadCollection ( new LevelSessionsCollection ( ) , ' your_sessions ' , null , 0 ) . model
2014-03-31 18:48:22 -04:00
@ listenToOnce @ sessions , ' sync ' , @ onSessionsLoaded
onSessionsLoaded: (e) ->
for session in @ sessions . models
@ levelStatusMap [ session . get ( ' levelID ' ) ] = if session . get ( ' state ' ) ? . complete then ' complete ' else ' started '
@ render ( )
2014-02-11 17:58:45 -05:00
getRenderData: (context={}) ->
2014-01-03 13:32:13 -05:00
context = super ( context )
tutorials = [
{
name: ' Rescue Mission '
2014-03-18 18:49:06 -04:00
difficulty: 1
2014-01-03 13:32:13 -05:00
id: ' rescue-mission '
image: ' /file/db/level/52740644904ac0411700067c/rescue_mission_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Tharin has been captured! '
2014-01-03 13:32:13 -05:00
}
{
name: ' Grab the Mushroom '
difficulty: 1
id: ' grab-the-mushroom '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/529662dfe0df8f0000000007/grab_the_mushroom_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Grab a powerup and smash a big ogre. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Drink Me '
difficulty: 1
id: ' drink-me '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525dc5589a0765e496000006/drink_me_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Drink up and slay two munchkins. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Taunt the Guards '
difficulty: 1
id: ' taunt-the-guards '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/5276c9bdcf83207a2801ff8f/taunt_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Tharin, if clever, can escape with Phoebe. '
2014-01-03 13:32:13 -05:00
}
{
2014-06-30 22:16:26 -04:00
name: ' It \' s a Trap '
2014-01-03 13:32:13 -05:00
difficulty: 1
id: ' its-a-trap '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/528aea2d7f37fc4e0700016b/its_a_trap_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Organize a dungeon ambush with archers. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Break the Prison '
difficulty: 1
id: ' break-the-prison '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/5275272c69abdcb12401216e/break_the_prison_icon.png '
2014-06-30 22:16:26 -04:00
description: ' More comrades are imprisoned! '
2014-01-03 13:32:13 -05:00
}
{
name: ' Taunt '
difficulty: 1
id: ' taunt '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525f150306e1ab0962000018/taunt_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Taunt the ogre to claim victory. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Cowardly Taunt '
difficulty: 1
id: ' cowardly-taunt '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525abfd9b12777d78e000009/cowardly_taunt_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Lure infuriated ogres to their doom. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Commanding Followers '
difficulty: 1
id: ' commanding-followers '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Lead allied soldiers into battle. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Mobile Artillery '
difficulty: 1
id: ' mobile-artillery '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525085419851b83f4b000001/mobile_artillery_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Blow ogres up! '
2014-01-03 13:32:13 -05:00
}
]
experienced = [
{
name: ' Hunter Triplets '
2014-03-18 18:49:06 -04:00
difficulty: 2
2014-01-03 13:32:13 -05:00
id: ' hunter-triplets '
image: ' /file/db/level/526711d9add4f8965f000002/hunter_triplets_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Three soldiers go ogre hunting. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Emphasis on Aim '
difficulty: 2
id: ' emphasis-on-aim '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/525f384d96cd77000000000f/munchkin_masher_icon.png '
2014-07-17 03:16:08 -04:00
description: ' Choose your targets carefully. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Zone of Danger '
2014-03-18 18:49:06 -04:00
difficulty: 3
2014-01-03 13:32:13 -05:00
id: ' zone-of-danger '
image: ' /file/db/level/526ae95c1e5cd30000000008/zone_of_danger_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Target the ogres swarming into arrow range. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Molotov Medic '
difficulty: 2
id: ' molotov-medic '
2014-03-18 18:49:06 -04:00
image: ' /file/db/level/52602ecb026e8481e7000001/generic_1.png '
2014-06-30 22:16:26 -04:00
description: ' Tharin must play support in this dungeon battle. '
2014-01-03 13:32:13 -05:00
}
{
name: ' Gridmancer '
2014-03-18 18:49:06 -04:00
difficulty: 5
2014-01-03 13:32:13 -05:00
id: ' gridmancer '
image: ' /file/db/level/52ae2460ef42c52f13000008/gridmancer_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Super algorithm challenge level! '
2014-01-03 13:32:13 -05:00
}
]
2014-03-12 19:41:09 -04:00
arenas = [
2014-08-19 00:49:58 -04:00
{
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 '
}
2014-05-19 14:58:45 -04:00
{
name: ' Greed '
difficulty: 4
id: ' greed '
image: ' /file/db/level/526fd3043c637ece50001bb2/the_herd_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Liked Dungeon Arena and Gold Rush? Put them together in this economic arena! '
2014-05-19 14:58:45 -04:00
levelPath: ' ladder '
}
2014-03-12 19:41:09 -04:00
{
name: ' Dungeon Arena '
difficulty: 3
id: ' dungeon-arena '
image: ' /file/db/level/526ae95c1e5cd30000000008/zone_of_danger_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Play head-to-head against fellow Wizards in a dungeon melee! '
2014-03-12 19:41:09 -04:00
levelPath: ' ladder '
}
{
2014-04-25 18:00:46 -04:00
name: ' Gold Rush '
difficulty: 3
id: ' gold-rush '
image: ' /file/db/level/52602ecb026e8481e7000001/generic_1.png '
2014-06-30 22:16:26 -04:00
description: ' Prove you are better at collecting gold than your opponent! '
2014-04-25 18:00:46 -04:00
levelPath: ' ladder '
}
2014-04-23 19:07:59 -04:00
{
2014-04-25 18:00:46 -04:00
name: ' Brawlwood '
difficulty: 4
id: ' brawlwood '
2014-04-23 19:07:59 -04:00
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Combat the armies of other Wizards in a strategic forest arena! (Fast computer required.) '
2014-04-23 19:07:59 -04:00
levelPath: ' ladder '
}
2014-08-04 22:46:00 -04:00
{
name: ' Sky Span (Testing) '
difficulty: 3
id: ' sky-span '
image: ' /file/db/level/526ae95c1e5cd30000000008/zone_of_danger_icon.png '
description: ' Preview version of an upgraded Dungeon Arena. Help us with hero balance before release! '
levelPath: ' ladder '
}
2014-03-12 19:41:09 -04:00
]
2014-08-19 00:49:58 -04:00
2014-08-12 16:23:43 -04:00
classicAlgorithms = [
2014-03-03 19:22:50 -05:00
{
name: ' Bubble Sort Bootcamp Battle '
difficulty: 3
id: ' bubble-sort-bootcamp-battle '
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Write a bubble sort to organize your soldiers. - by Alexandru Caciulescu '
2014-03-03 19:22:50 -05:00
}
2014-01-03 13:32:13 -05:00
{
2014-03-12 19:41:09 -04:00
name: ' Ogres of Hanoi '
difficulty: 3
id: ' ogres-of-hanoi '
image: ' /file/db/level/526fd3043c637ece50001bb2/the_herd_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Transfer a stack of ogres while preserving their honor. - by Alexandru Caciulescu '
2014-06-09 15:29:02 -04:00
}
{
name: ' Danger! Minefield '
difficulty: 3
2014-06-09 15:37:34 -04:00
id: ' danger-minefield '
2014-06-10 00:11:59 -04:00
image: ' /file/db/level/526bda3fe79aefde2a003e36/mobile_artillery_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Learn how to find prime numbers while defusing mines! - by Alexandru Caciulescu '
2014-03-12 19:41:09 -04:00
}
2014-06-22 20:43:54 -04:00
{
name: ' K-means++ Cluster Wars '
difficulty: 4
id: ' k-means-cluster-wars '
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Learn cluster analysis while leading armies into battle! - by Alexandru Caciulescu '
2014-08-07 19:04:02 -04:00
}
{
2014-08-07 20:26:13 -04:00
name: ' Quicksort the Spiral '
2014-08-07 19:04:02 -04:00
difficulty: 3
id: ' quicksort-the-spiral '
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
description: ' Learn Quicksort while sorting a spiral of ogres! - by Alexandru Caciulescu '
2014-06-22 20:43:54 -04:00
}
2014-08-18 11:39:16 -04:00
{
name: ' Minimax Tic-Tac-Toe '
difficulty: 4
id: ' minimax-tic-tac-toe '
image: ' /file/db/level/525ef8ef06e1ab0962000003/commanding_followers_icon.png '
description: ' Learn how to make a game AI with the Minimax algorithm. - by Alexandru Caciulescu '
}
2014-08-12 16:23:43 -04:00
]
playerCreated = [
{
name: ' Extra Extrapolation '
difficulty: 2
id: ' extra-extrapolation '
image: ' /file/db/level/526bda3fe79aefde2a003e36/mobile_artillery_icon.png '
description: ' Predict your target \' s position for deadly aim. - by Sootn '
}
{
name: ' The Right Route '
difficulty: 1
id: ' the-right-route '
image: ' /file/db/level/526fd3043c637ece50001bb2/the_herd_icon.png '
description: ' Strike at the weak point in an array of enemies. - by Aftermath '
}
{
name: ' Sword Loop '
difficulty: 2
id: ' sword-loop '
image: ' /file/db/level/525dc5589a0765e496000006/drink_me_icon.png '
description: ' Kill the ogres and save the peasants with for-loops. - by Prabh Simran Singh Baweja '
}
{
name: ' Coin Mania '
difficulty: 2
id: ' coin-mania '
image: ' /file/db/level/529662dfe0df8f0000000007/grab_the_mushroom_icon.png '
description: ' Learn while-loops to grab coins and potions. - by Prabh Simran Singh Baweja '
}
2014-04-14 16:43:23 -04:00
{
name: ' Find the Spy '
difficulty: 2
id: ' find-the-spy '
image: ' /file/db/level/526ae95c1e5cd30000000008/zone_of_danger_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Identify the spies hidden among your soldiers - by Nathan Gossett '
2014-04-14 16:43:23 -04:00
}
2014-04-25 18:00:46 -04:00
{
name: ' Harvest Time '
difficulty: 2
2014-04-29 11:53:55 -04:00
id: ' harvest-time '
2014-04-25 18:00:46 -04:00
image: ' /file/db/level/529662dfe0df8f0000000007/grab_the_mushroom_icon.png '
2014-06-30 22:16:26 -04:00
description: ' Collect a hundred mushrooms in just five lines of code - by Nathan Gossett '
2014-04-25 18:00:46 -04:00
}
2014-07-09 09:02:58 -04:00
{
name: ' Guide Everyone Home '
difficulty: 2
id: ' guide-everyone-home '
image: ' /file/db/level/52740644904ac0411700067c/rescue_mission_icon.png '
description: ' Fetch the wizards teleporting into the area - by Nathan Gossett '
}
2014-07-09 21:19:59 -04:00
{
name: " Let ' s go Fly a Kite "
difficulty: 3
id: ' lets-go-fly-a-kite '
image: ' /file/db/level/526711d9add4f8965f000002/hunter_triplets_icon.png '
description: ' There is a horde of ogres marching on your village. Stay out of reach and use your bow to take them out! - by Danny Whittaker '
}
2014-01-03 13:32:13 -05:00
]
context.campaigns = [
2014-06-30 22:16:26 -04:00
{ id: ' beginner ' , name: ' Beginner Campaign ' , description: ' ... in which you learn the wizardry of programming. ' , levels: tutorials }
{ id: ' multiplayer ' , name: ' Multiplayer Arenas ' , description: ' ... in which you code head-to-head against other players. ' , levels: arenas }
{ id: ' dev ' , name: ' Random Harder Levels ' , description: ' ... in which you learn the interface while doing something a little harder. ' , levels: experienced }
2014-08-12 16:23:43 -04:00
{ id: ' classic ' , name: ' Classic Algorithms ' , description: ' ... in which you learn the most popular algorithms in Computer Science. ' , levels: classicAlgorithms }
2014-06-30 22:16:26 -04:00
{ id: ' player_created ' , name: ' Player-Created ' , description: ' ... in which you battle against the creativity of your fellow <a href= \" /contribute # artisan \" >Artisan Wizards</a>. ' , levels: playerCreated }
2014-01-03 13:32:13 -05:00
]
2014-03-31 18:48:22 -04:00
context.levelStatusMap = @ levelStatusMap
2014-01-03 13:32:13 -05:00
context
afterRender: ->
super ( )
2014-01-30 19:36:36 -05:00
@ $el . find ( ' .modal ' ) . on ' shown.bs.modal ' , ->
2014-01-03 13:32:13 -05:00
$ ( ' input:visible:first ' , @ ) . focus ( )