Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/common/gamedescription.js
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | if (playerDescriptions.observer) | ||||
})); | })); | ||||
return teamDescription.join("\n\n"); | return teamDescription.join("\n\n"); | ||||
} | } | ||||
/** | /** | ||||
* Sets an additional map label, map preview image and describes the chosen game settings more closely. | * Sets an additional map label, map preview image and describes the chosen game settings more closely. | ||||
* | * | ||||
* Requires g_GameAttributes and g_VictoryConditions. | * Requires g_VictoryConditions. | ||||
* | |||||
* @param gameSettings - Serialised-format/JSON game settings. | |||||
* (this takes serialised data to avoid loadings the gamesettings in the session GUI page) | |||||
*/ | */ | ||||
function getGameDescription(mapCache) | function getGameDescription(gameSettings, mapCache) | ||||
{ | { | ||||
let titles = []; | let titles = []; | ||||
if (!g_GameAttributes.settings.VictoryConditions.length) | if (!gameSettings.settings.VictoryConditions.length) | ||||
titles.push({ | titles.push({ | ||||
"label": translateWithContext("victory condition", "Endless Game"), | "label": translateWithContext("victory condition", "Endless Game"), | ||||
"value": translate("No winner will be determined, even if everyone is defeated.") | "value": translate("No winner will be determined, even if everyone is defeated.") | ||||
}); | }); | ||||
for (let victoryCondition of g_VictoryConditions) | for (let victoryCondition of g_VictoryConditions) | ||||
{ | { | ||||
if (g_GameAttributes.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | if (gameSettings.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | ||||
continue; | continue; | ||||
let title = translateVictoryCondition(victoryCondition.Name); | let title = translateVictoryCondition(victoryCondition.Name); | ||||
if (victoryCondition.Name == "wonder") | if (victoryCondition.Name == "wonder") | ||||
{ | { | ||||
let wonderDuration = Math.round(g_GameAttributes.settings.WonderDuration); | let wonderDuration = Math.round(gameSettings.settings.WonderDuration); | ||||
title = sprintf( | title = sprintf( | ||||
translatePluralWithContext( | translatePluralWithContext( | ||||
"victory condition", | "victory condition", | ||||
"Wonder (%(min)s minute)", | "Wonder (%(min)s minute)", | ||||
"Wonder (%(min)s minutes)", | "Wonder (%(min)s minutes)", | ||||
wonderDuration | wonderDuration | ||||
), | ), | ||||
{ "min": wonderDuration }); | { "min": wonderDuration }); | ||||
} | } | ||||
let isCaptureTheRelic = victoryCondition.Name == "capture_the_relic"; | let isCaptureTheRelic = victoryCondition.Name == "capture_the_relic"; | ||||
if (isCaptureTheRelic) | if (isCaptureTheRelic) | ||||
{ | { | ||||
let relicDuration = Math.round(g_GameAttributes.settings.RelicDuration); | let relicDuration = Math.round(gameSettings.settings.RelicDuration); | ||||
title = sprintf( | title = sprintf( | ||||
translatePluralWithContext( | translatePluralWithContext( | ||||
"victory condition", | "victory condition", | ||||
"Capture the Relic (%(min)s minute)", | "Capture the Relic (%(min)s minute)", | ||||
"Capture the Relic (%(min)s minutes)", | "Capture the Relic (%(min)s minutes)", | ||||
relicDuration | relicDuration | ||||
), | ), | ||||
{ "min": relicDuration }); | { "min": relicDuration }); | ||||
} | } | ||||
titles.push({ | titles.push({ | ||||
"label": title, | "label": title, | ||||
"value": victoryCondition.Description | "value": victoryCondition.Description | ||||
}); | }); | ||||
if (isCaptureTheRelic) | if (isCaptureTheRelic) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Relic Count"), | "label": translate("Relic Count"), | ||||
"value": Math.round(g_GameAttributes.settings.RelicCount) | "value": Math.round(gameSettings.settings.RelicCount) | ||||
}); | }); | ||||
if (victoryCondition.Name == "regicide") | if (victoryCondition.Name == "regicide") | ||||
if (g_GameAttributes.settings.RegicideGarrison) | if (gameSettings.settings.RegicideGarrison) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Hero Garrison"), | "label": translate("Hero Garrison"), | ||||
"value": translate("Heroes can be garrisoned.") | "value": translate("Heroes can be garrisoned.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Exposed Heroes"), | "label": translate("Exposed Heroes"), | ||||
"value": translate("Heroes cannot be garrisoned and they are vulnerable to raids.") | "value": translate("Heroes cannot be garrisoned and they are vulnerable to raids.") | ||||
}); | }); | ||||
} | } | ||||
if (g_GameAttributes.settings.RatingEnabled && | if (gameSettings.settings.RatingEnabled && | ||||
g_GameAttributes.settings.PlayerData.length == 2) | gameSettings.settings.PlayerData.length == 2) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Rated game"), | "label": translate("Rated game"), | ||||
"value": translate("When the winner of this match is determined, the lobby score will be adapted.") | "value": translate("When the winner of this match is determined, the lobby score will be adapted.") | ||||
}); | }); | ||||
if (g_GameAttributes.settings.LockTeams) | if (gameSettings.settings.LockTeams) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Locked Teams"), | "label": translate("Locked Teams"), | ||||
"value": translate("Players can't change the initial teams.") | "value": translate("Players can't change the initial teams.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Diplomacy"), | "label": translate("Diplomacy"), | ||||
"value": translate("Players can make alliances and declare war on allies.") | "value": translate("Players can make alliances and declare war on allies.") | ||||
}); | }); | ||||
if (g_GameAttributes.settings.LastManStanding) | if (gameSettings.settings.LastManStanding) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Last Man Standing"), | "label": translate("Last Man Standing"), | ||||
"value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.") | "value": translate("Only one player can win the game. If the remaining players are allies, the game continues until only one remains.") | ||||
}); | }); | ||||
else | else | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Allied Victory"), | "label": translate("Allied Victory"), | ||||
"value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.") | "value": translate("If one player wins, his or her allies win too. If one group of allies remains, they win.") | ||||
}); | }); | ||||
let ceasefire = Math.round(g_GameAttributes.settings.Ceasefire); | let ceasefire = Math.round(gameSettings.settings.Ceasefire); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Ceasefire"), | "label": translate("Ceasefire"), | ||||
"value": | "value": | ||||
ceasefire == 0 ? | !ceasefire ? | ||||
translate("disabled") : | translate("disabled") : | ||||
sprintf(translatePlural( | sprintf(translatePlural( | ||||
"For the first minute, other players will stay neutral.", | "For the first minute, other players will stay neutral.", | ||||
"For the first %(min)s minutes, other players will stay neutral.", | "For the first %(min)s minutes, other players will stay neutral.", | ||||
ceasefire), | ceasefire), | ||||
{ "min": ceasefire }) | { "min": ceasefire }) | ||||
}); | }); | ||||
if (g_GameAttributes.map == "random") | if (gameSettings.map == "random") | ||||
titles.push({ | titles.push({ | ||||
"label": translateWithContext("Map Selection", "Random Map"), | "label": translateWithContext("Map Selection", "Random Map"), | ||||
"value": translate("Randomly select a map from the list.") | "value": translate("Randomly select a map from the list.") | ||||
}); | }); | ||||
else | else | ||||
{ | { | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Name"), | "label": translate("Map Name"), | ||||
"value": mapCache.translateMapName( | "value": mapCache.translateMapName( | ||||
mapCache.getTranslatableMapName(g_GameAttributes.mapType, g_GameAttributes.map, g_GameAttributes)) | mapCache.getTranslatableMapName(gameSettings.mapType, gameSettings.map, gameSettings)) | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Description"), | "label": translate("Map Description"), | ||||
"value": mapCache.getTranslatedMapDescription(g_GameAttributes.mapType, g_GameAttributes.map) | "value": mapCache.getTranslatedMapDescription(gameSettings.mapType, gameSettings.map) | ||||
}); | }); | ||||
} | } | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Type"), | "label": translate("Map Type"), | ||||
"value": g_MapTypes.Title[g_MapTypes.Name.indexOf(g_GameAttributes.mapType)] | "value": g_MapTypes.Title[g_MapTypes.Name.indexOf(gameSettings.mapType)] | ||||
}); | }); | ||||
if (g_GameAttributes.mapType == "random") | if (gameSettings.mapType == "random") | ||||
{ | { | ||||
let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(g_GameAttributes.settings.Size)]; | let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(gameSettings.settings.Size)]; | ||||
if (mapSize) | if (mapSize) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Size"), | "label": translate("Map Size"), | ||||
"value": mapSize | "value": mapSize | ||||
}); | }); | ||||
} | } | ||||
if (g_GameAttributes.settings.Biome) | if (gameSettings.settings.Biome) | ||||
{ | { | ||||
let biome = g_Settings.Biomes.find(b => b.Id == g_GameAttributes.settings.Biome); | let biome = g_Settings.Biomes.find(b => b.Id == gameSettings.settings.Biome); | ||||
titles.push({ | titles.push({ | ||||
"label": biome ? biome.Title : translateWithContext("biome", "Random Biome"), | "label": biome ? biome.Title : translateWithContext("biome", "Random Biome"), | ||||
"value": biome ? biome.Description : translate("Randomly select a biome from the list.") | "value": biome ? biome.Description : translate("Randomly select a biome from the list.") | ||||
}); | }); | ||||
} | } | ||||
if (g_GameAttributes.settings.TriggerDifficulty !== undefined) | if (gameSettings.settings.TriggerDifficulty !== undefined) | ||||
{ | { | ||||
let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == g_GameAttributes.settings.TriggerDifficulty); | let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == gameSettings.settings.TriggerDifficulty); | ||||
titles.push({ | titles.push({ | ||||
"label": triggerDifficulty.Title, | "label": triggerDifficulty.Title, | ||||
"value": triggerDifficulty.Tooltip | "value": triggerDifficulty.Tooltip | ||||
}); | }); | ||||
} | } | ||||
if (g_GameAttributes.settings.Nomad !== undefined) | if (gameSettings.settings.Nomad !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": g_GameAttributes.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | "label": gameSettings.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | ||||
"value": | "value": | ||||
g_GameAttributes.settings.Nomad ? | gameSettings.settings.Nomad ? | ||||
translate("Players start with only few units and have to find a suitable place to build their city.") : | translate("Players start with only few units and have to find a suitable place to build their city.") : | ||||
translate("Players start with a Civic Center.") | translate("Players start with a Civic Center.") | ||||
}); | }); | ||||
if (g_GameAttributes.settings.StartingResources !== undefined) | if (gameSettings.settings.StartingResources !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Starting Resources"), | "label": translate("Starting Resources"), | ||||
"value": | "value": | ||||
g_GameAttributes.settings.PlayerData && | gameSettings.settings.PlayerData && | ||||
g_GameAttributes.settings.PlayerData.some(pData => pData && pData.Resources !== undefined) ? | gameSettings.settings.PlayerData.some(pData => pData && pData.Resources !== undefined) ? | ||||
translateWithContext("starting resources", "Per Player") : | translateWithContext("starting resources", "Per Player") : | ||||
sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), { | sprintf(translate("%(startingResourcesTitle)s (%(amount)s)"), { | ||||
"startingResourcesTitle": | "startingResourcesTitle": | ||||
g_StartingResources.Title[ | g_StartingResources.Title[ | ||||
g_StartingResources.Resources.indexOf( | g_StartingResources.Resources.indexOf( | ||||
g_GameAttributes.settings.StartingResources)], | gameSettings.settings.StartingResources)], | ||||
"amount": g_GameAttributes.settings.StartingResources | "amount": gameSettings.settings.StartingResources | ||||
}) | }) | ||||
}); | }); | ||||
if (g_GameAttributes.settings.PopulationCap !== undefined) | if (gameSettings.settings.PopulationCap !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Population Limit"), | "label": translate("Population Limit"), | ||||
"value": | "value": | ||||
g_GameAttributes.settings.PlayerData && | gameSettings.settings.PlayerData && | ||||
g_GameAttributes.settings.PlayerData.some(pData => pData && pData.PopulationLimit !== undefined) ? | gameSettings.settings.PlayerData.some(pData => pData && pData.PopulationLimit !== undefined) ? | ||||
translateWithContext("population limit", "Per Player") : | translateWithContext("population limit", "Per Player") : | ||||
g_PopulationCapacities.Title[ | g_PopulationCapacities.Title[ | ||||
g_PopulationCapacities.Population.indexOf( | g_PopulationCapacities.Population.indexOf( | ||||
g_GameAttributes.settings.PopulationCap)] | gameSettings.settings.PopulationCap)] | ||||
}); | }); | ||||
if (g_GameAttributes.settings.WorldPopulationCap !== undefined) | if (gameSettings.settings.WorldPopulationCap !== undefined) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("World Population Cap"), | "label": translate("World Population Cap"), | ||||
"value": | "value": | ||||
g_WorldPopulationCapacities.Title[ | g_WorldPopulationCapacities.Title[ | ||||
g_WorldPopulationCapacities.Population.indexOf( | g_WorldPopulationCapacities.Population.indexOf( | ||||
g_GameAttributes.settings.WorldPopulationCap)] | gameSettings.settings.WorldPopulationCap)] | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Treasures"), | "label": translate("Treasures"), | ||||
"value": g_GameAttributes.settings.DisableTreasures ? | "value": gameSettings.settings.DisableTreasures ? | ||||
translateWithContext("treasures", "Disabled") : | translateWithContext("treasures", "Disabled") : | ||||
translateWithContext("treasures", "As defined by the map.") | translateWithContext("treasures", "As defined by the map.") | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Revealed Map"), | "label": translate("Revealed Map"), | ||||
"value": g_GameAttributes.settings.RevealMap | "value": gameSettings.settings.RevealMap | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Explored Map"), | "label": translate("Explored Map"), | ||||
"value": g_GameAttributes.settings.ExploreMap | "value": gameSettings.settings.ExploreMap | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Cheats"), | "label": translate("Cheats"), | ||||
"value": g_GameAttributes.settings.CheatsEnabled | "value": gameSettings.settings.CheatsEnabled | ||||
}); | }); | ||||
return titles.map(title => sprintf(translate("%(label)s %(details)s"), { | return titles.map(title => sprintf(translate("%(label)s %(details)s"), { | ||||
"label": coloredText(title.label, g_DescriptionHighlight), | "label": coloredText(title.label, g_DescriptionHighlight), | ||||
"details": | "details": | ||||
title.value === true ? translateWithContext("game setup option", "enabled") : | title.value === true ? translateWithContext("game setup option", "enabled") : | ||||
title.value || translateWithContext("game setup option", "disabled") | title.value || translateWithContext("game setup option", "disabled") | ||||
})).join("\n"); | })).join("\n"); | ||||
Show All 30 Lines |
Wildfire Games · Phabricator