Skip to content

Commit

Permalink
Merge pull request #166 from Dahlgren/bugfix/mission-rotation-difficulty
Browse files Browse the repository at this point in the history
Set default mission rotation difficulty as server difficulty
  • Loading branch information
Dahlgren authored Aug 10, 2020
2 parents 9301bda + 7a9d505 commit f5eb892
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
9 changes: 9 additions & 0 deletions public/js/app/models/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@ module.exports = Backbone.Model.extend({
}
}
})
},

missionDifficulty: function () {
var serverDifficulty = this.get('forcedDifficulty')
if (serverDifficulty) {
return serverDifficulty.toLowerCase()
}

return undefined
}
})
12 changes: 10 additions & 2 deletions public/js/app/views/servers/missions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
8 changes: 7 additions & 1 deletion public/js/app/views/servers/missions/rotation/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}))
}
})

0 comments on commit f5eb892

Please sign in to comment.