mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 10:06:08 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
5f78f57c85
23 changed files with 99 additions and 185 deletions
|
@ -37,18 +37,14 @@
|
|||
<script src="/javascripts/aether.js"></script>
|
||||
<script src="/javascripts/app.js"></script> <!-- it's all Backbone! -->
|
||||
|
||||
<script>
|
||||
window.linkedInAsyncInit = function() {
|
||||
console.log("Linkedin Async Init!");
|
||||
Backbone.Mediator.publish('linkedin-loaded');
|
||||
};
|
||||
|
||||
<!-- Can move to lib/services/linkedin.coffee instead somehow? Or just get rid of LinkedIn...
|
||||
</script>
|
||||
<script type="text/javascript" async src="http://platform.linkedin.com/in.js">
|
||||
api_key: 75v8mv4ictvmx6
|
||||
onLoad: linkedInAsyncInit
|
||||
authorize: true
|
||||
</script>
|
||||
-->
|
||||
|
||||
<script>
|
||||
window.userObject = "userObjectTag";
|
||||
|
|
|
@ -78,7 +78,6 @@ initializeUtilityServices = ->
|
|||
services = [
|
||||
'./lib/services/filepicker'
|
||||
'./lib/services/segmentio'
|
||||
'./lib/services/olark'
|
||||
]
|
||||
|
||||
for service in services
|
||||
|
|
|
@ -61,7 +61,6 @@ module.exports = class LevelLoader extends CocoClass
|
|||
# Session Loading
|
||||
|
||||
loadSession: ->
|
||||
return if @headless
|
||||
if @sessionID
|
||||
url = "/db/level.session/#{@sessionID}"
|
||||
else
|
||||
|
@ -71,6 +70,11 @@ module.exports = class LevelLoader extends CocoClass
|
|||
session = new LevelSession().setURL url
|
||||
@sessionResource = @supermodel.loadModel(session, 'level_session', {cache: false})
|
||||
@session = @sessionResource.model
|
||||
if @opponentSessionID
|
||||
opponentSession = new LevelSession().setURL "/db/level.session/#{@opponentSessionID}"
|
||||
@opponentSessionResource = @supermodel.loadModel(opponentSession, 'opponent_session')
|
||||
@opponentSession = @opponentSessionResource.model
|
||||
|
||||
if @session.loaded
|
||||
@session.setURL '/db/level.session/' + @session.id
|
||||
@loadDependenciesForSession @session
|
||||
|
@ -78,11 +82,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
@listenToOnce @session, 'sync', ->
|
||||
@session.setURL '/db/level.session/' + @session.id
|
||||
@loadDependenciesForSession @session
|
||||
|
||||
if @opponentSessionID
|
||||
opponentSession = new LevelSession().setURL "/db/level.session/#{@opponentSessionID}"
|
||||
@opponentSessionResource = @supermodel.loadModel(opponentSession, 'opponent_session')
|
||||
@opponentSession = @opponentSessionResource.model
|
||||
if @opponentSession
|
||||
if @opponentSession.loaded
|
||||
@loadDependenciesForSession @opponentSession
|
||||
else
|
||||
|
@ -92,11 +92,13 @@ module.exports = class LevelLoader extends CocoClass
|
|||
if session is @session
|
||||
Backbone.Mediator.publish 'level:session-loaded', level: @level, session: @session
|
||||
@consolidateFlagHistory() if @opponentSession?.loaded
|
||||
else
|
||||
else if session is @opponentSession
|
||||
@consolidateFlagHistory() if @session.loaded
|
||||
return unless @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']
|
||||
@sessionDependenciesRegistered ?= {}
|
||||
heroConfig = session.get('heroConfig')
|
||||
heroConfig ?= me.get('heroConfig') if session is @session
|
||||
heroConfig ?= me.get('heroConfig') if session is @session and not @headless
|
||||
console.error @level.get('name'), session.get('team'), session.get('creatorName'), 'had hero', heroConfig.thangType
|
||||
heroConfig ?= {inventory: {}, thangType: '529ffbf1cf1818f2be000001'} # If all else fails, assign Tharin as the hero.
|
||||
session.set 'heroConfig', heroConfig unless _.isEqual heroConfig, session.get('heroConfig')
|
||||
url = "/db/thang.type/#{heroConfig.thangType}/version"
|
||||
|
@ -108,13 +110,16 @@ module.exports = class LevelLoader extends CocoClass
|
|||
@loadThangsRequiredByThangType heroThangType
|
||||
|
||||
for itemThangType in _.values(heroConfig.inventory)
|
||||
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original,rasterIcon"
|
||||
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original,rasterIcon,kind"
|
||||
if itemResource = @maybeLoadURL(url, ThangType, 'thang')
|
||||
@worldNecessities.push itemResource
|
||||
else
|
||||
itemThangType = @supermodel.getModel url
|
||||
@loadDefaultComponentsForThangType itemThangType
|
||||
@loadThangsRequiredByThangType itemThangType
|
||||
@sessionDependenciesRegistered[session.id] = true
|
||||
if _.size(@sessionDependenciesRegistered) is 2 and not (r for r in @worldNecessities when r?).length
|
||||
@onWorldNecessitiesLoaded()
|
||||
|
||||
consolidateFlagHistory: ->
|
||||
state = @session.get('state') ? {}
|
||||
|
@ -172,7 +177,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
url = "/db/level/#{obj.original}/version/#{obj.majorVersion}"
|
||||
@maybeLoadURL url, Level, 'level'
|
||||
|
||||
unless @headless
|
||||
unless @headless or @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop']
|
||||
wizard = ThangType.loadUniversalWizard()
|
||||
@supermodel.loadModel wizard, 'thang'
|
||||
|
||||
|
@ -193,7 +198,7 @@ module.exports = class LevelLoader extends CocoClass
|
|||
else if component.config.requiredThangTypes
|
||||
requiredThangTypes = requiredThangTypes.concat component.config.requiredThangTypes
|
||||
for thangType in requiredThangTypes
|
||||
url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon"
|
||||
url = "/db/thang.type/#{thangType}/version?project=name,components,original,rasterIcon,kind"
|
||||
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
|
||||
|
||||
onThangNamesLoaded: (thangNames) ->
|
||||
|
@ -216,9 +221,10 @@ module.exports = class LevelLoader extends CocoClass
|
|||
return unless index >= 0
|
||||
@worldNecessities.splice(index, 1)
|
||||
@worldNecessities = (r for r in @worldNecessities when r?)
|
||||
@onWorldNecessitiesLoaded() if @worldNecessities.length is 0
|
||||
if @worldNecessities.length is 0 and (not @sessionDependenciesRegistered or @sessionDependenciesRegistered[@session.id] and (not @opponentSession or @sessionDependenciesRegistered[@opponentSession.id]))
|
||||
@onWorldNecessitiesLoaded()
|
||||
|
||||
onWorldNecessitiesLoaded: =>
|
||||
onWorldNecessitiesLoaded: ->
|
||||
@initWorld()
|
||||
@supermodel.clearMaxProgress()
|
||||
@trigger 'world-necessities-loaded'
|
||||
|
@ -250,7 +256,6 @@ module.exports = class LevelLoader extends CocoClass
|
|||
console.log 'SuperModel for Level loaded in', new Date().getTime() - @t0, 'ms'
|
||||
@loadLevelSounds()
|
||||
@denormalizeSession()
|
||||
app.tracker.updatePlayState(@level, @session) unless @headless
|
||||
|
||||
buildLoop: =>
|
||||
someLeft = false
|
||||
|
|
|
@ -9,7 +9,6 @@ module.exports = class Tracker
|
|||
window.tracker = @
|
||||
@isProduction = document.location.href.search('codecombat.com') isnt -1
|
||||
@identify()
|
||||
@updateOlark()
|
||||
|
||||
identify: (traits) ->
|
||||
console.log 'Would identify', traits if debugAnalytics
|
||||
|
@ -20,24 +19,6 @@ module.exports = class Tracker
|
|||
traits[userTrait] ?= me.get(userTrait)
|
||||
analytics.identify me.id, traits
|
||||
|
||||
updateOlark: ->
|
||||
return unless me and olark?
|
||||
olark 'api.chat.updateVisitorStatus', snippet: ["User ID: #{me.id}"]
|
||||
return if me.get('anonymous')
|
||||
olark 'api.visitor.updateEmailAddress', emailAddress: me.get('email') if me.get('email')
|
||||
olark 'api.chat.updateVisitorNickname', snippet: me.displayName()
|
||||
|
||||
updatePlayState: (level, session) ->
|
||||
return unless olark?
|
||||
link = "codecombat.com/play/level/#{level.get('slug') or level.id}?session=#{session.id}"
|
||||
snippet = [
|
||||
"#{link}"
|
||||
"User ID: #{me.id}"
|
||||
"Session ID: #{session.id}"
|
||||
"Level: #{level.get('name')}"
|
||||
]
|
||||
olark 'api.chat.updateVisitorStatus', snippet: snippet
|
||||
|
||||
trackPageView: ->
|
||||
return unless @isProduction and analytics?
|
||||
url = Backbone.history.getFragment()
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
module.exports = initializeOlark = ->
|
||||
window.olark or ((c) -> #<![CDATA[
|
||||
f = window
|
||||
d = document
|
||||
l = (if f.location.protocol is 'https:' then 'https:' else 'http:')
|
||||
z = c.name
|
||||
r = 'load'
|
||||
nt = ->
|
||||
s = ->
|
||||
a.P r
|
||||
f[z] r
|
||||
return
|
||||
f[z] = ->
|
||||
(a.s = a.s or []).push arguments
|
||||
return
|
||||
|
||||
a = f[z]._ = {}
|
||||
q = c.methods.length
|
||||
while q--
|
||||
((n) ->
|
||||
f[z][n] = ->
|
||||
f[z] 'call', n, arguments
|
||||
return
|
||||
|
||||
return
|
||||
) c.methods[q]
|
||||
a.l = c.loader
|
||||
a.i = nt
|
||||
a.p = 0: +new Date
|
||||
a.P = (u) ->
|
||||
a.p[u] = new Date - a.p[0]
|
||||
return
|
||||
|
||||
(if f.addEventListener then f.addEventListener(r, s, false) else f.attachEvent('on' + r, s))
|
||||
ld = ->
|
||||
p = (hd) ->
|
||||
hd = 'head'
|
||||
[
|
||||
'<'
|
||||
hd
|
||||
'></'
|
||||
hd
|
||||
'><'
|
||||
i
|
||||
' onl' + 'oad=\"var d='
|
||||
g
|
||||
";d.getElementsByTagName('head')[0]."
|
||||
j
|
||||
'(d.'
|
||||
h
|
||||
"('script'))."
|
||||
k
|
||||
"='"
|
||||
l
|
||||
'//'
|
||||
a.l
|
||||
"'"
|
||||
'\"'
|
||||
'></'
|
||||
i
|
||||
'>'
|
||||
].join ''
|
||||
i = 'body'
|
||||
m = d[i]
|
||||
return setTimeout(ld, 100) unless m
|
||||
a.P 1
|
||||
j = 'appendChild'
|
||||
h = 'createElement'
|
||||
k = 'src'
|
||||
n = d[h]('div')
|
||||
v = n[j](d[h](z))
|
||||
b = d[h]('iframe')
|
||||
g = 'document'
|
||||
e = 'domain'
|
||||
o = undefined
|
||||
n.style.display = 'none'
|
||||
m.insertBefore(n, m.firstChild).id = z
|
||||
b.frameBorder = '0'
|
||||
b.id = z + '-loader'
|
||||
b.src = 'javascript:false' if /MSIE[ ]+6/.test(navigator.userAgent)
|
||||
b.allowTransparency = 'true'
|
||||
v[j] b
|
||||
try
|
||||
b.contentWindow[g].open()
|
||||
catch w
|
||||
c[e] = d[e]
|
||||
o = 'javascript:var d=' + g + ".open();d.domain='" + d.domain + "';"
|
||||
b[k] = o + 'void(0);'
|
||||
try
|
||||
t = b.contentWindow[g]
|
||||
t.write p()
|
||||
t.close()
|
||||
catch x
|
||||
b[k] = o + 'd.write(\"' + p().replace(/"/g, String.fromCharCode(92) + '\"') + '\");d.close();'
|
||||
a.P 2
|
||||
return
|
||||
|
||||
ld()
|
||||
return
|
||||
|
||||
nt()
|
||||
return
|
||||
)(
|
||||
loader: 'static.olark.com/jsclient/loader0.js'
|
||||
name: 'olark'
|
||||
methods: [
|
||||
'configure'
|
||||
'extend'
|
||||
'declare'
|
||||
'identify'
|
||||
]
|
||||
)
|
||||
|
||||
# custom configuration goes here (www.olark.com/documentation)
|
||||
olark.identify '1451-787-10-5544' #]]>
|
|
@ -45,7 +45,7 @@ module.exports = class Simulator extends CocoClass
|
|||
@supermodel ?= new SuperModel()
|
||||
@supermodel.resetProgress()
|
||||
@stopListening @supermodel, 'loaded-all'
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), headless: true
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: @task.getLevelName(), sessionID: @task.getFirstSessionID(), opponentSessionID: @task.getSecondSessionID(), headless: true
|
||||
|
||||
if @supermodel.finished()
|
||||
@simulateSingleGame()
|
||||
|
@ -165,7 +165,7 @@ module.exports = class Simulator extends CocoClass
|
|||
@supermodel ?= new SuperModel()
|
||||
@supermodel.resetProgress()
|
||||
@stopListening @supermodel, 'loaded-all'
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: levelID, sessionID: @task.getFirstSessionID(), headless: true
|
||||
@levelLoader = new LevelLoader supermodel: @supermodel, levelID: levelID, sessionID: @task.getFirstSessionID(), opponentSessionID: @task.getSecondSessionID(), headless: true
|
||||
if @supermodel.finished()
|
||||
@simulateGame()
|
||||
else
|
||||
|
@ -189,11 +189,13 @@ module.exports = class Simulator extends CocoClass
|
|||
@world = @levelLoader.world
|
||||
@task.setWorld(@world)
|
||||
@level = @levelLoader.level
|
||||
@session = @levelLoader.session
|
||||
@otherSession = @levelLoader.opponentSession
|
||||
@levelLoader.destroy()
|
||||
@levelLoader = null
|
||||
|
||||
setupGod: ->
|
||||
@god.setLevel @level.serialize @supermodel, @task.getSessions()[0], @task.getSessions()[1]
|
||||
@god.setLevel @level.serialize(@supermodel, @session, @otherSession)
|
||||
@god.setLevelSessionIDs (session.sessionID for session in @task.getSessions())
|
||||
@god.setWorldClassMap @world.classMap
|
||||
@god.setGoalManager new GoalManager(@world, @level.get 'goals')
|
||||
|
@ -424,6 +426,8 @@ class SimulationTask
|
|||
|
||||
getFirstSessionID: -> @rawData.sessions[0].sessionID
|
||||
|
||||
getSecondSessionID: -> @rawData.sessions[1].sessionID
|
||||
|
||||
getTaskID: -> @rawData.taskID
|
||||
|
||||
getReceiptHandle: -> @rawData.receiptHandle
|
||||
|
|
|
@ -78,7 +78,8 @@ class CocoModel extends Backbone.Model
|
|||
thisTV4.addSchema('metaschema', require('schemas/metaschema'))
|
||||
TreemaNode.utils.populateDefaults(clone, @schema(), thisTV4)
|
||||
@attributesWithDefaults = clone
|
||||
console.debug "Populated defaults for #{@attributes.name or @type()} in #{new Date() - t0}ms"
|
||||
duration = new Date() - t0
|
||||
console.debug "Populated defaults for #{@attributes.name or @type()} in #{duration}ms" if duration > 10
|
||||
|
||||
loadFromBackup: ->
|
||||
return unless @saveBackups
|
||||
|
|
|
@ -57,7 +57,7 @@ module.exports = class Level extends CocoModel
|
|||
if isHero and otherSession
|
||||
# If it's a hero and there's another session, find the right session for it.
|
||||
# If there is no other session (playing against default code, or on single player), clone all placeholders.
|
||||
# TODO: actually look at the teams on these things to determine which session should go with which placeholder.
|
||||
# TODO: actually look at the teams on these Thangs to determine which session should go with which placeholder.
|
||||
if levelThang.id is 'Hero Placeholder 1' and session.get('team') is 'humans'
|
||||
session = otherSession
|
||||
else if levelThang.id is 'Hero Placeholder' and session.get('team') is 'ogres'
|
||||
|
|
|
@ -121,7 +121,7 @@ module.exports = class SuperModel extends Backbone.Model
|
|||
if cachedModel
|
||||
clone = $.extend true, {}, model.attributes
|
||||
cachedModel.set(clone, {silent: true, fromMerge: true})
|
||||
console.debug "Updated cached model <#{cachedModel.get('name') or cachedModel.getURL()}> with new data"
|
||||
#console.debug "Updated cached model <#{cachedModel.get('name') or cachedModel.getURL()}> with new data"
|
||||
else
|
||||
@registerModel(model)
|
||||
collection
|
||||
|
|
|
@ -235,6 +235,7 @@ module.exports = class ThangType extends CocoModel
|
|||
return if _.isString spriteSheet
|
||||
return unless spriteSheet
|
||||
canvas = $("<canvas width='#{size}' height='#{size}'></canvas>")
|
||||
console.log 'made canvas', canvas, 'with size', size unless canvas[0]
|
||||
stage = new createjs.Stage(canvas[0])
|
||||
sprite = new createjs.Sprite(spriteSheet)
|
||||
pt = @actions.portrait?.positions?.registration
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
.modal-body
|
||||
padding: 0 20px
|
||||
min-height: 30px
|
||||
|
||||
.achievement-panel
|
||||
background: url("/images/pages/play/level/modal/achievement_plate.png")
|
||||
|
@ -184,6 +185,20 @@
|
|||
float: right
|
||||
margin-left: 10px
|
||||
|
||||
.ladder-submission-view
|
||||
display: inline-block
|
||||
color: white
|
||||
|
||||
.rank-button.btn-block
|
||||
display: inline-block
|
||||
width: initial
|
||||
padding-left: 19px
|
||||
padding-right: 19px
|
||||
|
||||
.last-submitted
|
||||
float: none
|
||||
|
||||
|
||||
html.no-borderimage
|
||||
#hero-victory-modal
|
||||
.background-wrapper
|
||||
|
|
|
@ -51,9 +51,16 @@ block modal-footer-content
|
|||
span#gem-total +0
|
||||
|
||||
button.btn.btn-warning.hide#saving-progress-label(disabled, data-i18n="play_level.victory_saving_progress") Saving Progress
|
||||
a.btn.btn-success.world-map-button.hide#continue-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_continue") Continue
|
||||
|
||||
if readyToRank
|
||||
.ladder-submission-view
|
||||
else if level.get('type') === 'hero-ladder'
|
||||
a.btn.btn-primary(href="/play/ladder/#{level.get('slug')}#my-matches", data-dismiss="modal", data-i18n="play_level.victory_return_to_ladder") Return to Ladder
|
||||
else
|
||||
a.btn.btn-success.world-map-button.hide#continue-button(href="/play-hero", data-dismiss="modal", data-i18n="play_level.victory_play_continue") Continue
|
||||
|
||||
if me.get('anonymous')
|
||||
p.sign-up-poke
|
||||
button.btn.btn-success.sign-up-button.btn-large(data-toggle="coco-modal", data-target="modal/SignupModal", data-i18n="play_level.victory_sign_up") Sign Up to Save Progress
|
||||
span(data-i18n="play_level.victory_sign_up_poke") Want to save your code? Create a free account!
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ module.exports = class SaveLevelModal extends SaveVersionModal
|
|||
console.log "Should we save", m.get('system'), m.get('name'), m, "? localChanges:", m.hasLocalChanges(), "version:", m.get('version'), 'isPublished:', m.isPublished(), 'collection:', m.collection
|
||||
return false
|
||||
return true if m.hasLocalChanges()
|
||||
console.error "Trying to check major version of #{m.type()} #{m.get('name')}, but it doesn't have a version:", m unless m.get('version')
|
||||
return true if (m.get('version').major is 0 and m.get('version').minor is 0) or not m.isPublished() and not m.collection
|
||||
# Sometimes we have two versions: one in a search collection and one with a URL. We only save changes to the latter.
|
||||
false
|
||||
|
|
|
@ -484,7 +484,8 @@ module.exports = class ThangsTabView extends CocoView
|
|||
|
||||
folderForThang: (thang) ->
|
||||
thangType = @supermodel.getModelByOriginal ThangType, thang.thangType
|
||||
[thangType.get('kind'), thangType.get('name')]
|
||||
console.error 'uhh, we had kind', thangType.get('kind', true), 'for', thangType unless thangType.get('kind', true)
|
||||
[thangType.get('kind', true), thangType.get('name', true)]
|
||||
|
||||
pathForThang: (thang) ->
|
||||
folder = @folderForThang(thang)
|
||||
|
|
|
@ -77,7 +77,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
context
|
||||
|
||||
getAnimationNames: -> _.keys(@thangType.get('actions') or {})
|
||||
|
||||
|
||||
afterRender: ->
|
||||
super()
|
||||
return unless @supermodel.finished()
|
||||
|
@ -119,7 +119,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
@stage = new createjs.Stage(canvas[0])
|
||||
@layerAdapter = new LayerAdapter({name:'Default', webGL: true})
|
||||
@topLayer = new createjs.Container()
|
||||
|
||||
|
||||
@layerAdapter.container.x = @topLayer.x = CENTER.x
|
||||
@layerAdapter.container.y = @topLayer.y = CENTER.y
|
||||
@stage.addChild(@layerAdapter.container, @topLayer)
|
||||
|
@ -135,7 +135,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
@updateGrid()
|
||||
_.defer @refreshAnimation
|
||||
@toggleDots(false)
|
||||
|
||||
|
||||
createjs.Ticker.setFPS(30)
|
||||
createjs.Ticker.addEventListener('tick', @stage)
|
||||
|
||||
|
@ -244,7 +244,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
lank = new Lank(@thangType, @getLankOptions())
|
||||
@showLank(lank)
|
||||
@updateScale()
|
||||
|
||||
|
||||
onNewSpriteSheet: ->
|
||||
$('#spritesheets').empty()
|
||||
for image in @layerAdapter.spriteSheet._images
|
||||
|
@ -260,7 +260,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
@showAction(animationName)
|
||||
@updateRotation()
|
||||
@updateScale() # must happen after update rotation, because updateRotation calls the sprite update() method.
|
||||
|
||||
|
||||
showMovieClip: (animationName) ->
|
||||
vectorParser = new SpriteBuilder(@thangType)
|
||||
movieClip = vectorParser.buildMovieClip(animationName)
|
||||
|
@ -289,7 +289,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
portrait?.attr('id', 'portrait').addClass('img-thumbnail')
|
||||
portrait.addClass 'img-thumbnail'
|
||||
$('#portrait').replaceWith(portrait)
|
||||
|
||||
|
||||
showLank: (lank) ->
|
||||
@clearDisplayObject()
|
||||
@clearLank()
|
||||
|
@ -306,7 +306,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
|
||||
clearDisplayObject: ->
|
||||
@topLayer.removeChild(@currentObject) if @currentObject?
|
||||
|
||||
|
||||
clearLank: ->
|
||||
@layerAdapter.removeLank(@currentLank) if @currentLank
|
||||
@currentLank?.destroy()
|
||||
|
@ -365,7 +365,8 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
url = "/editor/thang/#{newThangType.get('slug') or newThangType.id}"
|
||||
portraitSource = null
|
||||
if @thangType.get('raster')
|
||||
image = @currentLank.sprite.image
|
||||
#image = @currentLank.sprite.image # Doesn't work?
|
||||
image = @currentLank.sprite.spriteSheet._images[0]
|
||||
portraitSource = imageToPortrait image
|
||||
# bit of a hacky way to get that portrait
|
||||
success = =>
|
||||
|
@ -429,7 +430,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
obj = vectorParser.buildMovieClip(key) if type is 'animations'
|
||||
obj = vectorParser.buildContainerFromStore(key) if type is 'containers'
|
||||
obj = vectorParser.buildShapeFromStore(key) if type is 'shapes'
|
||||
|
||||
|
||||
bounds = obj?.bounds or obj?.nominalBounds
|
||||
if bounds
|
||||
@boundsBox = new createjs.Shape()
|
||||
|
@ -437,7 +438,7 @@ module.exports = class ThangTypeEditView extends RootView
|
|||
@topLayer.addChild(@boundsBox)
|
||||
obj.regX = @boundsBox.regX = bounds.x + bounds.width / 2
|
||||
obj.regY = @boundsBox.regY = bounds.y + bounds.height / 2
|
||||
|
||||
|
||||
@showSprite(obj) if obj
|
||||
@showingSelectedNode = true
|
||||
@currentLank?.destroy()
|
||||
|
|
|
@ -49,6 +49,7 @@ module.exports = class SimulateTabView extends CocoView
|
|||
fetchAndSimulateTaskOriginal = @simulator.fetchAndSimulateTask
|
||||
@simulator.fetchAndSimulateTask = =>
|
||||
if @simulator.simulatedByYou >= 5
|
||||
console.log '------------------- Destroying Simulator and making a new one -----------------'
|
||||
@simulator.destroy()
|
||||
@simulator = null
|
||||
@simulateNextGame()
|
||||
|
|
|
@ -455,8 +455,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
showVictory: ->
|
||||
options = {level: @level, supermodel: @supermodel, session: @session}
|
||||
ModalClass = if @level.get('type', true) in ['hero', 'hero-coop'] then HeroVictoryModal else VictoryModal
|
||||
# TODO: made HeroVictoryModal able to support hero-ladder and then switch over for that level type, too
|
||||
ModalClass = if @level.get('type', true) in ['hero', 'hero-ladder', 'hero-coop'] then HeroVictoryModal else VictoryModal
|
||||
victoryModal = new ModalClass(options)
|
||||
@openModalView(victoryModal)
|
||||
if me.get('anonymous')
|
||||
|
|
|
@ -6,6 +6,7 @@ CocoCollection = require 'collections/CocoCollection'
|
|||
LocalMongo = require 'lib/LocalMongo'
|
||||
utils = require 'lib/utils'
|
||||
ThangType = require 'models/ThangType'
|
||||
LadderSubmissionView = require 'views/play/common/LadderSubmissionView'
|
||||
|
||||
module.exports = class HeroVictoryModal extends ModalView
|
||||
id: 'hero-victory-modal'
|
||||
|
@ -13,6 +14,9 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
closeButton: false
|
||||
closesOnClickOutside: false
|
||||
|
||||
subscriptions:
|
||||
'ladder:game-submitted': 'onGameSubmitted'
|
||||
|
||||
constructor: (options) ->
|
||||
super(options)
|
||||
@session = options.session
|
||||
|
@ -88,6 +92,7 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
|
||||
c.thangTypes = @thangTypes
|
||||
c.me = me
|
||||
c.readyToRank = @level.get('type', true) is 'hero-ladder' and @session.readyToRank()
|
||||
return c
|
||||
|
||||
afterRender: ->
|
||||
|
@ -116,6 +121,9 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
panel.delay(500)
|
||||
panel.queue(-> complete())
|
||||
@animationComplete = not @animatedPanels.length
|
||||
if @level.get('type', true) is 'hero-ladder'
|
||||
@ladderSubmissionView = new LadderSubmissionView session: @session, level: @level
|
||||
@insertSubView @ladderSubmissionView, @$el.find('.ladder-submission-view')
|
||||
|
||||
beginAnimateNumbers: ->
|
||||
@numericalItemPanels = _.map(@animatedPanels.find('.numerical'), (panel) -> {
|
||||
|
@ -186,6 +194,11 @@ module.exports = class HeroVictoryModal extends ModalView
|
|||
@$el.find('#saving-progress-label').toggleClass('hide', @readyToContinue)
|
||||
@$el.find('#continue-button').toggleClass('hide', not @readyToContinue)
|
||||
|
||||
onGameSubmitted: (e) ->
|
||||
ladderURL = "/play/ladder/#{@level.get('slug')}#my-matches"
|
||||
Backbone.Mediator.publish 'router:navigate', route: ladderURL
|
||||
|
||||
|
||||
# TODO: award heroes/items and play an awesome sound when you get one
|
||||
|
||||
destroy: ->
|
||||
|
|
|
@ -40,6 +40,8 @@ module.exports = class Spell
|
|||
if @permissions.readwrite.length and sessionSource = @session.getSourceFor(@spellKey)
|
||||
if sessionSource isnt '// Should fill in some default source\n' # TODO: figure out why session is getting this default source in there and stop it
|
||||
@source = sessionSource
|
||||
if p.aiSource and not @otherSession and not @canWrite()
|
||||
@source = @originalSource = p.aiSource
|
||||
@thangs = {}
|
||||
if @canRead() # We can avoid creating these views if we'll never use them.
|
||||
@view = new SpellView {spell: @, level: options.level, session: @session, worker: @worker}
|
||||
|
|
|
@ -17,7 +17,8 @@ transpileLevelSession = (sessionID, cb) ->
|
|||
if err then return cb err
|
||||
submittedCode = session.submittedCode
|
||||
unless session.submittedCodeLanguage
|
||||
throw 'SUBMITTED CODE LANGUAGE DOESN\'T EXIST'
|
||||
console.log '\n\n\n#{i++} SUBMITTED CODE LANGUAGE DOESN\'T EXIST\n', session, '\n\n'
|
||||
return cb()
|
||||
else
|
||||
console.log "Transpiling code for session #{i++} #{session._id} in language #{session.submittedCodeLanguage}"
|
||||
transpiledCode = {}
|
||||
|
|
|
@ -124,7 +124,7 @@ module.exports.getTwoGames = (req, res) ->
|
|||
#if userIsAnonymous req then return errors.unauthorized(res, 'You need to be logged in to get games.')
|
||||
humansGameID = req.body.humansGameID
|
||||
ogresGameID = req.body.ogresGameID
|
||||
ladderGameIDs = ['greed', 'criss-cross', 'brawlwood', 'dungeon-arena', 'gold-rush', 'sky-span']
|
||||
ladderGameIDs = ['greed', 'criss-cross', 'brawlwood', 'dungeon-arena', 'gold-rush', 'sky-span', 'dueling-grounds', 'cavern-survival']
|
||||
levelID = _.sample ladderGameIDs
|
||||
unless ogresGameID and humansGameID
|
||||
#fetch random games here
|
||||
|
|
|
@ -98,7 +98,7 @@ describe 'LevelLoader', ->
|
|||
levelLoader.loadDependenciesForSession(session)
|
||||
requests = jasmine.Ajax.requests.all()
|
||||
urls = (r.url for r in requests)
|
||||
expect('/db/thang.type/gloves/version?project=name,components,original' in urls).toBeTruthy()
|
||||
expect('/db/thang.type/gloves/version?project=name,components,original,rasterIcon,kind' in urls).toBeTruthy()
|
||||
expect('/db/thang.type/anya/version' in urls).toBeTruthy()
|
||||
|
||||
it 'loads components for the hero in the heroConfig in the given session', ->
|
||||
|
@ -141,7 +141,7 @@ describe 'LevelLoader', ->
|
|||
jasmine.Ajax.requests.sendResponses(responses)
|
||||
requests = jasmine.Ajax.requests.all()
|
||||
urls = (r.url for r in requests)
|
||||
expect('/db/thang.type/mace/version?project=name,components,original' in urls).toBeTruthy()
|
||||
expect('/db/thang.type/mace/version?project=name,components,original,rasterIcon,kind' in urls).toBeTruthy()
|
||||
|
||||
it 'loads components which are inherited by level thangs from thang type default components', ->
|
||||
new LevelLoader({supermodel:new SuperModel(), sessionID: 'id', levelID: 'id'})
|
||||
|
@ -165,7 +165,7 @@ describe 'LevelLoader', ->
|
|||
jasmine.Ajax.requests.sendResponses(responses)
|
||||
requests = jasmine.Ajax.requests.all()
|
||||
urls = (r.url for r in requests)
|
||||
expect('/db/thang.type/wand/version?project=name,components,original' in urls).toBeTruthy()
|
||||
expect('/db/thang.type/wand/version?project=name,components,original,rasterIcon,kind' in urls).toBeTruthy()
|
||||
|
||||
it 'loads components for item thang types which are inherited by level thangs from thang type default equips component configs', ->
|
||||
new LevelLoader({supermodel:new SuperModel(), sessionID: 'id', levelID: 'id'})
|
||||
|
@ -173,7 +173,7 @@ describe 'LevelLoader', ->
|
|||
responses =
|
||||
'/db/level/id': levelWithShaman
|
||||
'/db/thang.type/names': [thangTypeShamanWithWandEquipped]
|
||||
'/db/thang.type/wand/version?project=name,components,original': thangTypeWand
|
||||
'/db/thang.type/wand/version?project=name,components,original,rasterIcon,kind': thangTypeWand
|
||||
|
||||
jasmine.Ajax.requests.sendResponses(responses)
|
||||
requests = jasmine.Ajax.requests.all()
|
||||
|
|
|
@ -10,7 +10,7 @@ describe 'Problem', ->
|
|||
addMarker: ->
|
||||
}
|
||||
}
|
||||
aether = {
|
||||
aether = {
|
||||
raw: "this.say('hi');\nthis.sad('bye');"
|
||||
language: { id: 'javascript' }
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ describe 'Problem', ->
|
|||
}
|
||||
levelID = 'awesome'
|
||||
|
||||
it 'save user code problem', ->
|
||||
# TODO: Problems are no longer saved when creating Problems; instead it's in SpellView. Update tests?
|
||||
xit 'save user code problem', ->
|
||||
new Problem aether, aetherProblem, ace, false, true, levelID
|
||||
expect(jasmine.Ajax.requests.count()).toBe(1)
|
||||
|
||||
|
@ -46,7 +47,7 @@ describe 'Problem', ->
|
|||
expect(params.language).toEqual(aether.language.id)
|
||||
expect(params.levelID).toEqual(levelID)
|
||||
|
||||
it 'save user code problem no range', ->
|
||||
xit 'save user code problem no range', ->
|
||||
aetherProblem.range = null
|
||||
new Problem aether, aetherProblem, ace, false, true, levelID
|
||||
expect(jasmine.Ajax.requests.count()).toBe(1)
|
||||
|
@ -68,7 +69,7 @@ describe 'Problem', ->
|
|||
expect(params.codeSnippet).toBeUndefined()
|
||||
expect(params.errRange).toBeUndefined()
|
||||
|
||||
it 'save user code problem multi-line snippet', ->
|
||||
xit 'save user code problem multi-line snippet', ->
|
||||
aether.raw = "this.say('hi');\nthis.sad\n('bye');"
|
||||
aetherProblem.range = [ { row: 1 }, { row: 2 } ]
|
||||
|
||||
|
|
Loading…
Reference in a new issue