Differential D2069 Diff 9078 binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/tests/test_GuiInterface.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | "GetNames": () => ({ | ||||
"food": "Food", | "food": "Food", | ||||
"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, { | ||||
GetVictoryConditions: () => ["conquest", "wonder"], | "GetVictoryConditions": () => ["conquest", "wonder"], | ||||
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; }, | ||||
GetPopulationLimit: function() { return 20; }, | "GetPopulationLimit": function() { return 20; }, | ||||
GetMaxPopulation: function() { return 200; }, | "GetMaxPopulation": function() { return 200; }, | ||||
GetResourceCounts: function() { return { food: 100 }; }, | "GetResourceCounts": function() { return { "food": 100 }; }, | ||||
GetPanelEntities: function() { return []; }, | "GetPanelEntities": function() { return []; }, | ||||
IsTrainingBlocked: function() { return false; }, | "IsTrainingBlocked": function() { return false; }, | ||||
GetState: function() { return "active"; }, | "GetState": function() { return "active"; }, | ||||
GetTeam: function() { return -1; }, | "GetTeam": function() { return -1; }, | ||||
GetLockTeams: function() { return false; }, | "GetLockTeams": function() { return false; }, | ||||
GetCheatsEnabled: function() { return false; }, | "GetCheatsEnabled": function() { return false; }, | ||||
GetDiplomacy: function() { return [-1, 1]; }, | "GetDiplomacy": function() { return [-1, 1]; }, | ||||
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": tech => tech == "phase_village", | "IsTechnologyResearched": tech => tech == "phase_village", | ||||
"GetQueuedResearch": () => new Map(), | "GetQueuedResearch": () => new Map(), | ||||
"GetStartedTechs": () => new Set(), | "GetStartedTechs": () => new Set(), | ||||
"GetResearchedTechs": () => new Set(), | "GetResearchedTechs": () => new Set(), | ||||
"GetClassCounts": () => ({}), | "GetClassCounts": () => ({}), | ||||
"GetTypeCountsByClass": () => ({}) | "GetTypeCountsByClass": () => ({}) | ||||
}); | }); | ||||
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 | ||||
}; | }; | ||||
}, | }, | ||||
GetSequences: function() { | "GetSequences": function() { | ||||
return { | return { | ||||
"unitsTrained": [0, 10], | "unitsTrained": [0, 10], | ||||
"unitsLost": [0, 42], | "unitsLost": [0, 42], | ||||
"buildingsConstructed": [1, 3], | "buildingsConstructed": [1, 3], | ||||
"buildingsCaptured": [3, 7], | "buildingsCaptured": [3, 7], | ||||
"buildingsLost": [3, 10], | "buildingsLost": [3, 10], | ||||
"civCentresBuilt": [4, 10], | "civCentresBuilt": [4, 10], | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": [5, 100], | "food": [5, 100], | ||||
"wood": [0, 0], | "wood": [0, 0], | ||||
"metal": [0, 0], | "metal": [0, 0], | ||||
"stone": [0, 0], | "stone": [0, 0], | ||||
"vegetarianFood": [0, 0] | "vegetarianFood": [0, 0] | ||||
}, | }, | ||||
"treasuresCollected": [1, 20], | "treasuresCollected": [1, 20], | ||||
"lootCollected": [0, 2], | "lootCollected": [0, 2], | ||||
"percentMapExplored": [0, 10], | "percentMapExplored": [0, 10], | ||||
"teamPercentMapExplored": [0, 10], | "teamPercentMapExplored": [0, 10], | ||||
"percentMapControlled": [0, 10], | "percentMapControlled": [0, 10], | ||||
"teamPercentMapControlled": [0, 10], | "teamPercentMapControlled": [0, 10], | ||||
"peakPercentOfMapControlled": [0, 10], | "peakPercentOfMapControlled": [0, 10], | ||||
"teamPeakPercentOfMapControlled": [0, 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; }, | ||||
GetPopulationLimit: function() { return 30; }, | "GetPopulationLimit": function() { return 30; }, | ||||
GetMaxPopulation: function() { return 300; }, | "GetMaxPopulation": function() { return 300; }, | ||||
GetResourceCounts: function() { return { food: 200 }; }, | "GetResourceCounts": function() { return { "food": 200 }; }, | ||||
GetPanelEntities: function() { return []; }, | "GetPanelEntities": function() { return []; }, | ||||
IsTrainingBlocked: function() { return false; }, | "IsTrainingBlocked": function() { return false; }, | ||||
GetState: function() { return "active"; }, | "GetState": function() { return "active"; }, | ||||
GetTeam: function() { return -1; }, | "GetTeam": function() { return -1; }, | ||||
GetLockTeams: function() {return false; }, | "GetLockTeams": function() {return false; }, | ||||
GetCheatsEnabled: function() { return false; }, | "GetCheatsEnabled": function() { return false; }, | ||||
GetDiplomacy: function() { return [-1, 1]; }, | "GetDiplomacy": function() { return [-1, 1]; }, | ||||
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": tech => tech == "phase_village", | "IsTechnologyResearched": tech => tech == "phase_village", | ||||
"GetQueuedResearch": () => new Map(), | "GetQueuedResearch": () => new Map(), | ||||
"GetStartedTechs": () => new Set(), | "GetStartedTechs": () => new Set(), | ||||
"GetResearchedTechs": () => new Set(), | "GetResearchedTechs": () => new Set(), | ||||
"GetClassCounts": () => ({}), | "GetClassCounts": () => ({}), | ||||
"GetTypeCountsByClass": () => ({}) | "GetTypeCountsByClass": () => ({}) | ||||
}); | }); | ||||
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 | ||||
}; | }; | ||||
}, | }, | ||||
GetSequences: function() { | "GetSequences": function() { | ||||
return { | return { | ||||
"unitsTrained": [0, 10], | "unitsTrained": [0, 10], | ||||
"unitsLost": [0, 9], | "unitsLost": [0, 9], | ||||
"buildingsConstructed": [0, 5], | "buildingsConstructed": [0, 5], | ||||
"buildingsCaptured": [0, 7], | "buildingsCaptured": [0, 7], | ||||
"buildingsLost": [0, 4], | "buildingsLost": [0, 4], | ||||
"civCentresBuilt": [0, 1], | "civCentresBuilt": [0, 1], | ||||
"resourcesGathered": { | "resourcesGathered": { | ||||
"food": [0, 100], | "food": [0, 100], | ||||
"wood": [0, 0], | "wood": [0, 0], | ||||
"metal": [0, 0], | "metal": [0, 0], | ||||
"stone": [0, 0], | "stone": [0, 0], | ||||
"vegetarianFood": [0, 0] | "vegetarianFood": [0, 0] | ||||
}, | }, | ||||
"treasuresCollected": [0, 0], | "treasuresCollected": [0, 0], | ||||
"lootCollected": [0, 0], | "lootCollected": [0, 0], | ||||
"percentMapExplored": [0, 10], | "percentMapExplored": [0, 10], | ||||
"teamPercentMapExplored": [0, 10], | "teamPercentMapExplored": [0, 10], | ||||
"percentMapControlled": [0, 10], | "percentMapControlled": [0, 10], | ||||
"teamPercentMapControlled": [0, 10], | "teamPercentMapControlled": [0, 10], | ||||
"peakPercentOfMapControlled": [0, 10], | "peakPercentOfMapControlled": [0, 10], | ||||
"teamPeakPercentOfMapControlled": [0, 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": [ | ||||
{ | { | ||||
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: new Map(), | "researchQueued": new Map(), | ||||
researchStarted: new Set(), | "researchStarted": new Set(), | ||||
researchedTechs: new Set(), | "researchedTechs": new Set(), | ||||
classCounts: {}, | "classCounts": {}, | ||||
typeCountsByClass: {}, | "typeCountsByClass": {}, | ||||
canBarter: false, | "canBarter": false, | ||||
barterPrices: { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
"sell": { "food": 25 } | "sell": { "food": 25 } | ||||
}, | }, | ||||
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, | ||||
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: new Map(), | "researchQueued": new Map(), | ||||
researchStarted: new Set(), | "researchStarted": new Set(), | ||||
researchedTechs: new Set(), | "researchedTechs": new Set(), | ||||
classCounts: {}, | "classCounts": {}, | ||||
typeCountsByClass: {}, | "typeCountsByClass": {}, | ||||
canBarter: false, | "canBarter": false, | ||||
barterPrices: { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
"sell": { "food": 25 } | "sell": { "food": 25 } | ||||
}, | }, | ||||
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, | ||||
"victoryConditions": ["conquest", "wonder"], | "victoryConditions": ["conquest", "wonder"], | ||||
alliedVictory: false | "alliedVictory": false | ||||
}); | }); | ||||
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": new Map(), | "researchQueued": new Map(), | ||||
"researchStarted": new Set(), | "researchStarted": new Set(), | ||||
"researchedTechs": new Set(), | "researchedTechs": new Set(), | ||||
"classCounts": {}, | "classCounts": {}, | ||||
"typeCountsByClass": {}, | "typeCountsByClass": {}, | ||||
"canBarter": false, | "canBarter": false, | ||||
"barterPrices": { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
Show All 31 Lines | "players": [ | ||||
"teamPercentMapControlled": [0, 10], | "teamPercentMapControlled": [0, 10], | ||||
"peakPercentOfMapControlled": [0, 10], | "peakPercentOfMapControlled": [0, 10], | ||||
"teamPeakPercentOfMapControlled": [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": new Map(), | "researchQueued": new Map(), | ||||
"researchStarted": new Set(), | "researchStarted": new Set(), | ||||
"researchedTechs": new Set(), | "researchedTechs": new Set(), | ||||
"classCounts": {}, | "classCounts": {}, | ||||
"typeCountsByClass": {}, | "typeCountsByClass": {}, | ||||
"canBarter": false, | "canBarter": false, | ||||
"barterPrices": { | "barterPrices": { | ||||
"buy": { "food": 150 }, | "buy": { "food": 150 }, | ||||
Show All 37 Lines | TS_ASSERT_UNEVAL_EQUALS(cmp.GetExtendedSimulationState(), { | ||||
"circularMap": false, | "circularMap": false, | ||||
"timeElapsed": 0, | "timeElapsed": 0, | ||||
"victoryConditions": ["conquest", "wonder"], | "victoryConditions": ["conquest", "wonder"], | ||||
"alliedVictory": false | "alliedVictory": false | ||||
}); | }); | ||||
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; } | ||||
}); | }); | ||||
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; }, | ||||
IsUndeletable: function() { return false; } | "IsUndeletable": function() { return false; } | ||||
}); | }); | ||||
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 }; | ||||
}, | }, | ||||
IsInWorld: function() { | "IsInWorld": function() { | ||||
return true; | return true; | ||||
} | } | ||||
}); | }); | ||||
AddMock(10, IID_ResourceTrickle, { | AddMock(10, IID_ResourceTrickle, { | ||||
"GetTimer": () => 1250, | "GetTimer": () => 1250, | ||||
"GetRates": () => ({ "food": 2, "wood": 3, "stone": 5, "metal": 9 }) | "GetRates": () => ({ "food": 2, "wood": 3, "stone": 5, "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, | ||||
"player": INVALID_PLAYER, | "player": INVALID_PLAYER, | ||||
"template": "example", | "template": "example", | ||||
"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", | ||||
"canDelete": true | "canDelete": true | ||||
}, | }, | ||||
"position": {x:1, y:2, z:3}, | "position": { "x": 1, "y": 2, "z": 3 }, | ||||
"hitpoints": 50, | "hitpoints": 50, | ||||
"maxHitpoints": 60, | "maxHitpoints": 60, | ||||
"needsRepair": false, | "needsRepair": false, | ||||
"needsHeal": true, | "needsHeal": true, | ||||
"builder": true, | "builder": true, | ||||
"canGarrison": false, | "canGarrison": false, | ||||
"visibility": "visible", | "visibility": "visible", | ||||
"isBarterMarket":true, | "isBarterMarket": true, | ||||
"resourceTrickle": { | "resourceTrickle": { | ||||
"interval": 1250, | "interval": 1250, | ||||
"rates": { "food": 2, "wood": 3, "stone": 5, "metal": 9 } | "rates": { "food": 2, "wood": 3, "stone": 5, "metal": 9 } | ||||
} | } | ||||
}); | }); |
Wildfire Games · Phabricator