Fix for earned achievement default null worths. Misc other fixes.

This commit is contained in:
Nick Winter 2014-09-22 20:15:51 -07:00
parent 786820e056
commit 1b4e75e7e8
5 changed files with 23 additions and 17 deletions

View file

@ -89,6 +89,8 @@ module.exports = class LevelLoader extends CocoClass
@listenToOnce @opponentSession, 'sync', @loadDependenciesForSession @listenToOnce @opponentSession, 'sync', @loadDependenciesForSession
loadDependenciesForSession: (session) -> loadDependenciesForSession: (session) ->
if session is @session
Backbone.Mediator.publish 'level:session-loaded', level: @level, session: @session
return unless @level.get('type', true) is 'hero' return unless @level.get('type', true) is 'hero'
heroConfig = session.get('heroConfig') heroConfig = session.get('heroConfig')
heroConfig ?= me.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" url = "/db/thang.type/#{itemThangType}/version?project=name,components,original"
@worldNecessities.push @maybeLoadURL(url, ThangType, 'thang') @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 # Grabbing the rest of the required data for the level

View file

@ -53,10 +53,12 @@ module.exports = class GameMenuModal extends ModalView
updateConfig: -> updateConfig: ->
sessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {}) sessionHeroConfig = $.extend {}, true, (@options.session.get('heroConfig') ? {})
lastHeroConfig = me.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() inventory = @subviews.inventory_view.getCurrentEquipmentConfig()
patchSession = patchMe = false 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 for key, val of props when val
patchSession ||= not _.isEqual val, sessionHeroConfig[key] patchSession ||= not _.isEqual val, sessionHeroConfig[key]
patchMe ||= not _.isEqual val, lastHeroConfig[key] patchMe ||= not _.isEqual val, lastHeroConfig[key]
@ -69,6 +71,7 @@ module.exports = class GameMenuModal extends ModalView
aceConfig = me.get('aceConfig', true) ? {} aceConfig = me.get('aceConfig', true) ? {}
aceConfig.language = codeLanguage aceConfig.language = codeLanguage
me.set 'aceConfig', aceConfig me.set 'aceConfig', aceConfig
console.log 'update config from game menu modal; props:', props, 'patch session?', patchSession, 'patch me?', patchMe
if patchSession if patchSession
@options.session.set 'heroConfig', sessionHeroConfig @options.session.set 'heroConfig', sessionHeroConfig
success = -> success = ->

View file

@ -295,7 +295,7 @@ module.exports = class InventoryView extends CocoView
'simple-boots': '53e237bf53457600003e3f05' 'simple-boots': '53e237bf53457600003e3f05'
'longsword': '53e218d853457600003e3ebe' 'longsword': '53e218d853457600003e3ebe'
'leather-tunic': '53e22eac53457600003e3efc' 'leather-tunic': '53e22eac53457600003e3efc'
'leather-boots': '53e2384453457600003e3f07' #'leather-boots': '53e2384453457600003e3f07'
'programmaticon-i': '53e4108204c00d4607a89f78' 'programmaticon-i': '53e4108204c00d4607a89f78'
'crude-glasses': '53e238df53457600003e3f0b' 'crude-glasses': '53e238df53457600003e3f0b'
'builders-hammer': '53f4e6e3d822c23505b74f42' 'builders-hammer': '53f4e6e3d822c23505b74f42'
@ -305,14 +305,14 @@ module.exports = class InventoryView extends CocoView
'shadow-guard': {feet: 'simple-boots'} 'shadow-guard': {feet: 'simple-boots'}
'true-names': {feet: 'simple-boots', 'right-hand': 'longsword'} 'true-names': {feet: 'simple-boots', 'right-hand': 'longsword'}
'the-raised-sword': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic'} 'the-raised-sword': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic'}
'the-first-kithmaze': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'} 'the-first-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'the-second-kithmaze': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'} 'the-second-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'new-sight': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'} 'new-sight': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i'}
'lowly-kithmen': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'} 'lowly-kithmen': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'a-bolt-in-the-dark': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'} 'a-bolt-in-the-dark': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'the-final-kithmaze': {feet: 'leather-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'} 'the-final-kithmaze': {feet: 'simple-boots', 'right-hand': 'longsword', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'kithgard-gates': {feet: 'leather-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'} 'kithgard-gates': {feet: 'simple-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
'defence-of-plainswood': {feet: 'leather-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'} 'defence-of-plainswood': {feet: 'simple-boots', 'right-hand': 'builders-hammer', torso: 'leather-tunic', 'programming-book': 'programmaticon-i', eyes: 'crude-glasses'}
necessaryGear = gearByLevel[@options.levelID] necessaryGear = gearByLevel[@options.levelID]
for slot, item of necessaryGear ? {} for slot, item of necessaryGear ? {}
@equipment[slot] ?= gear[item] @equipment[slot] ?= gear[item]

View file

@ -362,7 +362,8 @@ module.exports = class PlayLevelView extends RootView
AudioPlayer.preloadSound src AudioPlayer.preloadSound src
Backbone.Mediator.subscribeOnce 'audio-player:loaded', @playAmbientSound, @ Backbone.Mediator.subscribeOnce 'audio-player:loaded', @playAmbientSound, @
return 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: -> restoreSessionState: ->
return if @alreadyLoadedState return if @alreadyLoadedState
@ -618,7 +619,7 @@ module.exports = class PlayLevelView extends RootView
onSubmissionComplete: => onSubmissionComplete: =>
return if @destroyed return if @destroyed
@showVictory() if @goalManager.checkOverallStatus() is 'success' Backbone.Mediator.publish 'level:show-victory', showModal: true if @goalManager.checkOverallStatus() is 'success'
destroy: -> destroy: ->
@levelLoader?.destroy() @levelLoader?.destroy()
@ -626,7 +627,9 @@ module.exports = class PlayLevelView extends RootView
@god?.destroy() @god?.destroy()
@goalManager?.destroy() @goalManager?.destroy()
@scriptManager?.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 $(window).off 'resize', @onWindowResize
delete window.world # not sure where this is set, but this is one way to clean it up delete window.world # not sure where this is set, but this is one way to clean it up
clearInterval(@pointerInterval) clearInterval(@pointerInterval)

View file

@ -51,7 +51,7 @@ AchievablePlugin = (schema, options) ->
achievement: achievement._id.toHexString() achievement: achievement._id.toHexString()
achievementName: achievement.get 'name' achievementName: achievement.get 'name'
worth = achievement.get('worth') worth = achievement.get('worth') ? 10
earnedPoints = 0 earnedPoints = 0
wrapUp = -> wrapUp = ->
# Update user's experience points # Update user's experience points