Differential D2652 Diff 13601 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_UpgradeModification.js
Engine.LoadHelperScript("Player.js"); | Engine.LoadHelperScript("Player.js"); | ||||
Engine.LoadHelperScript("ValueModification.js"); | Engine.LoadHelperScript("ValueModification.js"); | ||||
Resources = { | Resources = { | ||||
"BuildSchema": type => { | "BuildSchema": type => { | ||||
let schema = ""; | let schema = ""; | ||||
for (let res of ["food", "metal", "stone", "wood"]) | for (let res of ["food", "metal", "stone", "wood"]) | ||||
schema += | schema += | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='" + res + "'>" + | "<element name='" + res + "'>" + | ||||
"<ref name='" + type + "'/>" + | "<ref name='" + type + "'/>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>"; | "</optional>"; | ||||
return "<interleave>" + schema + "</interleave>"; | return "<interleave>" + schema + "</interleave>"; | ||||
} | } | ||||
}; | }; | ||||
Engine.LoadComponentScript("interfaces/ProductionQueue.js"); | |||||
Engine.LoadComponentScript("interfaces/ModifiersManager.js"); // Provides `IID_ModifiersManager`, used below. | Engine.LoadComponentScript("interfaces/ModifiersManager.js"); // Provides `IID_ModifiersManager`, used below. | ||||
Engine.LoadComponentScript("interfaces/Timer.js"); // Provides `IID_Timer`, used below. | Engine.LoadComponentScript("interfaces/Timer.js"); // Provides `IID_Timer`, used below. | ||||
// What we're testing: | // What we're testing: | ||||
Engine.LoadComponentScript("interfaces/Upgrade.js"); | Engine.LoadComponentScript("interfaces/Upgrade.js"); | ||||
Engine.LoadComponentScript("Upgrade.js"); | Engine.LoadComponentScript("Upgrade.js"); | ||||
// Input (bare minimum needed for tests): | // Input (bare minimum needed for tests): | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
// Create an entity with an Upgrade component: | // Create an entity with an Upgrade component: | ||||
AddMock(20, IID_Ownership, { | AddMock(20, IID_Ownership, { | ||||
"GetOwner": () => playerID // Called in helpers/Player.js::QueryOwnerInterface(). | "GetOwner": () => playerID // Called in helpers/Player.js::QueryOwnerInterface(). | ||||
}); | }); | ||||
AddMock(20, IID_Identity, { | AddMock(20, IID_Identity, { | ||||
"GetCiv": () => civCode // Called in components/Upgrade.js::init(). | "GetCiv": () => civCode // Called in components/Upgrade.js::init(). | ||||
}); | }); | ||||
AddMock(20, IID_ProductionQueue, { | |||||
"HasQueuedProduction": () => false | |||||
}); | |||||
let cmpUpgrade = ConstructComponent(20, "Upgrade", template.Upgrade); | let cmpUpgrade = ConstructComponent(20, "Upgrade", template.Upgrade); | ||||
cmpUpgrade.owner = playerID; | cmpUpgrade.owner = playerID; | ||||
/** | /** | ||||
* Now to start the test proper | * Now to start the test proper | ||||
* To start with, no techs are researched... | * To start with, no techs are researched... | ||||
*/ | */ | ||||
// T1: Check the cost of the upgrade without a player value being passed (as it would be in the structree). | // T1: Check the cost of the upgrade without a player value being passed (as it would be in the structree). | ||||
Show All 31 Lines |
Wildfire Games · Phabricator