mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Fix eslint rule 'no-shadow'
Manual fixes needed for: eslint --no-config-lookup --rule '"no-shadow": 1' Ref: #7812 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
dcda4187be
commit
7b4cf11e25
22 changed files with 90 additions and 90 deletions
|
|
@ -286,26 +286,26 @@ function displayOptions()
|
|||
|
||||
control[optionType.guiSetter] = function() {
|
||||
|
||||
const value = optionType.guiToValue(control);
|
||||
const newValue = optionType.guiToValue(control);
|
||||
|
||||
if (optionType.sanitizeValue)
|
||||
optionType.sanitizeValue(value, control, option);
|
||||
optionType.sanitizeValue(newValue, control, option);
|
||||
|
||||
const oldValue = optionType.configToValue(Engine.ConfigDB_GetValue("user", option.config));
|
||||
|
||||
control.tooltip = option.tooltip + (optionType.tooltip ? "\n" + optionType.tooltip(value, option) : "");
|
||||
control.tooltip = option.tooltip + (optionType.tooltip ? "\n" + optionType.tooltip(newValue, option) : "");
|
||||
|
||||
const hasChanges = Engine.ConfigDB_HasChanges("user");
|
||||
Engine.ConfigDB_CreateValue("user", option.config, String(value));
|
||||
Engine.ConfigDB_CreateValue("user", option.config, String(newValue));
|
||||
|
||||
g_ChangedKeys.add(option.config);
|
||||
fireConfigChangeHandlers(new Set([option.config]));
|
||||
|
||||
if (option.timeout)
|
||||
optionType.timeout(option, oldValue, hasChanges, value);
|
||||
optionType.timeout(option, oldValue, hasChanges, newValue);
|
||||
|
||||
if (option.function)
|
||||
Engine[option.function](value);
|
||||
Engine[option.function](newValue);
|
||||
|
||||
enableButtons();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -771,9 +771,9 @@ function updateGroups()
|
|||
|
||||
const button = Engine.GetGUIObjectByName("unitGroupButton[" + i + "]");
|
||||
button.hidden = g_Groups.groups[i].getTotalCount() == 0;
|
||||
button.onPress = (function(i) { return function() { performGroup((Engine.HotkeyIsPressed("selection.add") ? "add" : "select"), i); }; })(i);
|
||||
button.onDoublePress = (function(i) { return function() { performGroup("snap", i); }; })(i);
|
||||
button.onPressRight = (function(i) { return function() { performGroup("breakUp", i); }; })(i);
|
||||
button.onPress = (function(groupId) { return function() { performGroup((Engine.HotkeyIsPressed("selection.add") ? "add" : "select"), groupId); }; })(i);
|
||||
button.onDoublePress = (function(groupId) { return function() { performGroup("snap", groupId); }; })(i);
|
||||
button.onPressRight = (function(groupId) { return function() { performGroup("breakUp", groupId); }; })(i);
|
||||
|
||||
// Choose the icon of the most common template (or the most costly if it's not unique)
|
||||
if (g_Groups.groups[i].getTotalCount() > 0)
|
||||
|
|
|
|||
|
|
@ -85,9 +85,9 @@ class CounterManager
|
|||
|
||||
for (const counter of this.counters)
|
||||
{
|
||||
const hidden = g_ViewedPlayer <= 0;
|
||||
counter.panel.hidden = hidden;
|
||||
if (!hidden)
|
||||
const isHidden = g_ViewedPlayer <= 0;
|
||||
counter.panel.hidden = isHidden;
|
||||
if (!isHidden)
|
||||
counter.rebuild(viewedPlayerState, this.getAllyStatTooltip.bind(this));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -209,9 +209,9 @@ function* GenerateMap(mapSettings)
|
|||
yield 38;
|
||||
|
||||
g_Map.log("Creating dirt patches");
|
||||
for (const size of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)])
|
||||
for (const dirtClumpSize of [scaleByMapSize(3, 48), scaleByMapSize(5, 84), scaleByMapSize(8, 128)])
|
||||
createAreas(
|
||||
new ClumpPlacer(size, 0.3, 0.06, 0.5),
|
||||
new ClumpPlacer(dirtClumpSize, 0.3, 0.06, 0.5),
|
||||
[
|
||||
new LayeredPainter(
|
||||
[[tMainTerrain, tTier1Terrain], [tTier1Terrain, tTier2Terrain], [tTier2Terrain, tTier3Terrain]],
|
||||
|
|
@ -231,9 +231,9 @@ function* GenerateMap(mapSettings)
|
|||
yield 42;
|
||||
|
||||
g_Map.log("Creating grass patches");
|
||||
for (const size of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)])
|
||||
for (const grassClumpSize of [scaleByMapSize(2, 32), scaleByMapSize(3, 48), scaleByMapSize(5, 80)])
|
||||
createAreas(
|
||||
new ClumpPlacer(size, 0.3, 0.06, 0.5),
|
||||
new ClumpPlacer(grassClumpSize, 0.3, 0.06, 0.5),
|
||||
new TerrainPainter(tTier4Terrain),
|
||||
[avoidClasses(clForest, 0, clHill, 0, clDirt, 5, clIsland, 0), stayClasses(clLand, 7)],
|
||||
scaleByMapSize(15, 45));
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraints
|
|||
for (let ix = sx; ix <= lx; ++ix)
|
||||
for (let iz = sz; iz <= lz; ++iz)
|
||||
{
|
||||
const position = new Vector2D(ix, iz);
|
||||
const distance = position.distanceTo(circlePosition);
|
||||
const deltaPosition = new Vector2D(ix, iz);
|
||||
const distance = deltaPosition.distanceTo(circlePosition);
|
||||
|
||||
const newHeight =
|
||||
randIntInclusive(0, 2) +
|
||||
|
|
@ -190,16 +190,16 @@ function createMountain(maxHeight, minRadius, maxRadius, numCircles, constraints
|
|||
if (distance > radius)
|
||||
continue;
|
||||
|
||||
if (g_Map.getHeight(position) < newHeight)
|
||||
g_Map.setHeight(position, newHeight);
|
||||
else if (g_Map.getHeight(position) >= newHeight && g_Map.getHeight(position) < newHeight + 4)
|
||||
g_Map.setHeight(position, newHeight + 4);
|
||||
if (g_Map.getHeight(deltaPosition) < newHeight)
|
||||
g_Map.setHeight(deltaPosition, newHeight);
|
||||
else if (g_Map.getHeight(deltaPosition) >= newHeight && g_Map.getHeight(position) < newHeight + 4)
|
||||
g_Map.setHeight(deltaPosition, newHeight + 4);
|
||||
|
||||
if (terrain)
|
||||
createTerrain(terrain).place(position);
|
||||
createTerrain(terrain).place(deltaPosition);
|
||||
|
||||
if (tileClass)
|
||||
tileClass.add(position);
|
||||
tileClass.add(deltaPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ CityPainter.prototype.paint = function(area)
|
|||
const processed = new Array(mapSize).fill(0).map(() => new Uint8Array(mapSize));
|
||||
|
||||
for (let x = 0; x < mapSize; x += 0.5)
|
||||
{
|
||||
for (let y = 0; y < mapSize; y += 0.5)
|
||||
{
|
||||
const point = new Vector2D(x, y).rotateAround(this.angle, mapCenter).round();
|
||||
|
|
@ -77,8 +78,9 @@ CityPainter.prototype.paint = function(area)
|
|||
tileClass.add(obstructionPoint);
|
||||
|
||||
++templateCounts[template.templateName];
|
||||
templates = templates.filter(template => templateCounts[template.templateName] < template.maxCount);
|
||||
templates = templates.filter(templ => templateCounts[templ.templateName] < templ.maxCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ LayeredPainter.prototype.paint = function(area)
|
|||
"area": area,
|
||||
"brushSize": 1,
|
||||
"gridSize": g_Map.getSize(),
|
||||
"withinArea": (area, position) => area.contains(position),
|
||||
"withinArea": (bounds, position) => bounds.contains(position),
|
||||
"paintTile": (point, distance) => {
|
||||
let width = 0;
|
||||
let i = 0;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ SmoothElevationPainter.prototype.paint = function(area)
|
|||
}
|
||||
}
|
||||
|
||||
const withinArea = (area, position) => g_TileVertices.some(vertexPos => area.contains(Vector2D.sub(position, vertexPos)));
|
||||
const withinArea = (bounds, position) => g_TileVertices.some(vertexPos => bounds.contains(Vector2D.sub(position, vertexPos)));
|
||||
|
||||
// Change height inside the area depending on the distance to the border
|
||||
breadthFirstSearchPaint({
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ PETRA.BuildManager.prototype.checkEvents = function(gameState, events)
|
|||
// at this stage, so we simply have to dump the cache.
|
||||
this.builderCounters = new Map();
|
||||
|
||||
const civ = gameState.getPlayerCiv();
|
||||
for (const ent of gameState.getOwnUnits().values())
|
||||
this.incrementBuilderCounters(civ, ent, 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,12 +130,12 @@ AlertRaiser.prototype.EndOfAlert = function()
|
|||
continue;
|
||||
|
||||
const cmpGarrisonHolder = Engine.QueryInterface(holder, IID_GarrisonHolder);
|
||||
const units = cmpGarrisonHolder.GetEntities().filter(ent => {
|
||||
const garrisonedUnits = cmpGarrisonHolder.GetEntities().filter(ent => {
|
||||
const cmpOwner = Engine.QueryInterface(ent, IID_Ownership);
|
||||
return cmpOwner && cmpOwner.GetOwner() == owner && this.UnitFilter(ent);
|
||||
});
|
||||
|
||||
for (const unit of units)
|
||||
for (const unit of garrisonedUnits)
|
||||
if (cmpGarrisonHolder.Unload(unit))
|
||||
{
|
||||
const cmpUnitAI = Engine.QueryInterface(unit, IID_UnitAI);
|
||||
|
|
|
|||
|
|
@ -254,8 +254,7 @@ BuildRestrictions.prototype.CheckPlacement = function()
|
|||
|
||||
var filter = function(id)
|
||||
{
|
||||
var cmpIdentity = Engine.QueryInterface(id, IID_Identity);
|
||||
return cmpIdentity.GetClassesList().indexOf(cat) > -1;
|
||||
return Engine.QueryInterface(id, IID_Identity).GetClassesList().indexOf(cat) > -1;
|
||||
};
|
||||
|
||||
if (this.template.Distance.MinDistance !== undefined)
|
||||
|
|
@ -263,7 +262,7 @@ BuildRestrictions.prototype.CheckPlacement = function()
|
|||
const minDistance = ApplyValueModificationsToTemplate("BuildRestrictions/Distance/MinDistance", +this.template.Distance.MinDistance, cmpPlayer.GetPlayerID(), template);
|
||||
if (cmpRangeManager.ExecuteQuery(this.entity, 0, minDistance, [cmpPlayer.GetPlayerID()], IID_BuildRestrictions, false).some(filter))
|
||||
{
|
||||
const result = markForPluralTranslation(
|
||||
result = markForPluralTranslation(
|
||||
"%(name)s too close to a %(category)s, must be at least %(distance)s meter away",
|
||||
"%(name)s too close to a %(category)s, must be at least %(distance)s meters away",
|
||||
minDistance);
|
||||
|
|
@ -284,7 +283,7 @@ BuildRestrictions.prototype.CheckPlacement = function()
|
|||
const maxDistance = ApplyValueModificationsToTemplate("BuildRestrictions/Distance/MaxDistance", +this.template.Distance.MaxDistance, cmpPlayer.GetPlayerID(), template);
|
||||
if (!cmpRangeManager.ExecuteQuery(this.entity, 0, maxDistance, [cmpPlayer.GetPlayerID()], IID_BuildRestrictions, false).some(filter))
|
||||
{
|
||||
const result = markForPluralTranslation(
|
||||
result = markForPluralTranslation(
|
||||
"%(name)s too far from a %(category)s, must be within %(distance)s meter",
|
||||
"%(name)s too far from a %(category)s, must be within %(distance)s meters",
|
||||
maxDistance);
|
||||
|
|
|
|||
|
|
@ -4179,7 +4179,7 @@ UnitAI.prototype.GetOrderData = function()
|
|||
|
||||
UnitAI.prototype.UpdateWorkOrders = function(type)
|
||||
{
|
||||
var isWorkType = type => type == "Gather" || type == "Trade" || type == "Repair" || type == "ReturnResource";
|
||||
var isWorkType = kind => kind == "Gather" || kind == "Trade" || kind == "Repair" || kind == "ReturnResource";
|
||||
if (isWorkType(type))
|
||||
{
|
||||
this.workOrders = [];
|
||||
|
|
@ -5049,7 +5049,7 @@ UnitAI.prototype.GetBestAttackAgainst = function(target, allowCapture = this.DEF
|
|||
*/
|
||||
UnitAI.prototype.AttackVisibleEntity = function(ents)
|
||||
{
|
||||
var target = ents.find(target => this.CanAttack(target));
|
||||
var target = ents.find(entity => this.CanAttack(entity));
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
|
|
@ -5064,10 +5064,10 @@ UnitAI.prototype.AttackVisibleEntity = function(ents)
|
|||
*/
|
||||
UnitAI.prototype.AttackEntityInZone = function(ents)
|
||||
{
|
||||
var target = ents.find(target =>
|
||||
this.CanAttack(target) &&
|
||||
this.CheckTargetDistanceFromHeldPosition(target, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|
||||
(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(target))
|
||||
var target = ents.find(entity =>
|
||||
this.CanAttack(entity) &&
|
||||
this.CheckTargetDistanceFromHeldPosition(entity, IID_Attack, this.GetBestAttackAgainst(target, true)) &&
|
||||
(this.GetStance().respondChaseBeyondVision || this.CheckTargetIsInVisionRange(entity))
|
||||
);
|
||||
if (!target)
|
||||
return false;
|
||||
|
|
@ -5130,11 +5130,11 @@ UnitAI.prototype.RespondToSightedEntities = function(ents)
|
|||
*/
|
||||
UnitAI.prototype.RespondToHealableEntities = function(ents)
|
||||
{
|
||||
const ent = ents.find(ent => this.CanHeal(ent));
|
||||
if (!ent)
|
||||
const target = ents.find(ent => this.CanHeal(ent));
|
||||
if (!target)
|
||||
return false;
|
||||
|
||||
this.PushOrderFront("Heal", { "target": ent, "force": false });
|
||||
this.PushOrderFront("Heal", { "target": target, "force": false });
|
||||
return true;
|
||||
};
|
||||
|
||||
|
|
@ -5156,7 +5156,7 @@ UnitAI.prototype.ShouldAbandonChase = function(target, force, iid, type)
|
|||
const cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|
||||
const cmpAttack = Engine.QueryInterface(target, IID_Attack);
|
||||
if (cmpUnitAI && cmpAttack &&
|
||||
cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|
||||
cmpAttack.GetAttackTypes().some(kind => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, kind)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ var template = { "Identity": { "Classes": { "_string": "CorrectClass OtherClass"
|
|||
|
||||
global.AuraTemplates = {
|
||||
"Get": name => {
|
||||
const template = {
|
||||
const auraTemplate = {
|
||||
"type": name,
|
||||
"affectedPlayers": ["Ally"],
|
||||
"affects": ["CorrectClass"],
|
||||
|
|
@ -27,8 +27,8 @@ global.AuraTemplates = {
|
|||
"auraDescription": "description"
|
||||
};
|
||||
if (name == "range")
|
||||
template.radius = auraRange;
|
||||
return template;
|
||||
auraTemplate.radius = auraRange;
|
||||
return auraTemplate;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,25 +27,25 @@ const testCaptureAttacks = {
|
|||
"32": 2.0
|
||||
};
|
||||
|
||||
function testCapturable(testData, test_function)
|
||||
function testCapturable(data, test_function)
|
||||
{
|
||||
ResetState();
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_Timer, {
|
||||
"SetInterval": (ent, iid, funcname, time, repeattime, data) => {},
|
||||
"SetInterval": (ent, iid, funcname, time, repeattime, payload) => {},
|
||||
"CancelTimer": timer => {}
|
||||
});
|
||||
|
||||
AddMock(testData.structure, IID_Ownership, {
|
||||
"GetOwner": () => testData.playerID,
|
||||
AddMock(data.structure, IID_Ownership, {
|
||||
"GetOwner": () => data.playerID,
|
||||
"SetOwner": id => {}
|
||||
});
|
||||
|
||||
AddMock(testData.structure, IID_GarrisonHolder, {
|
||||
"GetEntities": () => testData.garrisonedEntities
|
||||
AddMock(data.structure, IID_GarrisonHolder, {
|
||||
"GetEntities": () => data.garrisonedEntities
|
||||
});
|
||||
|
||||
AddMock(testData.structure, IID_Fogging, {
|
||||
AddMock(data.structure, IID_Fogging, {
|
||||
"Activate": () => {}
|
||||
});
|
||||
|
||||
|
|
@ -70,25 +70,25 @@ function testCapturable(testData, test_function)
|
|||
"GetPlayerByID": id => 10 + id
|
||||
});
|
||||
|
||||
AddMock(testData.structure, IID_StatisticsTracker, {
|
||||
AddMock(data.structure, IID_StatisticsTracker, {
|
||||
"LostEntity": () => {},
|
||||
"CapturedBuilding": () => {}
|
||||
});
|
||||
|
||||
const cmpCapturable = ConstructComponent(testData.structure, "Capturable", {
|
||||
"CapturePoints": testData.maxCapturePoints,
|
||||
"RegenRate": testData.regenRate,
|
||||
"GarrisonRegenRate": testData.garrisonRegenRate
|
||||
const cmpCapturable = ConstructComponent(data.structure, "Capturable", {
|
||||
"CapturePoints": data.maxCapturePoints,
|
||||
"RegenRate": data.regenRate,
|
||||
"GarrisonRegenRate": data.garrisonRegenRate
|
||||
});
|
||||
|
||||
AddMock(testData.structure, IID_TerritoryDecay, {
|
||||
"IsDecaying": () => testData.decay,
|
||||
"GetDecayRate": () => testData.decayRate,
|
||||
"GetConnectedNeighbours": () => testData.neighbours
|
||||
AddMock(data.structure, IID_TerritoryDecay, {
|
||||
"IsDecaying": () => data.decay,
|
||||
"GetDecayRate": () => data.decayRate,
|
||||
"GetConnectedNeighbours": () => data.neighbours
|
||||
});
|
||||
|
||||
let regenRate = testData.regenRate;
|
||||
for (const entity of testData.garrisonedEntities)
|
||||
let regenRate = data.regenRate;
|
||||
for (const entity of data.garrisonedEntities)
|
||||
{
|
||||
if (testCaptureAttacks[entity] === undefined)
|
||||
continue;
|
||||
|
|
@ -97,7 +97,7 @@ function testCapturable(testData, test_function)
|
|||
return type === "Capture" ? { "Capture": testCaptureAttacks[entity] } : undefined;
|
||||
},
|
||||
});
|
||||
regenRate += testCaptureAttacks[entity] * testData.garrisonRegenRate;
|
||||
regenRate += testCaptureAttacks[entity] * data.garrisonRegenRate;
|
||||
}
|
||||
|
||||
TS_ASSERT_EQUALS(cmpCapturable.GetRegenRate(), regenRate);
|
||||
|
|
@ -147,9 +147,9 @@ testCapturable(testData, cmpCapturable => {
|
|||
TS_ASSERT_UNEVAL_EQUALS(cmpCapturable.GetCapturePoints(), [0, 0, 0, 3000]);
|
||||
});
|
||||
|
||||
function testRegen(testData, capturePointsIn, capturePointsOut, regenerating)
|
||||
function testRegen(data, capturePointsIn, capturePointsOut, regenerating)
|
||||
{
|
||||
testCapturable(testData, cmpCapturable => {
|
||||
testCapturable(data, cmpCapturable => {
|
||||
cmpCapturable.SetCapturePoints(capturePointsIn);
|
||||
cmpCapturable.CheckTimer();
|
||||
Engine.PostMessage = function(ent, iid, message) {
|
||||
|
|
@ -172,14 +172,14 @@ testData.regenRate = -19;
|
|||
testRegen(testData, [100, 2800, 50, 50], [112, 2796, 46, 46], true);
|
||||
testData.regenRate = 2;
|
||||
|
||||
function testDecay(testData, capturePointsIn, capturePointsOut)
|
||||
function testDecay(data, capturePointsIn, capturePointsOut)
|
||||
{
|
||||
testCapturable(testData, cmpCapturable => {
|
||||
testCapturable(data, cmpCapturable => {
|
||||
cmpCapturable.SetCapturePoints(capturePointsIn);
|
||||
cmpCapturable.CheckTimer();
|
||||
Engine.PostMessage = function(ent, iid, message) {
|
||||
if (iid == MT_CaptureRegenStateChanged)
|
||||
TS_ASSERT_UNEVAL_EQUALS(message.territoryDecay, testData.decayRate);
|
||||
TS_ASSERT_UNEVAL_EQUALS(message.territoryDecay, data.decayRate);
|
||||
};
|
||||
cmpCapturable.TimerTick();
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmpCapturable.GetCapturePoints(), capturePointsOut);
|
||||
|
|
@ -193,9 +193,9 @@ testDecay(testData, [2900, 35, 10, 55], [2901, 27, 22, 50]);
|
|||
testData.decay = false;
|
||||
|
||||
// Tests Reduce
|
||||
function testReduce(testData, amount, player, taken)
|
||||
function testReduce(data, amount, player, taken)
|
||||
{
|
||||
testCapturable(testData, cmpCapturable => {
|
||||
testCapturable(data, cmpCapturable => {
|
||||
cmpCapturable.SetCapturePoints([0, 2000, 0, 1000]);
|
||||
cmpCapturable.CheckTimer();
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmpCapturable.Reduce(amount, player), taken);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ AddMock(ent, IID_Sound, {
|
|||
|
||||
AddMock(SYSTEM_ENTITY, IID_Timer, {
|
||||
"CancelTimer": id => { timerActivated = false; return; },
|
||||
"SetInterval": (ent, iid, funcname, time, repeattime, data) => { timerActivated = true; return 7; }
|
||||
"SetInterval": (entity, iid, funcname, time, repeattime, data) => { timerActivated = true; return 7; }
|
||||
});
|
||||
|
||||
Engine.AddEntity = function(template) {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const entity = 11;
|
|||
const entPopBonus = 5;
|
||||
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue
|
||||
(valueName, currentValue, entityId) => currentValue
|
||||
);
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
|
||||
|
|
@ -40,7 +40,7 @@ TS_ASSERT_EQUALS(spy._called, 1);
|
|||
// Test value modifications.
|
||||
// Test no change.
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue
|
||||
(valueName, currentValue, entityId) => currentValue
|
||||
);
|
||||
|
||||
cmpPlayer = AddMock(player, IID_Player, {
|
||||
|
|
@ -55,7 +55,7 @@ AddMock(entity, IID_Ownership, {
|
|||
});
|
||||
let difference = 3;
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue + difference
|
||||
(valueName, currentValue, entityId) => currentValue + difference
|
||||
);
|
||||
|
||||
cmpPlayer = AddMock(player, IID_Player, {
|
||||
|
|
@ -78,7 +78,7 @@ cmpPlayer = AddMock(player, IID_Player, {
|
|||
});
|
||||
difference = 0;
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue + difference
|
||||
(valueName, currentValue, entityId) => currentValue + difference
|
||||
);
|
||||
spy = new Spy(cmpPlayer, "AddPopulationBonuses");
|
||||
cmpPopulation.OnValueModification({ "component": "Population" });
|
||||
|
|
@ -87,7 +87,7 @@ TS_ASSERT_EQUALS(spy._called, 1);
|
|||
// Test negative change.
|
||||
difference = -2;
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue + difference
|
||||
(valueName, currentValue, entityId) => currentValue + difference
|
||||
);
|
||||
|
||||
cmpPlayer = AddMock(player, IID_Player, {
|
||||
|
|
@ -101,7 +101,7 @@ TS_ASSERT_EQUALS(spy._called, 1);
|
|||
// Test newly created entities also get affected by modifications.
|
||||
difference = 3;
|
||||
Engine.RegisterGlobal("ApplyValueModificationsToEntity",
|
||||
(valueName, currentValue, entity) => currentValue + difference
|
||||
(valueName, currentValue, entityId) => currentValue + difference
|
||||
);
|
||||
cmpPlayer = AddMock(player, IID_Player, {
|
||||
"AddPopulationBonuses": bonus => TS_ASSERT_EQUALS(bonus, entPopBonus + difference)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const createTurretCmp = entity => {
|
|||
"JumpTo": (posX, posZ) => {},
|
||||
"MoveOutOfWorld": () => {},
|
||||
"SetHeightOffset": height => {},
|
||||
"SetTurretParent": entity => {},
|
||||
"SetTurretParent": ent => {},
|
||||
"SetYRotation": angle => {}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ AddMock(SYSTEM_ENTITY, IID_Timer, {
|
|||
});
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_ModifiersManager, {
|
||||
"ApplyTemplateModifiers": (valueName, curValue, template, player) => {
|
||||
"ApplyTemplateModifiers": (valueName, curValue, templ, player) => {
|
||||
// Called in helpers/ValueModification.js::ApplyValueModificationsToTemplate()
|
||||
// as part of Tests T2 and T5 below.
|
||||
const mods = isResearched ? templateTechModifications.with : templateTechModifications.without;
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ AddMock(14, IID_Player, {
|
|||
"TrySubtractResources": costs => true
|
||||
});
|
||||
AddMock(SYSTEM_ENTITY, IID_Timer, {
|
||||
"SetTimeout": (ent, iid, funcname, time, data) => TS_ASSERT_EQUALS(time, 25 * 1000)
|
||||
"SetTimeout": (entity, iid, funcname, time, data) => TS_ASSERT_EQUALS(time, 25 * 1000)
|
||||
});
|
||||
cmpVisionSharing.AddSpy(4, 25);
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmpVisionSharing.shared, new Set([1, 2, 5, 4]));
|
||||
|
|
@ -171,7 +171,7 @@ AddMock(ent, IID_Vision, {
|
|||
"GetRange": () => 48
|
||||
});
|
||||
AddMock(SYSTEM_ENTITY, IID_Timer, {
|
||||
"SetTimeout": (ent, iid, funcname, time, data) => TS_ASSERT_EQUALS(time, 15 * 1000 * 60 / 48)
|
||||
"SetTimeout": (entity, iid, funcname, time, data) => TS_ASSERT_EQUALS(time, 15 * 1000 * 60 / 48)
|
||||
});
|
||||
cmpVisionSharing.AddSpy(4);
|
||||
TS_ASSERT_UNEVAL_EQUALS(cmpVisionSharing.shared, new Set([1, 2, 5, 4]));
|
||||
|
|
|
|||
|
|
@ -768,8 +768,8 @@ var g_Commands = {
|
|||
"spy-request": function(player, cmd, data)
|
||||
{
|
||||
const cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager);
|
||||
const ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.player).filter(ent => {
|
||||
const cmpVisionSharing = Engine.QueryInterface(ent, IID_VisionSharing);
|
||||
const ent = pickRandom(cmpRangeManager.GetEntitiesByPlayer(cmd.player).filter(entity => {
|
||||
const cmpVisionSharing = Engine.QueryInterface(entity, IID_VisionSharing);
|
||||
return cmpVisionSharing && cmpVisionSharing.IsBribable() && !cmpVisionSharing.ShareVisionWith(player);
|
||||
}));
|
||||
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ class ObstructionSnap
|
|||
for (const edge of pairedEdges)
|
||||
if (this.compareEdges(edge, secondEdge) < 0)
|
||||
secondEdge = edge;
|
||||
const distance = Vector2D.dot(secondEdge.normal, templatePos) - Vector2D.dot(secondEdge.normal, secondEdge.begin);
|
||||
templatePos.sub(Vector2D.mult(secondEdge.normal, distance - sizeToPairedEdge - this.getPadding(secondEdge)));
|
||||
const dist = Vector2D.dot(secondEdge.normal, templatePos) - Vector2D.dot(secondEdge.normal, secondEdge.begin);
|
||||
templatePos.sub(Vector2D.mult(secondEdge.normal, dist - sizeToPairedEdge - this.getPadding(secondEdge)));
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -253,8 +253,8 @@ function ObstructionsBlockingTemplateChange(ent, templateArg)
|
|||
if (cmpNewObstruction && cmpNewObstruction.GetBlockMovementFlag())
|
||||
{
|
||||
// Remove all obstructions at the new entity, especially animal corpses
|
||||
for (const ent of cmpNewObstruction.GetEntitiesDeletedUponConstruction())
|
||||
Engine.DestroyEntity(ent);
|
||||
for (const entity of cmpNewObstruction.GetEntitiesDeletedUponConstruction())
|
||||
Engine.DestroyEntity(entity);
|
||||
|
||||
const collisions = cmpNewObstruction.GetEntitiesBlockingConstruction();
|
||||
if (collisions.length)
|
||||
|
|
|
|||
Loading…
Reference in a new issue