diff --git a/app/models/ThangType.coffee b/app/models/ThangType.coffee index 00065b3ed..62f9eaa4e 100644 --- a/app/models/ThangType.coffee +++ b/app/models/ThangType.coffee @@ -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 \ No newline at end of file + @loadUniversalWizard: -> + return @wizardType if @wizardType + wizOriginal = "52a00d55cf1818f2be00000b" + url = "/db/thang_type/#{wizOriginal}/version" + @wizardType = new module.exports() + @wizardType.url = -> url + @wizardType.fetch() + @wizardType \ No newline at end of file diff --git a/app/views/home_view.coffee b/app/views/home_view.coffee index a16c1a9ba..3d9f30db2 100644 --- a/app/views/home_view.coffee +++ b/app/views/home_view.coffee @@ -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() diff --git a/app/views/play/ladder/play_modal.coffee b/app/views/play/ladder/play_modal.coffee index 5ef5fc74c..30c3a116d 100644 --- a/app/views/play/ladder/play_modal.coffee +++ b/app/views/play/ladder/play_modal.coffee @@ -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