Differential D144 Diff 1667 ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | "GetNames": () => ({ | ||||
"metal": "Metal", | "metal": "Metal", | ||||
"stone": "Stone", | "stone": "Stone", | ||||
"wood": "Wood" | "wood": "Wood" | ||||
}), | }), | ||||
"GetResource": resource => ({ | "GetResource": resource => ({ | ||||
"aiAnalysisInfluenceGroup": | "aiAnalysisInfluenceGroup": | ||||
resource == "food" ? "ignore" : | resource == "food" ? "ignore" : | ||||
resource == "wood" ? "abundant" : "sparse" | resource == "wood" ? "abundant" : "sparse" | ||||
}), | }) | ||||
}; | }; | ||||
var cmp = ConstructComponent(SYSTEM_ENTITY, "GuiInterface"); | var cmp = ConstructComponent(SYSTEM_ENTITY, "GuiInterface"); | ||||
AddMock(SYSTEM_ENTITY, IID_Barter, { | AddMock(SYSTEM_ENTITY, IID_Barter, { | ||||
GetPrices: function() { | GetPrices: function() { | ||||
return { | return { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
"sell": { "food": 25 } | "sell": { "food": 25 } | ||||
}; | }; | ||||
}, | }, | ||||
PlayerHasMarket: function () { return false; } | PlayerHasMarket: function () { return false; } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_EndGameManager, { | AddMock(SYSTEM_ENTITY, IID_EndGameManager, { | ||||
GetGameType: function() { return "conquest"; }, | GetGameType: function() { return "conquest"; }, | ||||
GetAlliedVictory: function() { return false; } | GetAlliedVictory: function() { return false; } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | AddMock(SYSTEM_ENTITY, IID_PlayerManager, { | ||||
GetNumPlayers: function() { return 2; }, | GetNumPlayers: function() { return 2; }, | ||||
GetPlayerByID: function(id) { TS_ASSERT(id === 0 || id === 1); return 100+id; }, | GetPlayerByID: function(id) { TS_ASSERT(id === 0 || id === 1); return 100+id; } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, { | AddMock(SYSTEM_ENTITY, IID_RangeManager, { | ||||
GetLosVisibility: function(ent, player) { return "visible"; }, | GetLosVisibility: function(ent, player) { return "visible"; }, | ||||
GetLosCircular: function() { return false; }, | GetLosCircular: function() { return false; } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | AddMock(SYSTEM_ENTITY, IID_TemplateManager, { | ||||
GetCurrentTemplateName: function(ent) { return "example"; }, | GetCurrentTemplateName: function(ent) { return "example"; }, | ||||
GetTemplate: function(name) { return ""; }, | GetTemplate: function(name) { return ""; } | ||||
}); | }); | ||||
AddMock(SYSTEM_ENTITY, IID_Timer, { | AddMock(SYSTEM_ENTITY, IID_Timer, { | ||||
GetTime: function() { return 0; }, | GetTime: function() { return 0; }, | ||||
SetTimeout: function(ent, iid, funcname, time, data) { return 0; }, | SetTimeout: function(ent, iid, funcname, time, data) { return 0; } | ||||
}); | }); | ||||
AddMock(100, IID_Player, { | AddMock(100, IID_Player, { | ||||
GetName: function() { return "Player 1"; }, | GetName: function() { return "Player 1"; }, | ||||
GetCiv: function() { return "gaia"; }, | GetCiv: function() { return "gaia"; }, | ||||
GetColor: function() { return { r: 1, g: 1, b: 1, a: 1}; }, | GetColor: function() { return { r: 1, g: 1, b: 1, a: 1}; }, | ||||
CanControlAllUnits: function() { return false; }, | CanControlAllUnits: function() { return false; }, | ||||
GetPopulationCount: function() { return 10; }, | GetPopulationCount: function() { return 10; }, | ||||
Show All 10 Lines | AddMock(100, IID_Player, { | ||||
IsAlly: function() { return false; }, | IsAlly: function() { return false; }, | ||||
IsMutualAlly: function() { return false; }, | IsMutualAlly: function() { return false; }, | ||||
IsNeutral: function() { return false; }, | IsNeutral: function() { return false; }, | ||||
IsEnemy: function() { return true; }, | IsEnemy: function() { return true; }, | ||||
GetDisabledTemplates: function() { return {}; }, | GetDisabledTemplates: function() { return {}; }, | ||||
GetDisabledTechnologies: function() { return {}; }, | GetDisabledTechnologies: function() { return {}; }, | ||||
GetSpyCostMultiplier: function() { return 1; }, | GetSpyCostMultiplier: function() { return 1; }, | ||||
HasSharedDropsites: function() { return false; }, | HasSharedDropsites: function() { return false; }, | ||||
HasSharedLos: function() { return false; }, | HasSharedLos: function() { return false; } | ||||
}); | }); | ||||
AddMock(100, IID_EntityLimits, { | AddMock(100, IID_EntityLimits, { | ||||
GetLimits: function() { return {"Foo": 10}; }, | GetLimits: function() { return {"Foo": 10}; }, | ||||
GetCounts: function() { return {"Foo": 5}; }, | GetCounts: function() { return {"Foo": 5}; }, | ||||
GetLimitChangers: function() {return {"Foo": {}}; } | GetLimitChangers: function() {return {"Foo": {}}; } | ||||
}); | }); | ||||
AddMock(100, IID_TechnologyManager, { | AddMock(100, IID_TechnologyManager, { | ||||
IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, | IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, | ||||
GetQueuedResearch: function() { return {}; }, | GetQueuedResearch: function() { return {}; }, | ||||
GetStartedTechs: function() { return {}; }, | GetStartedTechs: function() { return {}; }, | ||||
GetResearchedTechs: function() { return {}; }, | GetResearchedTechs: function() { return {}; }, | ||||
GetClassCounts: function() { return {}; }, | GetClassCounts: function() { return {}; }, | ||||
GetTypeCountsByClass: function() { return {}; }, | GetTypeCountsByClass: function() { return {}; }, | ||||
GetTechModifications: function() { return {}; }, | GetTechModifications: function() { return {}; } | ||||
}); | }); | ||||
AddMock(100, IID_StatisticsTracker, { | AddMock(100, IID_StatisticsTracker, { | ||||
GetBasicStatistics: function() { | GetBasicStatistics: function() { | ||||
return { | return { | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": 100, | "food": 100, | ||||
"wood": 0, | "wood": 0, | ||||
"metal": 0, | "metal": 0, | ||||
"stone": 0, | "stone": 0, | ||||
"vegetarianFood": 0, | "vegetarianFood": 0 | ||||
}, | }, | ||||
"percentMapExplored": 10 | "percentMapExplored": 10 | ||||
}; | }; | ||||
}, | }, | ||||
GetStatistics: function() { | GetSequences: function() { | ||||
return { | return { | ||||
"unitsTrained": 10, | "unitsTrained": [0, 10], | ||||
"unitsLost": 9, | "unitsLost": [0, 42], | ||||
"buildingsConstructed": 5, | "buildingsConstructed": [1, 3], | ||||
"buildingsCaptured": 7, | "buildingsCaptured": [3, 7], | ||||
"buildingsLost": 4, | "buildingsLost": [3, 10], | ||||
"civCentresBuilt": 1, | "civCentresBuilt": [4, 10], | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": 100, | "food": [5, 100], | ||||
"wood": 0, | "wood": [0, 0], | ||||
"metal": 0, | "metal": [0, 0], | ||||
"stone": 0, | "stone": [0, 0], | ||||
"vegetarianFood": 0, | "vegetarianFood": [0, 0] | ||||
}, | }, | ||||
"treasuresCollected": 0, | "treasuresCollected": [1, 20], | ||||
"lootCollected": 0, | "lootCollected": [0, 2], | ||||
"percentMapExplored": 10, | "percentMapExplored": [0, 10], | ||||
"teamPercentMapExplored": 10, | "teamPercentMapExplored": [0, 10], | ||||
"percentMapControlled": 10, | "percentMapControlled": [0, 10], | ||||
"teamPercentMapControlled": 10, | "teamPercentMapControlled": [0, 10], | ||||
"peakPercentOfMapControlled": 10, | "peakPercentOfMapControlled": [0, 10], | ||||
"teamPeakPercentOfMapControlled": 10 | "teamPeakPercentOfMapControlled": [0, 10] | ||||
}; | }; | ||||
}, | }, | ||||
IncreaseTrainedUnitsCounter: function() { return 1; }, | IncreaseTrainedUnitsCounter: function() { return 1; }, | ||||
IncreaseConstructedBuildingsCounter: function() { return 1; }, | IncreaseConstructedBuildingsCounter: function() { return 1; }, | ||||
IncreaseBuiltCivCentresCounter: function() { return 1; }, | IncreaseBuiltCivCentresCounter: function() { return 1; } | ||||
}); | }); | ||||
AddMock(101, IID_Player, { | AddMock(101, IID_Player, { | ||||
GetName: function() { return "Player 2"; }, | GetName: function() { return "Player 2"; }, | ||||
GetCiv: function() { return "mace"; }, | GetCiv: function() { return "mace"; }, | ||||
GetColor: function() { return { r: 1, g: 0, b: 0, a: 1}; }, | GetColor: function() { return { r: 1, g: 0, b: 0, a: 1}; }, | ||||
CanControlAllUnits: function() { return true; }, | CanControlAllUnits: function() { return true; }, | ||||
GetPopulationCount: function() { return 40; }, | GetPopulationCount: function() { return 40; }, | ||||
Show All 10 Lines | AddMock(101, IID_Player, { | ||||
IsAlly: function() { return true; }, | IsAlly: function() { return true; }, | ||||
IsMutualAlly: function() {return false; }, | IsMutualAlly: function() {return false; }, | ||||
IsNeutral: function() { return false; }, | IsNeutral: function() { return false; }, | ||||
IsEnemy: function() { return false; }, | IsEnemy: function() { return false; }, | ||||
GetDisabledTemplates: function() { return {}; }, | GetDisabledTemplates: function() { return {}; }, | ||||
GetDisabledTechnologies: function() { return {}; }, | GetDisabledTechnologies: function() { return {}; }, | ||||
GetSpyCostMultiplier: function() { return 1; }, | GetSpyCostMultiplier: function() { return 1; }, | ||||
HasSharedDropsites: function() { return false; }, | HasSharedDropsites: function() { return false; }, | ||||
HasSharedLos: function() { return false; }, | HasSharedLos: function() { return false; } | ||||
}); | }); | ||||
AddMock(101, IID_EntityLimits, { | AddMock(101, IID_EntityLimits, { | ||||
GetLimits: function() { return {"Bar": 20}; }, | GetLimits: function() { return {"Bar": 20}; }, | ||||
GetCounts: function() { return {"Bar": 0}; }, | GetCounts: function() { return {"Bar": 0}; }, | ||||
GetLimitChangers: function() {return {"Bar": {}}; } | GetLimitChangers: function() {return {"Bar": {}}; } | ||||
}); | }); | ||||
AddMock(101, IID_TechnologyManager, { | AddMock(101, IID_TechnologyManager, { | ||||
IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, | IsTechnologyResearched: function(tech) { if (tech == "phase_village") return true; else return false; }, | ||||
GetQueuedResearch: function() { return {}; }, | GetQueuedResearch: function() { return {}; }, | ||||
GetStartedTechs: function() { return {}; }, | GetStartedTechs: function() { return {}; }, | ||||
GetResearchedTechs: function() { return {}; }, | GetResearchedTechs: function() { return {}; }, | ||||
GetClassCounts: function() { return {}; }, | GetClassCounts: function() { return {}; }, | ||||
GetTypeCountsByClass: function() { return {}; }, | GetTypeCountsByClass: function() { return {}; }, | ||||
GetTechModifications: function() { return {}; }, | GetTechModifications: function() { return {}; } | ||||
}); | }); | ||||
AddMock(101, IID_StatisticsTracker, { | AddMock(101, IID_StatisticsTracker, { | ||||
GetBasicStatistics: function() { | GetBasicStatistics: function() { | ||||
return { | return { | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": 100, | "food": 100, | ||||
"wood": 0, | "wood": 0, | ||||
"metal": 0, | "metal": 0, | ||||
"stone": 0, | "stone": 0, | ||||
"vegetarianFood": 0, | "vegetarianFood": 0 | ||||
}, | }, | ||||
"percentMapExplored": 10 | "percentMapExplored": 10 | ||||
}; | }; | ||||
}, | }, | ||||
GetStatistics: function() { | GetSequences: function() { | ||||
return { | return { | ||||
"unitsTrained": 10, | "unitsTrained": [0, 10], | ||||
"unitsLost": 9, | "unitsLost": [0, 9], | ||||
"buildingsConstructed": 5, | "buildingsConstructed": [0, 5], | ||||
"buildingsCaptured": 7, | "buildingsCaptured": [0, 7], | ||||
"buildingsLost": 4, | "buildingsLost": [0, 4], | ||||
"civCentresBuilt": 1, | "civCentresBuilt": [0, 1], | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": 100, | "food": [0, 100], | ||||
"wood": 0, | "wood": [0, 0], | ||||
"metal": 0, | "metal": [0, 0], | ||||
"stone": 0, | "stone": [0, 0], | ||||
"vegetarianFood": 0, | "vegetarianFood": [0, 0] | ||||
}, | }, | ||||
"treasuresCollected": 0, | "treasuresCollected": [0, 0], | ||||
"lootCollected": 0, | "lootCollected": [0, 0], | ||||
"percentMapExplored": 10, | "percentMapExplored": [0, 10], | ||||
"teamPercentMapExplored": 10, | "teamPercentMapExplored": [0, 10], | ||||
"percentMapControlled": 10, | "percentMapControlled": [0, 10], | ||||
"teamPercentMapControlled": 10, | "teamPercentMapControlled": [0, 10], | ||||
"peakPercentOfMapControlled": 10, | "peakPercentOfMapControlled": [0, 10], | ||||
"teamPeakPercentOfMapControlled": 10 | "teamPeakPercentOfMapControlled": [0, 10] | ||||
}; | }; | ||||
}, | }, | ||||
IncreaseTrainedUnitsCounter: function() { return 1; }, | IncreaseTrainedUnitsCounter: function() { return 1; }, | ||||
IncreaseConstructedBuildingsCounter: function() { return 1; }, | IncreaseConstructedBuildingsCounter: function() { return 1; }, | ||||
IncreaseBuiltCivCentresCounter: function() { return 1; }, | IncreaseBuiltCivCentresCounter: function() { return 1; } | ||||
}); | }); | ||||
// Note: property order matters when using TS_ASSERT_UNEVAL_EQUALS, | // Note: property order matters when using TS_ASSERT_UNEVAL_EQUALS, | ||||
// because uneval preserves property order. So make sure this object | // because uneval preserves property order. So make sure this object | ||||
// matches the ordering in GuiInterface. | // matches the ordering in GuiInterface. | ||||
TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), { | TS_ASSERT_UNEVAL_EQUALS(cmp.GetSimulationState(), { | ||||
players: [ | players: [ | ||||
{ | { | ||||
Show All 31 Lines | players: [ | ||||
typeCountsByClass: {}, | typeCountsByClass: {}, | ||||
canBarter: false, | canBarter: false, | ||||
statistics: { | statistics: { | ||||
resourcesGathered: { | resourcesGathered: { | ||||
food: 100, | food: 100, | ||||
wood: 0, | wood: 0, | ||||
metal: 0, | metal: 0, | ||||
stone: 0, | stone: 0, | ||||
vegetarianFood: 0, | vegetarianFood: 0 | ||||
}, | }, | ||||
percentMapExplored: 10 | percentMapExplored: 10 | ||||
}, | } | ||||
}, | }, | ||||
{ | { | ||||
name: "Player 2", | name: "Player 2", | ||||
civ: "mace", | civ: "mace", | ||||
color: { r:1, g:0, b:0, a:1 }, | color: { r:1, g:0, b:0, a:1 }, | ||||
controlsAll: true, | controlsAll: true, | ||||
popCount: 40, | popCount: 40, | ||||
popLimit: 30, | popLimit: 30, | ||||
Show All 25 Lines | players: [ | ||||
typeCountsByClass: {}, | typeCountsByClass: {}, | ||||
canBarter: false, | canBarter: false, | ||||
statistics: { | statistics: { | ||||
resourcesGathered: { | resourcesGathered: { | ||||
food: 100, | food: 100, | ||||
wood: 0, | wood: 0, | ||||
metal: 0, | metal: 0, | ||||
stone: 0, | stone: 0, | ||||
vegetarianFood: 0, | vegetarianFood: 0 | ||||
}, | }, | ||||
percentMapExplored: 10 | percentMapExplored: 10 | ||||
}, | } | ||||
} | } | ||||
], | ], | ||||
circularMap: false, | circularMap: false, | ||||
timeElapsed: 0, | timeElapsed: 0, | ||||
gameType: "conquest", | gameType: "conquest", | ||||
alliedVictory: false, | alliedVictory: false, | ||||
"barterPrices": { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
"sell": { "food": 25 } | "sell": { "food": 25 } | ||||
}, | }, | ||||
"resources": { | "resources": { | ||||
"codes": ["food", "metal", "stone", "wood"], | "codes": ["food", "metal", "stone", "wood"], | ||||
"names": { | "names": { | ||||
"food": "Food", | "food": "Food", | ||||
"metal": "Metal", | "metal": "Metal", | ||||
"stone": "Stone", | "stone": "Stone", | ||||
"wood": "Wood", | "wood": "Wood" | ||||
}, | }, | ||||
"aiInfluenceGroups": { | "aiInfluenceGroups": { | ||||
"food": "ignore", | "food": "ignore", | ||||
"metal": "sparse", | "metal": "sparse", | ||||
"stone": "sparse", | "stone": "sparse", | ||||
"wood": "abundant", | "wood": "abundant" | ||||
} | |||||
} | } | ||||
}, | |||||
}); | }); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), { | TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), { | ||||
players: [ | "players": [ | ||||
{ | { | ||||
name: "Player 1", | "name": "Player 1", | ||||
civ: "gaia", | "civ": "gaia", | ||||
color: { r:1, g:1, b:1, a:1 }, | "color": { "r":1, "g":1, "b":1, "a":1 }, | ||||
controlsAll: false, | "controlsAll": false, | ||||
popCount: 10, | "popCount": 10, | ||||
popLimit: 20, | "popLimit": 20, | ||||
popMax: 200, | "popMax": 200, | ||||
panelEntities: [], | "panelEntities": [], | ||||
resourceCounts: { food: 100 }, | "resourceCounts": { "food": 100 }, | ||||
trainingBlocked: false, | "trainingBlocked": false, | ||||
state: "active", | "state": "active", | ||||
team: -1, | "team": -1, | ||||
teamsLocked: false, | "teamsLocked": false, | ||||
cheatsEnabled: false, | "cheatsEnabled": false, | ||||
disabledTemplates: {}, | "disabledTemplates": {}, | ||||
disabledTechnologies: {}, | "disabledTechnologies": {}, | ||||
hasSharedDropsites: false, | "hasSharedDropsites": false, | ||||
hasSharedLos: false, | "hasSharedLos": false, | ||||
spyCostMultiplier: 1, | "spyCostMultiplier": 1, | ||||
phase: "village", | "phase": "village", | ||||
isAlly: [false, false], | "isAlly": [false, false], | ||||
isMutualAlly: [false, false], | "isMutualAlly": [false, false], | ||||
isNeutral: [false, false], | "isNeutral": [false, false], | ||||
isEnemy: [true, true], | "isEnemy": [true, true], | ||||
entityLimits: {"Foo": 10}, | "entityLimits": {"Foo": 10}, | ||||
entityCounts: {"Foo": 5}, | "entityCounts": {"Foo": 5}, | ||||
entityLimitChangers: {"Foo": {}}, | "entityLimitChangers": {"Foo": {}}, | ||||
researchQueued: {}, | "researchQueued": {}, | ||||
researchStarted: {}, | "researchStarted": {}, | ||||
researchedTechs: {}, | "researchedTechs": {}, | ||||
classCounts: {}, | "classCounts": {}, | ||||
typeCountsByClass: {}, | "typeCountsByClass": {}, | ||||
canBarter: false, | "canBarter": false, | ||||
statistics: { | "statistics": { | ||||
unitsTrained: 10, | "resourcesGathered": { | ||||
unitsLost: 9, | "food": 100, | ||||
buildingsConstructed: 5, | "wood": 0, | ||||
buildingsCaptured: 7, | "metal": 0, | ||||
buildingsLost: 4, | "stone": 0, | ||||
civCentresBuilt: 1, | "vegetarianFood": 0 | ||||
resourcesGathered: { | |||||
food: 100, | |||||
wood: 0, | |||||
metal: 0, | |||||
stone: 0, | |||||
vegetarianFood: 0, | |||||
}, | }, | ||||
treasuresCollected: 0, | "percentMapExplored": 10 | ||||
lootCollected: 0, | |||||
percentMapExplored: 10, | |||||
teamPercentMapExplored: 10, | |||||
percentMapControlled: 10, | |||||
teamPercentMapControlled: 10, | |||||
peakPercentOfMapControlled: 10, | |||||
teamPeakPercentOfMapControlled: 10 | |||||
}, | }, | ||||
"sequences": { | |||||
"unitsTrained": [0, 10], | |||||
"unitsLost": [0, 42], | |||||
"buildingsConstructed": [1, 3], | |||||
"buildingsCaptured": [3, 7], | |||||
"buildingsLost": [3, 10], | |||||
"civCentresBuilt": [4, 10], | |||||
"resourcesGathered": { | |||||
"food": [5, 100], | |||||
"wood": [0, 0], | |||||
"metal": [0, 0], | |||||
"stone": [0, 0], | |||||
"vegetarianFood": [0, 0] | |||||
}, | |||||
"treasuresCollected": [1, 20], | |||||
"lootCollected": [0, 2], | |||||
"percentMapExplored": [0, 10], | |||||
"teamPercentMapExplored": [0, 10], | |||||
"percentMapControlled": [0, 10], | |||||
"teamPercentMapControlled": [0, 10], | |||||
"peakPercentOfMapControlled": [0, 10], | |||||
"teamPeakPercentOfMapControlled": [0, 10] | |||||
} | |||||
}, | }, | ||||
{ | { | ||||
name: "Player 2", | "name": "Player 2", | ||||
civ: "mace", | "civ": "mace", | ||||
color: { r:1, g:0, b:0, a:1 }, | "color": { "r":1, "g":0, "b":0, "a":1 }, | ||||
controlsAll: true, | "controlsAll": true, | ||||
popCount: 40, | "popCount": 40, | ||||
popLimit: 30, | "popLimit": 30, | ||||
popMax: 300, | "popMax": 300, | ||||
panelEntities: [], | "panelEntities": [], | ||||
resourceCounts: { food: 200 }, | "resourceCounts": { "food": 200 }, | ||||
trainingBlocked: false, | "trainingBlocked": false, | ||||
state: "active", | "state": "active", | ||||
team: -1, | "team": -1, | ||||
teamsLocked: false, | "teamsLocked": false, | ||||
cheatsEnabled: false, | "cheatsEnabled": false, | ||||
disabledTemplates: {}, | "disabledTemplates": {}, | ||||
disabledTechnologies: {}, | "disabledTechnologies": {}, | ||||
hasSharedDropsites: false, | "hasSharedDropsites": false, | ||||
hasSharedLos: false, | "hasSharedLos": false, | ||||
spyCostMultiplier: 1, | "spyCostMultiplier": 1, | ||||
phase: "village", | "phase": "village", | ||||
isAlly: [true, true], | "isAlly": [true, true], | ||||
isMutualAlly: [false, false], | "isMutualAlly": [false, false], | ||||
isNeutral: [false, false], | "isNeutral": [false, false], | ||||
isEnemy: [false, false], | "isEnemy": [false, false], | ||||
entityLimits: {"Bar": 20}, | "entityLimits": {"Bar": 20}, | ||||
entityCounts: {"Bar": 0}, | "entityCounts": {"Bar": 0}, | ||||
entityLimitChangers: {"Bar": {}}, | "entityLimitChangers": {"Bar": {}}, | ||||
researchQueued: {}, | "researchQueued": {}, | ||||
researchStarted: {}, | "researchStarted": {}, | ||||
researchedTechs: {}, | "researchedTechs": {}, | ||||
classCounts: {}, | "classCounts": {}, | ||||
typeCountsByClass: {}, | "typeCountsByClass": {}, | ||||
canBarter: false, | "canBarter": false, | ||||
statistics: { | "statistics": { | ||||
unitsTrained: 10, | "resourcesGathered": { | ||||
unitsLost: 9, | "food": 100, | ||||
buildingsConstructed: 5, | "wood": 0, | ||||
buildingsCaptured: 7, | "metal": 0, | ||||
buildingsLost: 4, | "stone": 0, | ||||
civCentresBuilt: 1, | "vegetarianFood": 0 | ||||
resourcesGathered: { | |||||
food: 100, | |||||
wood: 0, | |||||
metal: 0, | |||||
stone: 0, | |||||
vegetarianFood: 0, | |||||
}, | }, | ||||
treasuresCollected: 0, | "percentMapExplored": 10 | ||||
lootCollected: 0, | |||||
percentMapExplored: 10, | |||||
teamPercentMapExplored: 10, | |||||
percentMapControlled: 10, | |||||
teamPercentMapControlled: 10, | |||||
peakPercentOfMapControlled: 10, | |||||
teamPeakPercentOfMapControlled: 10 | |||||
}, | }, | ||||
"sequences": { | |||||
"unitsTrained": [0, 10], | |||||
"unitsLost": [0, 9], | |||||
"buildingsConstructed": [0, 5], | |||||
"buildingsCaptured": [0, 7], | |||||
"buildingsLost": [0, 4], | |||||
"civCentresBuilt": [0, 1], | |||||
"resourcesGathered": { | |||||
"food": [0, 100], | |||||
"wood": [0, 0], | |||||
"metal": [0, 0], | |||||
"stone": [0, 0], | |||||
"vegetarianFood": [0, 0] | |||||
}, | |||||
"treasuresCollected": [0, 0], | |||||
"lootCollected": [0, 0], | |||||
"percentMapExplored": [0, 10], | |||||
"teamPercentMapExplored": [0, 10], | |||||
"percentMapControlled": [0, 10], | |||||
"teamPercentMapControlled": [0, 10], | |||||
"peakPercentOfMapControlled": [0, 10], | |||||
"teamPeakPercentOfMapControlled": [0, 10] | |||||
} | |||||
} | } | ||||
], | ], | ||||
circularMap: false, | "circularMap": false, | ||||
timeElapsed: 0, | "timeElapsed": 0, | ||||
gameType: "conquest", | "gameType": "conquest", | ||||
alliedVictory: false, | "alliedVictory": false, | ||||
"barterPrices": { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
"sell": { "food": 25 } | "sell": { "food": 25 } | ||||
}, | }, | ||||
"resources": { | "resources": { | ||||
"codes": ["food", "metal", "stone", "wood"], | "codes": ["food", "metal", "stone", "wood"], | ||||
"names": { | "names": { | ||||
"food": "Food", | "food": "Food", | ||||
"metal": "Metal", | "metal": "Metal", | ||||
"stone": "Stone", | "stone": "Stone", | ||||
"wood": "Wood", | "wood": "Wood" | ||||
}, | }, | ||||
"aiInfluenceGroups": { | "aiInfluenceGroups": { | ||||
"food": "ignore", | "food": "ignore", | ||||
"metal": "sparse", | "metal": "sparse", | ||||
"stone": "sparse", | "stone": "sparse", | ||||
"wood": "abundant", | "wood": "abundant" | ||||
} | |||||
} | } | ||||
}, | |||||
}); | }); | ||||
AddMock(10, IID_Builder, { | AddMock(10, IID_Builder, { | ||||
GetEntitiesList: function() { | GetEntitiesList: function() { | ||||
return ["test1", "test2"]; | return ["test1", "test2"]; | ||||
}, | }, | ||||
}); | }); | ||||
AddMock(10, IID_Health, { | AddMock(10, IID_Health, { | ||||
GetHitpoints: function() { return 50; }, | GetHitpoints: function() { return 50; }, | ||||
GetMaxHitpoints: function() { return 60; }, | GetMaxHitpoints: function() { return 60; }, | ||||
IsRepairable: function() { return false; }, | IsRepairable: function() { return false; }, | ||||
IsUnhealable: function() { return false; }, | IsUnhealable: function() { return false; }, | ||||
IsUndeletable: function() { return false; }, | IsUndeletable: function() { return false; } | ||||
}); | }); | ||||
AddMock(10, IID_Identity, { | AddMock(10, IID_Identity, { | ||||
GetClassesList: function() { return ["class1", "class2"]; }, | GetClassesList: function() { return ["class1", "class2"]; }, | ||||
GetVisibleClassesList: function() { return ["class3", "class4"]; }, | GetVisibleClassesList: function() { return ["class3", "class4"]; }, | ||||
GetRank: function() { return "foo"; }, | GetRank: function() { return "foo"; }, | ||||
GetSelectionGroupName: function() { return "Selection Group Name"; }, | GetSelectionGroupName: function() { return "Selection Group Name"; }, | ||||
HasClass: function() { return true; }, | HasClass: function() { return true; } | ||||
}); | }); | ||||
AddMock(10, IID_Position, { | AddMock(10, IID_Position, { | ||||
GetTurretParent: function() {return INVALID_ENTITY;}, | GetTurretParent: function() {return INVALID_ENTITY;}, | ||||
GetPosition: function() { | GetPosition: function() { | ||||
return {x:1, y:2, z:3}; | return {x:1, y:2, z:3}; | ||||
}, | }, | ||||
GetRotation: function() { | GetRotation: function() { | ||||
return {x:4, y:5, z:6}; | return {x:4, y:5, z:6}; | ||||
}, | }, | ||||
IsInWorld: function() { | IsInWorld: function() { | ||||
return true; | return true; | ||||
}, | } | ||||
}); | }); | ||||
AddMock(10, IID_ResourceTrickle, { | AddMock(10, IID_ResourceTrickle, { | ||||
"GetTimer": () => 1250, | "GetTimer": () => 1250, | ||||
"GetRates": () => ({ | "GetRates": () => ({ | ||||
"food": 2, | "food": 2, | ||||
"wood": 3, | "wood": 3, | ||||
"stone": 5, | "stone": 5, | ||||
"metal": 9 | "metal": 9 | ||||
}) | }) | ||||
}); | }); | ||||
// Note: property order matters when using TS_ASSERT_UNEVAL_EQUALS, | // Note: property order matters when using TS_ASSERT_UNEVAL_EQUALS, | ||||
// because uneval preserves property order. So make sure this object | // because uneval preserves property order. So make sure this object | ||||
// matches the ordering in GuiInterface. | // matches the ordering in GuiInterface. | ||||
TS_ASSERT_UNEVAL_EQUALS(cmp.GetEntityState(-1, 10), { | TS_ASSERT_UNEVAL_EQUALS(cmp.GetEntityState(-1, 10), { | ||||
id: 10, | id: 10, | ||||
template: "example", | template: "example", | ||||
alertRaiser: null, | alertRaiser: null, | ||||
builder: true, | builder: true, | ||||
identity: { | identity: { | ||||
rank: "foo", | rank: "foo", | ||||
classes: ["class1", "class2"], | classes: ["class1", "class2"], | ||||
visibleClasses: ["class3", "class4"], | visibleClasses: ["class3", "class4"], | ||||
selectionGroupName: "Selection Group Name", | selectionGroupName: "Selection Group Name" | ||||
}, | }, | ||||
fogging: null, | fogging: null, | ||||
foundation: null, | foundation: null, | ||||
garrisonHolder: null, | garrisonHolder: null, | ||||
gate: null, | gate: null, | ||||
guard: null, | guard: null, | ||||
market: null, | market: null, | ||||
mirage: null, | mirage: null, | ||||
pack: null, | pack: null, | ||||
upgrade: null, | upgrade: null, | ||||
player: -1, | player: -1, | ||||
position: {x:1, y:2, z:3}, | position: {x:1, y:2, z:3}, | ||||
production: null, | production: null, | ||||
rallyPoint: null, | rallyPoint: null, | ||||
resourceCarrying: null, | resourceCarrying: null, | ||||
rotation: {x:4, y:5, z:6}, | rotation: {x:4, y:5, z:6}, | ||||
trader: null, | trader: null, | ||||
unitAI: null, | unitAI: null, | ||||
visibility: "visible", | visibility: "visible", | ||||
hitpoints: 50, | hitpoints: 50, | ||||
maxHitpoints: 60, | maxHitpoints: 60, | ||||
needsRepair: false, | needsRepair: false, | ||||
needsHeal: true, | needsHeal: true, | ||||
canDelete: true, | canDelete: true | ||||
}); | }); | ||||
TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedEntityState(-1, 10), { | TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedEntityState(-1, 10), { | ||||
armour: null, | armour: null, | ||||
attack: null, | attack: null, | ||||
buildingAI: null, | buildingAI: null, | ||||
heal: null, | heal: null, | ||||
isBarterMarket: true, | isBarterMarket: true, | ||||
Show All 10 Lines | resourceTrickle: { | ||||
"interval": 1250, | "interval": 1250, | ||||
"rates": { | "rates": { | ||||
"food": 2, | "food": 2, | ||||
"wood": 3, | "wood": 3, | ||||
"stone": 5, | "stone": 5, | ||||
"metal": 9 | "metal": 9 | ||||
} | } | ||||
}, | }, | ||||
speed: null, | speed: null | ||||
}); | }); |
Wildfire Games · Phabricator