Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/common/gamedescription.js
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | teamDescription.push(sprintf(translate("%(team)s:\n%(playerDescriptions)s"), { | ||||
"team": '[font="sans-bold-14"]' + translatePlural("Observer", "Observers", playerDescriptions.observer.length) + "[/font]", | "team": '[font="sans-bold-14"]' + translatePlural("Observer", "Observers", playerDescriptions.observer.length) + "[/font]", | ||||
"playerDescriptions": playerDescriptions.observer.join("\n") | "playerDescriptions": playerDescriptions.observer.join("\n") | ||||
})); | })); | ||||
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. | * Describes the chosen game settings more closely. | ||||
* | |||||
* Requires g_GameAttributes and g_VictoryConditions. | |||||
*/ | */ | ||||
function getGameDescription(mapCache) | function getGameDescription(mapCache) | ||||
{ | { | ||||
let titles = []; | let titles = []; | ||||
if (!g_GameAttributes.settings.VictoryConditions.length) | if (!g_NewGameSettings.victoryConditions.active.size) | ||||
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 Id of g_NewGameSettings.victoryConditions.active) | ||||
{ | { | ||||
if (g_GameAttributes.settings.VictoryConditions.indexOf(victoryCondition.Name) == -1) | let victoryCondition = g_NewGameSettings.victoryConditions.conditions[Id]; | ||||
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 = g_NewGameSettings.wonder.duration; | ||||
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 = g_NewGameSettings.relic.duration; | ||||
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": g_NewGameSettings.relic.count | ||||
}); | }); | ||||
if (victoryCondition.Name == "regicide") | if (victoryCondition.Name == "regicide") | ||||
if (g_GameAttributes.settings.RegicideGarrison) | if (g_NewGameSettings.regicideGarrison.enabled) | ||||
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 (g_NewGameSettings.rating.enabled) | ||||
g_GameAttributes.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 (g_NewGameSettings.lockedTeams.enabled) | ||||
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 (g_NewGameSettings.lastManStanding.enabled) | ||||
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 = g_NewGameSettings.ceasefire.value; | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Ceasefire"), | "label": translate("Ceasefire"), | ||||
"value": | "value": | ||||
ceasefire == 0 ? | ceasefire == 0 ? | ||||
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 (g_NewGameSettings.map.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(g_NewGameSettings.map.type, g_NewGameSettings.map.map, g_NewGameSettings)) | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Map Description"), | "label": translate("Map Description"), | ||||
"value": mapCache.getTranslatedMapDescription(g_GameAttributes.mapType, g_GameAttributes.map) | "value": mapCache.getTranslatedMapDescription(g_NewGameSettings.map.type, g_NewGameSettings.map.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(g_NewGameSettings.map.type)] | ||||
}); | }); | ||||
if (g_GameAttributes.mapType == "random") | if (g_NewGameSettings.map.type == "random") | ||||
{ | { | ||||
let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(g_GameAttributes.settings.Size)]; | let mapSize = g_MapSizes.Name[g_MapSizes.Tiles.indexOf(g_NewGameSettings.mapSize.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 (g_NewGameSettings.biome.biome) | ||||
{ | { | ||||
let biome = g_Settings.Biomes.find(b => b.Id == g_GameAttributes.settings.Biome); | let biome = g_NewGameSettings.biome.getData(); | ||||
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 (g_NewGameSettings.triggerDifficulty.value) | ||||
{ | { | ||||
let triggerDifficulty = g_Settings.TriggerDifficulties.find(difficulty => difficulty.Difficulty == g_GameAttributes.settings.TriggerDifficulty); | let triggerDifficulty = g_NewGameSettings.triggerDifficulty.getData(); | ||||
titles.push({ | titles.push({ | ||||
"label": triggerDifficulty.Title, | "label": triggerDifficulty.Title, | ||||
"value": triggerDifficulty.Tooltip | "value": triggerDifficulty.Tooltip | ||||
}); | }); | ||||
} | } | ||||
if (g_GameAttributes.settings.Nomad !== undefined) | if (g_NewGameSettings.nomad.enabled) | ||||
titles.push({ | titles.push({ | ||||
"label": g_GameAttributes.settings.Nomad ? translate("Nomad Mode") : translate("Civic Centers"), | "label": g_NewGameSettings.nomad.enabled ? translate("Nomad Mode") : translate("Civic Centers"), | ||||
"value": | "value": | ||||
g_GameAttributes.settings.Nomad ? | g_NewGameSettings.nomad.enabled ? | ||||
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 (g_NewGameSettings.startingResources.resources) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Starting Resources"), | "label": translate("Starting Resources"), | ||||
"value": | "value": g_NewGameSettings.startingResources.perPlayer ? | ||||
g_GameAttributes.settings.PlayerData && | |||||
g_GameAttributes.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)], | g_NewGameSettings.startingResources.resources)], | ||||
"amount": g_GameAttributes.settings.StartingResources | "amount": g_NewGameSettings.startingResources.resources | ||||
}) | }) | ||||
}); | }); | ||||
if (g_GameAttributes.settings.PopulationCap !== undefined) | if (!g_NewGameSettings.population.useWorldPop) | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Population Limit"), | "label": translate("Population Limit"), | ||||
"value": | "value": g_NewGameSettings.population.perPlayer ? | ||||
g_GameAttributes.settings.PlayerData && | |||||
g_GameAttributes.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)] | g_NewGameSettings.population.cap)] | ||||
}); | }); | ||||
if (g_GameAttributes.settings.WorldPopulationCap !== undefined) | if (g_NewGameSettings.population.useWorldPop) | ||||
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)] | g_NewGameSettings.population.cap)] | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Treasures"), | "label": translate("Treasures"), | ||||
"value": g_GameAttributes.settings.DisableTreasures ? | "value": g_NewGameSettings.disableTreasures.enabled ? | ||||
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("Explored Map"), | ||||
"value": g_GameAttributes.settings.RevealMap | "value": g_NewGameSettings.mapExploration.explored | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Explored Map"), | "label": translate("Revealed Map"), | ||||
"value": g_GameAttributes.settings.ExploreMap | "value": g_NewGameSettings.mapExploration.revealed | ||||
}); | }); | ||||
titles.push({ | titles.push({ | ||||
"label": translate("Cheats"), | "label": translate("Cheats"), | ||||
"value": g_GameAttributes.settings.CheatsEnabled | "value": g_NewGameSettings.cheats.enabled | ||||
}); | }); | ||||
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"); | ||||
} | } | ||||
function translateAISettings(playerData) | |||||
{ | |||||
if (!playerData.AI) | |||||
return ""; | |||||
return sprintf(translate("%(AIdifficulty)s %(AIbehavior)s %(AIname)s"), { | |||||
"AIname": translateAIName(playerData.AI), | |||||
"AIdifficulty": translateAIDifficulty(playerData.AIDiff), | |||||
"AIbehavior": translateAIBehavior(playerData.AIBehavior), | |||||
}); | |||||
} | |||||
/** | /** | ||||
* Sets the win/defeat icon to indicate current player's state. | * Sets the win/defeat icon to indicate current player's state. | ||||
*/ | */ | ||||
function setOutcomeIcon(state, image) | function setOutcomeIcon(state, image) | ||||
{ | { | ||||
if (state == "won") | if (state == "won") | ||||
{ | { | ||||
image.sprite = "stretched:session/icons/victory.png"; | image.sprite = "stretched:session/icons/victory.png"; | ||||
image.tooltip = translate("Victorious"); | image.tooltip = translate("Victorious"); | ||||
} | } | ||||
else if (state == "defeated") | else if (state == "defeated") | ||||
{ | { | ||||
image.sprite = "stretched:session/icons/defeat.png"; | image.sprite = "stretched:session/icons/defeat.png"; | ||||
image.tooltip = translate("Defeated"); | image.tooltip = translate("Defeated"); | ||||
} | } | ||||
} | } | ||||
function translateAISettings(playerData) | |||||
{ | |||||
if (!playerData.AI) | |||||
return ""; | |||||
return sprintf(translate("%(AIdifficulty)s %(AIbehavior)s %(AIname)s"), { | |||||
"AIname": translateAIName(playerData.AI), | |||||
"AIdifficulty": translateAIDifficulty(playerData.AIDiff), | |||||
"AIbehavior": translateAIBehavior(playerData.AIBehavior), | |||||
}); | |||||
} |
Wildfire Games · Phabricator