mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-18 01:11:46 -05:00
Merge branch 'master' into production
This commit is contained in:
commit
b9bd3c6388
13 changed files with 40 additions and 23 deletions
|
@ -89,6 +89,8 @@ module.exports = class LevelLoader extends CocoClass
|
|||
@listenToOnce @opponentSession, 'sync', @loadDependenciesForSession
|
||||
|
||||
loadDependenciesForSession: (session) ->
|
||||
if session is @session
|
||||
Backbone.Mediator.publish 'level:session-loaded', level: @level, session: @session
|
||||
return unless @level.get('type', true) is 'hero'
|
||||
heroConfig = session.get('heroConfig')
|
||||
heroConfig ?= me.get('heroConfig')
|
||||
|
@ -101,8 +103,6 @@ module.exports = class LevelLoader extends CocoClass
|
|||
url = "/db/thang.type/#{itemThangType}/version?project=name,components,original"
|
||||
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang')
|
||||
|
||||
if session is @session
|
||||
Backbone.Mediator.publish 'level:session-loaded', level: @level, session: @session
|
||||
|
||||
# Grabbing the rest of the required data for the level
|
||||
|
||||
|
|
|
@ -295,7 +295,7 @@ module.exports = class ThangType extends CocoModel
|
|||
for stat, modifiers of itemConfig.stats ? {}
|
||||
stats[stat] = @formatStatDisplay stat, modifiers
|
||||
for stat in itemConfig.extraHUDProperties ? []
|
||||
stats[stat] = null # Find it in the other Components.
|
||||
stats[stat] ?= null # Find it in the other Components.
|
||||
for component in components
|
||||
continue unless config = component.config
|
||||
for stat, value of stats when not value?
|
||||
|
@ -307,6 +307,8 @@ module.exports = class ThangType extends CocoModel
|
|||
stats[stat].display += " (#{dps} DPS)"
|
||||
if config.programmableSnippets
|
||||
props = props.concat config.programmableSnippets
|
||||
for stat, value of stats when not value?
|
||||
stats[stat] = name: stat, display: '???'
|
||||
props: props, stats: stats
|
||||
|
||||
formatStatDisplay: (name, modifiers) ->
|
||||
|
|
|
@ -23,8 +23,6 @@ $level-resize-transition-time: 0.5s
|
|||
width: 100%
|
||||
button, h4
|
||||
display: none
|
||||
#stop-real-time-playback-button
|
||||
display: block
|
||||
#playback-view
|
||||
$flags-width: 200px
|
||||
width: 90%
|
||||
|
@ -40,6 +38,8 @@ $level-resize-transition-time: 0.5s
|
|||
left: 20%
|
||||
width: 60%
|
||||
text-align: center
|
||||
#stop-real-time-playback-button
|
||||
display: block
|
||||
|
||||
.level-content
|
||||
margin: 0px auto
|
||||
|
@ -200,6 +200,14 @@ $level-resize-transition-time: 0.5s
|
|||
top: 0
|
||||
z-index: 19
|
||||
|
||||
#stop-real-time-playback-button
|
||||
display: none
|
||||
position: absolute
|
||||
bottom: 40px
|
||||
right: 15px
|
||||
font-size: 30px
|
||||
|
||||
|
||||
html.fullscreen-editor
|
||||
#level-view
|
||||
#fullscreen-editor-background-screen
|
||||
|
|
|
@ -41,5 +41,5 @@
|
|||
height: 24px
|
||||
|
||||
|
||||
#level-done-button, #stop-real-time-playback-button
|
||||
#level-done-button
|
||||
display: none
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
|
||||
#thang-hud
|
||||
|
||||
button.btn.btn-lg.btn-warning.banner.header-font#stop-real-time-playback-button(title="Stop real-time playback", data-i18n="play_level.stop") Stop
|
||||
|
||||
.footer
|
||||
.content
|
||||
p(class='footer-link-text')
|
||||
|
|
|
@ -19,10 +19,6 @@ h4.title
|
|||
if !found
|
||||
span.spl.spr - waiting...
|
||||
|
||||
|
||||
|
||||
button.btn.btn-xs.btn-warning.banner#stop-real-time-playback-button(title="Stop real-time playback", data-i18n="play_level.stop") Stop
|
||||
|
||||
button.btn.btn-xs.btn-inverse.banner#game-menu-button(title="Show game menu", data-i18n="play_level.game_menu") Game Menu
|
||||
|
||||
button.btn.btn-xs.btn-success.banner#docs-button(title="Show level instructions", data-i18n="play_level.guide") Guide
|
||||
|
|
|
@ -53,10 +53,12 @@ module.exports = class GameMenuModal extends ModalView
|
|||
updateConfig: ->
|
||||
sessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
|
||||
lastHeroConfig = me.get('heroConfig') ? {}
|
||||
thangType = @subviews.choose_hero_view.selectedHero.get 'original'
|
||||
thangType = @subviews.choose_hero_view.selectedHero?.get 'original'
|
||||
inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
|
||||
patchSession = patchMe = false
|
||||
props = thangType: thangType, inventory: inventory
|
||||
props = {}
|
||||
props.thangType = thangType if thangType
|
||||
props.inventory = inventory if _.size inventory
|
||||
for key, val of props when val
|
||||
patchSession ||= not _.isEqual val, sessionHeroConfig[key]
|
||||
patchMe ||= not _.isEqual val, lastHeroConfig[key]
|
||||
|
@ -69,6 +71,7 @@ module.exports = class GameMenuModal extends ModalView
|
|||
aceConfig = me.get('aceConfig', true) ? {}
|
||||
aceConfig.language = codeLanguage
|
||||
me.set 'aceConfig', aceConfig
|
||||
console.log 'update config from game menu modal; props:', props, 'patch session?', patchSession, 'patch me?', patchMe
|
||||
if patchSession
|
||||
@options.session.set 'heroConfig', sessionHeroConfig
|
||||
success = ->
|
||||
|
|
|
@ -140,7 +140,7 @@ module.exports = class InventoryView extends CocoView
|
|||
@onSelectionChanged()
|
||||
|
||||
onAvailableItemDoubleClick: (e) ->
|
||||
@selectAvailableItem $(e.target).closest('.list-group-item')
|
||||
@selectAvailableItem $(e.target).closest('.list-group-item') if e
|
||||
@onSelectionChanged()
|
||||
slot = @getSelectedSlot()
|
||||
slot = @$el.find('.item-slot:not(.disabled):first') if not slot.length
|
||||
|
@ -295,6 +295,7 @@ module.exports = class InventoryView extends CocoView
|
|||
'simple-boots': '53e237bf53457600003e3f05'
|
||||
'longsword': '53e218d853457600003e3ebe'
|
||||
'leather-tunic': '53e22eac53457600003e3efc'
|
||||
#'leather-boots': '53e2384453457600003e3f07'
|
||||
'programmaticon-i': '53e4108204c00d4607a89f78'
|
||||
'crude-glasses': '53e238df53457600003e3f0b'
|
||||
'builders-hammer': '53f4e6e3d822c23505b74f42'
|
||||
|
|
|
@ -24,8 +24,6 @@ module.exports = class ControlBarView extends CocoView
|
|||
|
||||
'click #game-menu-button': 'showGameMenuModal'
|
||||
|
||||
'click #stop-real-time-playback-button': -> Backbone.Mediator.publish 'playback:stop-real-time-playback', {}
|
||||
|
||||
'click': -> Backbone.Mediator.publish 'tome:focus-editor', {}
|
||||
|
||||
constructor: (options) ->
|
||||
|
|
|
@ -77,6 +77,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
events:
|
||||
'click #level-done-button': 'onDonePressed'
|
||||
'click #stop-real-time-playback-button': -> Backbone.Mediator.publish 'playback:stop-real-time-playback', {}
|
||||
'click #fullscreen-editor-background-screen': (e) -> Backbone.Mediator.publish 'tome:toggle-maximize', {}
|
||||
|
||||
shortcuts:
|
||||
|
@ -361,7 +362,8 @@ module.exports = class PlayLevelView extends RootView
|
|||
AudioPlayer.preloadSound src
|
||||
Backbone.Mediator.subscribeOnce 'audio-player:loaded', @playAmbientSound, @
|
||||
return
|
||||
@ambientSound = createjs.Sound.play src, loop: -1
|
||||
@ambientSound = createjs.Sound.play src, loop: -1, volume: 0.1
|
||||
createjs.Tween.get(@ambientSound).to({volume: 1.0}, 10000)
|
||||
|
||||
restoreSessionState: ->
|
||||
return if @alreadyLoadedState
|
||||
|
@ -617,7 +619,7 @@ module.exports = class PlayLevelView extends RootView
|
|||
|
||||
onSubmissionComplete: =>
|
||||
return if @destroyed
|
||||
@showVictory() if @goalManager.checkOverallStatus() is 'success'
|
||||
Backbone.Mediator.publish 'level:show-victory', showModal: true if @goalManager.checkOverallStatus() is 'success'
|
||||
|
||||
destroy: ->
|
||||
@levelLoader?.destroy()
|
||||
|
@ -625,7 +627,9 @@ module.exports = class PlayLevelView extends RootView
|
|||
@god?.destroy()
|
||||
@goalManager?.destroy()
|
||||
@scriptManager?.destroy()
|
||||
@ambientSound?.stop()
|
||||
if ambientSound = @ambientSound
|
||||
# Doesn't seem to work; stops immediately.
|
||||
createjs.Tween.get(ambientSound).to({volume: 0.0}, 1500).call -> ambientSound.stop()
|
||||
$(window).off 'resize', @onWindowResize
|
||||
delete window.world # not sure where this is set, but this is one way to clean it up
|
||||
clearInterval(@pointerInterval)
|
||||
|
|
|
@ -51,7 +51,7 @@ AchievablePlugin = (schema, options) ->
|
|||
achievement: achievement._id.toHexString()
|
||||
achievementName: achievement.get 'name'
|
||||
|
||||
worth = achievement.get('worth')
|
||||
worth = achievement.get('worth') ? 10
|
||||
earnedPoints = 0
|
||||
wrapUp = ->
|
||||
# Update user's experience points
|
||||
|
|
|
@ -74,7 +74,10 @@ module.exports.setup = (app) ->
|
|||
|
||||
sendSelf = (req, res) ->
|
||||
res.setHeader('Content-Type', 'text/json')
|
||||
res.send(UserHandler.formatEntity(req, req.user))
|
||||
if req.query.callback
|
||||
res.jsonp UserHandler.formatEntity(req, req.user, true)
|
||||
else
|
||||
res.send UserHandler.formatEntity(req, req.user, false)
|
||||
res.end()
|
||||
|
||||
app.post('/auth/logout', (req, res) ->
|
||||
|
|
|
@ -30,13 +30,13 @@ UserHandler = class UserHandler extends Handler
|
|||
props.push @privateProperties... if req.user.isAdmin() # Admins are mad with power
|
||||
props
|
||||
|
||||
formatEntity: (req, document) =>
|
||||
formatEntity: (req, document, publicOnly=false) =>
|
||||
return null unless document?
|
||||
obj = document.toObject()
|
||||
delete obj[prop] for prop in serverProperties
|
||||
includePrivates = req.user and (req.user.isAdmin() or req.user._id.equals(document._id))
|
||||
includePrivates = not publicOnly and (req.user and (req.user.isAdmin() or req.user._id.equals(document._id)))
|
||||
delete obj[prop] for prop in @privateProperties unless includePrivates
|
||||
includeCandidate = includePrivates or (obj.jobProfile?.active and req.user and ('employer' in (req.user.get('permissions') ? [])) and @employerCanViewCandidate req.user, obj)
|
||||
includeCandidate = not publicOnly and (includePrivates or (obj.jobProfile?.active and req.user and ('employer' in (req.user.get('permissions') ? [])) and @employerCanViewCandidate req.user, obj))
|
||||
delete obj[prop] for prop in candidateProperties unless includeCandidate
|
||||
return obj
|
||||
|
||||
|
|
Loading…
Reference in a new issue