2010-02-05 23:00:39 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/Attack.js");
|
2010-01-24 18:24:35 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/Builder.js");
|
2010-02-28 22:45:09 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/DamageReceiver.js");
|
2010-03-12 22:41:40 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/Foundation.js");
|
2010-02-05 23:00:39 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/Health.js");
|
2010-02-12 23:46:53 +01:00
|
|
|
Engine.LoadComponentScript("interfaces/ResourceGatherer.js");
|
|
|
|
Engine.LoadComponentScript("interfaces/ResourceSupply.js");
|
2010-01-09 20:20:14 +01:00
|
|
|
Engine.LoadComponentScript("GuiInterface.js");
|
|
|
|
|
|
|
|
var cmp = ConstructComponent(SYSTEM_ENTITY, "GuiInterface");
|
|
|
|
|
2010-01-24 18:24:35 +01:00
|
|
|
AddMock(SYSTEM_ENTITY, IID_PlayerManager, {
|
|
|
|
GetNumPlayers: function() { return 2; },
|
|
|
|
GetPlayerByID: function(id) { TS_ASSERT(id === 0 || id === 1); return 100+id; }
|
|
|
|
});
|
|
|
|
|
2010-01-26 00:43:58 +01:00
|
|
|
AddMock(SYSTEM_ENTITY, IID_TemplateManager, {
|
|
|
|
GetCurrentTemplateName: function(ent) { return "example"; },
|
|
|
|
GetTemplate: function(name) { return ""; },
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2010-01-24 18:24:35 +01:00
|
|
|
AddMock(100, IID_Player, {
|
|
|
|
GetPopulationCount: function() { return 10; },
|
2010-02-12 23:46:53 +01:00
|
|
|
GetPopulationLimit: function() { return 20; },
|
|
|
|
GetResourceCounts: function() { return { "food": 100 }; }
|
2010-01-24 18:24:35 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
AddMock(101, IID_Player, {
|
|
|
|
GetPopulationCount: function() { return 40; },
|
2010-02-12 23:46:53 +01:00
|
|
|
GetPopulationLimit: function() { return 30; },
|
|
|
|
GetResourceCounts: function() { return { "food": 200 }; }
|
2010-01-24 18:24:35 +01:00
|
|
|
});
|
|
|
|
|
2010-01-26 00:43:58 +01:00
|
|
|
TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), {
|
2010-02-12 23:46:53 +01:00
|
|
|
players: [{popCount:10, popLimit:20, resourceCounts:{food:100}}, {popCount:40, popLimit:30, resourceCounts:{food:200}}]
|
2010-01-26 00:43:58 +01:00
|
|
|
});
|
2010-01-24 18:24:35 +01:00
|
|
|
|
2010-01-09 20:20:14 +01:00
|
|
|
|
|
|
|
AddMock(10, IID_Position, {
|
|
|
|
GetPosition: function() {
|
|
|
|
return {x:1, y:2, z:3};
|
2010-01-24 18:24:35 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2010-02-05 23:00:39 +01:00
|
|
|
AddMock(10, IID_Health, {
|
2010-02-28 22:45:09 +01:00
|
|
|
GetHitpoints: function() { return 50; },
|
|
|
|
GetMaxHitpoints: function() { return 60; },
|
2010-02-05 23:00:39 +01:00
|
|
|
});
|
|
|
|
|
2010-01-24 18:24:35 +01:00
|
|
|
AddMock(10, IID_Builder, {
|
|
|
|
GetEntitiesList: function() {
|
|
|
|
return ["test1", "test2"];
|
|
|
|
}
|
2010-01-09 20:20:14 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
var state = cmp.GetEntityState(-1, 10);
|
2010-01-26 00:43:58 +01:00
|
|
|
TS_ASSERT_UNEVAL_EQUALS(state, {
|
|
|
|
template: "example",
|
|
|
|
position: {x:1, y:2, z:3},
|
2010-02-05 23:00:39 +01:00
|
|
|
hitpoints: 50,
|
2010-02-28 22:45:09 +01:00
|
|
|
maxHitpoints: 60,
|
2010-01-26 00:43:58 +01:00
|
|
|
buildEntities: ["test1", "test2"]
|
|
|
|
});
|