mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Refactored the universal wizard loading to happen silently when you import ThangType.
This commit is contained in:
parent
feaeb1dc98
commit
0d054bec8e
3 changed files with 21 additions and 13 deletions
|
@ -214,9 +214,11 @@ module.exports = class ThangType extends CocoModel
|
|||
onFileUploaded: =>
|
||||
console.log 'Image uploaded'
|
||||
|
||||
wizOriginal = "52a00d55cf1818f2be00000b"
|
||||
url = "/db/thang_type/#{wizOriginal}/version"
|
||||
wizardType = new module.exports()
|
||||
wizardType.url = -> url
|
||||
wizardType.fetch()
|
||||
module.exports.wizardType = wizardType
|
||||
@loadUniversalWizard: ->
|
||||
return @wizardType if @wizardType
|
||||
wizOriginal = "52a00d55cf1818f2be00000b"
|
||||
url = "/db/thang_type/#{wizOriginal}/version"
|
||||
@wizardType = new module.exports()
|
||||
@wizardType.url = -> url
|
||||
@wizardType.fetch()
|
||||
@wizardType
|
|
@ -11,6 +11,10 @@ module.exports = class HomeView extends View
|
|||
events:
|
||||
'mouseover #beginner-campaign': 'onMouseOverButton'
|
||||
'mouseout #beginner-campaign': 'onMouseOutButton'
|
||||
|
||||
constructor: ->
|
||||
super(arguments...)
|
||||
ThangType.loadUniversalWizard()
|
||||
|
||||
getRenderData: ->
|
||||
c = super()
|
||||
|
|
|
@ -8,14 +8,14 @@ module.exports = class LadderPlayModal extends View
|
|||
id: "ladder-play-modal"
|
||||
template: template
|
||||
closeButton: true
|
||||
startsLoading = true
|
||||
startsLoading: true
|
||||
|
||||
constructor: (options, @level, @session, @team) ->
|
||||
super(options)
|
||||
@nameMap = {}
|
||||
@otherTeam = if team is 'ogres' then 'humans' else 'ogres'
|
||||
@startLoadingChallengersMaybe()
|
||||
@wizardType = ThangType.wizardType
|
||||
@wizardType = ThangType.loadUniversalWizard()
|
||||
|
||||
# PART 1: Load challengers from the db unless some are in the matches
|
||||
|
||||
|
@ -66,15 +66,17 @@ module.exports = class LadderPlayModal extends View
|
|||
|
||||
ctx.challengers = @challengers or {}
|
||||
for challenger in _.values ctx.challengers
|
||||
continue unless challenger
|
||||
continue unless challenger and @wizardType.loaded
|
||||
if (not challenger.opponentImageSource) and challenger.opponentWizard?.colorConfig
|
||||
challenger.opponentImageSource = @wizardType.getPortraitSource(
|
||||
{colorConfig: challenger.opponentWizard.colorConfig})
|
||||
|
||||
ctx.genericPortrait = @wizardType.getPortraitSource()
|
||||
|
||||
if @wizardType.loaded
|
||||
ctx.genericPortrait = @wizardType.getPortraitSource()
|
||||
myColorConfig = me.get('wizard')?.colorConfig
|
||||
ctx.myPortrait = if myColorConfig then @wizardType.getPortraitSource({colorConfig: myColorConfig}) else ctx.genericPortrait
|
||||
|
||||
ctx.myName = me.get('name') || 'Newcomer'
|
||||
myColorConfig = me.get('wizard')?.colorConfig
|
||||
ctx.myPortrait = if myColorConfig then @wizardType.getPortraitSource({colorConfig: myColorConfig}) else ctx.genericPortrait
|
||||
ctx
|
||||
|
||||
# Choosing challengers
|
||||
|
|
Loading…
Reference in a new issue