0ad/binaries/data/mods/public/simulation/components/tests/test_ResourceDropsite.js
Ralph Sennhauser 2e090c2daa
Fix eslint rule 'prefer-const' in components/tests/[A-R]*
eslint --no-config-lookup --fix --rule '"prefer-const": 1' \
    binaries/data/mods/public/simulation/components/tests

Ref: #7812
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-05-11 09:06:57 +02:00

47 lines
1.1 KiB
JavaScript

Resources = {
"BuildChoicesSchema": () => {
let schema = "";
for (const res of ["food", "metal"])
{
for (const subtype in ["meat", "grain"])
schema += "<value>" + res + "." + subtype + "</value>";
schema += "<value> treasure." + res + "</value>";
}
return "<choice>" + schema + "</choice>";
}
};
Engine.LoadHelperScript("Player.js");
Engine.LoadComponentScript("interfaces/ResourceDropsite.js");
Engine.LoadComponentScript("ResourceDropsite.js");
Engine.RegisterGlobal("ApplyValueModificationsToEntity", (prop, oVal, ent) => oVal);
const owner = 1;
const entity = 11;
const dropper = 12;
const template = {
"Sharable": "true",
"Types": "food"
};
const cmpResourceDropsite = ConstructComponent(entity, "ResourceDropsite", template);
TS_ASSERT(cmpResourceDropsite.IsSharable());
AddMock(dropper, IID_Ownership, {
"GetOwner": () => 1
});
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
"GetPlayerByID": (id) => owner
});
AddMock(owner, IID_Player, {
"AddResources": (type, amount) => {}
});
TS_ASSERT_UNEVAL_EQUALS(cmpResourceDropsite.ReceiveResources({
"food": 1,
"wood": 1
}, dropper), { "food": 1 });