2014-11-28 20:49:41 -05:00
|
|
|
{hslToHex} = require 'core/utils'
|
2014-03-02 15:43:21 -05:00
|
|
|
|
|
|
|
module.exports.teamDataFromLevel = (level) ->
|
2014-10-18 17:51:43 -04:00
|
|
|
alliedSystem = _.find level.get('systems', true), (value) -> value.config?.teams?
|
2014-03-02 15:43:21 -05:00
|
|
|
teamNames = (teamName for teamName, teamConfig of alliedSystem.config.teams when teamConfig.playable)
|
|
|
|
teamConfigs = alliedSystem.config.teams
|
|
|
|
|
|
|
|
teams = []
|
|
|
|
for team in teamNames or []
|
|
|
|
otherTeam = if team is 'ogres' then 'humans' else 'ogres'
|
|
|
|
color = teamConfigs[team].color
|
|
|
|
bgColor = hslToHex([color.hue, color.saturation, color.lightness + (1 - color.lightness) * 0.5])
|
|
|
|
primaryColor = hslToHex([color.hue, 0.5, 0.5])
|
2015-11-19 17:47:25 -05:00
|
|
|
if level.get('slug') in ['wakka-maul']
|
|
|
|
displayName = _.string.titleize(team)
|
|
|
|
else
|
|
|
|
displayName = $.i18n.t("ladder.#{team}") # Use Red/Blue instead of Humans/Ogres
|
2014-03-02 15:43:21 -05:00
|
|
|
teams.push({
|
|
|
|
id: team
|
|
|
|
name: _.string.titleize(team)
|
2015-11-19 17:47:25 -05:00
|
|
|
displayName: displayName
|
2014-03-02 15:43:21 -05:00
|
|
|
otherTeam: otherTeam
|
2015-09-03 18:46:56 -04:00
|
|
|
otherTeamDisplayName: $.i18n.t("ladder.#{otherTeam}")
|
2014-03-02 15:43:21 -05:00
|
|
|
bgColor: bgColor
|
|
|
|
primaryColor: primaryColor
|
|
|
|
})
|
|
|
|
|
2014-06-30 22:16:26 -04:00
|
|
|
teams
|