Merge pull request #166 from Dahlgren/bugfix/mission-rotation-difficulty

Set default mission rotation difficulty as server difficulty
This commit is contained in:
Björn Dahlgren 2020-08-10 08:34:27 +02:00 committed by GitHub
commit f5eb892291
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View File

@ -62,5 +62,14 @@ module.exports = Backbone.Model.extend({
}
}
})
},
missionDifficulty: function () {
var serverDifficulty = this.get('forcedDifficulty')
if (serverDifficulty) {
return serverDifficulty.toLowerCase()
}
return undefined
}
})

View File

@ -35,13 +35,21 @@ module.exports = Marionette.LayoutView.extend({
var self = this
this.availableListView = new AvailableListView({ collection: this.missions, filterValue: this.filterValue })
this.availableListView = new AvailableListView({
collection: this.missions,
filterValue: this.filterValue
})
this.availableListView.on('add', function (model) {
self.rotationCollection.add([{
difficulty: self.model.missionDifficulty(),
name: model.get('name').replace('.pbo', '')
}])
})
this.rotationListView = new RotationListView({ collection: this.rotationCollection })
this.rotationListView = new RotationListView({
collection: this.rotationCollection,
server: this.model
})
},
onRender: function () {

View File

@ -14,8 +14,14 @@ module.exports = Marionette.CompositeView.extend({
'click .add-mission': 'addMission'
},
initialize: function (options) {
this.server = options.server
},
addMission: function (e) {
e.preventDefault()
this.collection.add(new MissionRotation())
this.collection.add(new MissionRotation({
difficulty: this.server.missionDifficulty()
}))
}
})