Fix tests. Patch by fatherbushido, refs #2706.

Some simplifications and array functions.
Fix indentation, thanks pastebin.

This was SVN commit r18471.
This commit is contained in:
elexis 2016-07-02 21:32:09 +00:00
parent f468ac936b
commit c24b6b582d
4 changed files with 19 additions and 24 deletions

View File

@ -483,8 +483,8 @@ g_SelectionPanels.Gate = {
"tooltip": translate("Lock Gate"),
"locked": true,
"callback": function (item) { lockGate(item.locked); }
});
gates.push({
},
{
"gate": state.gate,
"tooltip": translate("Unlock Gate"),
"locked": false,
@ -1034,20 +1034,14 @@ g_SelectionPanels.Upgrade = {
if (!unitEntState.upgrade)
return false;
var items = [];
for (let upgrade of unitEntState.upgrade.upgrades)
{
items.push({
"entity": upgrade.entity,
"cost": upgrade.cost,
"time": upgrade.time,
"icon": upgrade.icon,
"tooltip": upgrade.tooltip,
"requiredTechnology": upgrade.requiredTechnology,
});
}
return items;
return unitEntState.upgrade.upgrades.map(upgrade => ({
"entity": upgrade.entity,
"cost": upgrade.cost,
"time": upgrade.time,
"icon": upgrade.icon,
"tooltip": upgrade.tooltip,
"requiredTechnology": upgrade.requiredTechnology
}));
},
"setupButton" : function(data)
{
@ -1084,7 +1078,9 @@ g_SelectionPanels.Upgrade = {
"tooltip": data.item.tooltip
});
else
tooltip = sprintf(translate("Upgrade into a %(name)s."), {"name": template.name.generic});
tooltip = sprintf(translate("Upgrade into a %(name)s."), {
"name": template.name.generic
});
if (data.item.cost)
tooltip += "\n" + getEntityCostTooltip(data.item);

View File

@ -192,10 +192,7 @@ Upgrade.prototype.GetRequiredTechnology = function(templateArg)
entType = entType.replace(/\{civ\}/g, cmpIdentity.GetCiv());
let template = cmpTemplateManager.GetTemplate(entType);
if (template.Identity.RequiredTechnology)
return template.Identity.RequiredTechnology;
return undefined;
return template.Identity.RequiredTechnology || undefined;
};
Upgrade.prototype.GetResourceCosts = function(template)
@ -209,9 +206,8 @@ Upgrade.prototype.GetResourceCosts = function(template)
let costs = {};
for (let r in this.template[choice].Cost)
{
costs[r] = ApplyValueModificationsToEntity("Upgrade/Cost/"+r, +this.template[choice].Cost[r], this.entity);
}
return costs;
};

View File

@ -29,6 +29,7 @@ Engine.LoadComponentScript("interfaces/Trader.js");
Engine.LoadComponentScript("interfaces/Timer.js");
Engine.LoadComponentScript("interfaces/StatisticsTracker.js");
Engine.LoadComponentScript("interfaces/UnitAI.js");
Engine.LoadComponentScript("interfaces/Upgrade.js");
Engine.LoadComponentScript("interfaces/BuildingAI.js");
Engine.LoadComponentScript("GuiInterface.js");
@ -503,6 +504,7 @@ TS_ASSERT_UNEVAL_EQUALS(cmp.GetEntityState(-1, 10), {
market: null,
mirage: null,
pack: null,
upgrade: null,
player: -1,
position: {x:1, y:2, z:3},
production: null,

View File

@ -77,6 +77,7 @@
<Actor>structures/romans/siege_wall_long.xml</Actor>
<FoundationActor>structures/fndn_wall.xml</FoundationActor>
</VisualActor>
<WallPiece> <Length>36.0</Length>
<WallPiece>
<Length>36.0</Length>
</WallPiece>
</Entity>