diff --git a/app/js/shipyard/factory-ship.js b/app/js/shipyard/factory-ship.js index 6ba28854..5b5dc81c 100755 --- a/app/js/shipyard/factory-ship.js +++ b/app/js/shipyard/factory-ship.js @@ -97,7 +97,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', this.bulkheads.c = null; this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true); this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0; - this.cargoScoop.enabled = enabled ? Boolean(enabled[0]) : true; + this.cargoScoop.enabled = enabled ? enabled[0] * true : true; for (i = 0, l = this.priorityBands.length; i < l; i++) { this.priorityBands[i].deployed = 0; @@ -111,7 +111,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', for (i = 0; i < cl; i++) { common[i].cat = 0; - common[i].enabled = enabled ? Boolean(enabled[i + 1]) : true; + common[i].enabled = enabled ? enabled[i + 1] * true : true; common[i].priority = priorities ? priorities[i + 1] * 1 : 0; common[i].type = 'SYS'; common[i].c = common[i].id = null; // Resetting 'old' component if there was one @@ -128,7 +128,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', for (i = 0, l = hps.length; i < l; i++) { hps[i].cat = 1; - hps[i].enabled = enabled ? Boolean(enabled[cl + i]) : true; + hps[i].enabled = enabled ? enabled[cl + i] * true : true; hps[i].priority = priorities ? priorities[cl + i] * 1 : 0; hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS'; hps[i].c = hps[i].id = null; // Resetting 'old' component if there was one @@ -143,7 +143,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', for (i = 0, l = internal.length; i < l; i++) { internal[i].cat = 2; - internal[i].enabled = enabled ? Boolean(enabled[cl + i]) : true; + internal[i].enabled = enabled ? enabled[cl + i] * true : true; internal[i].priority = priorities ? priorities[cl + i] * 1 : 0; internal[i].type = 'SYS'; internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one diff --git a/test/fixtures/anaconda-test-detailed-export.json b/test/fixtures/anaconda-test-detailed-export.json index 77ba16b4..748b8b46 100644 --- a/test/fixtures/anaconda-test-detailed-export.json +++ b/test/fixtures/anaconda-test-detailed-export.json @@ -5,8 +5,8 @@ "references": [ { "name": "Coriolis.io", - "url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b?bn=Test", - "code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b", + "url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA%3D%3D%3D.AwhMJBGaei%2BJCyyiA%3D%3D%3D?bn=Test", + "code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===", "shipId": "anaconda" } ], @@ -29,7 +29,7 @@ "class": 6, "rating": "A", "enabled": true, - "priority": 1 + "priority": 3 }, "lifeSupport": { "class": 5, @@ -61,7 +61,7 @@ "class": 4, "rating": "A", "enabled": true, - "priority": 1, + "priority": 2, "group": "Plasma Accelerator", "mount": "Fixed" }, @@ -69,7 +69,7 @@ "class": 3, "rating": "D", "enabled": true, - "priority": 1, + "priority": 2, "group": "Beam Laser", "mount": "Turret" }, @@ -77,7 +77,7 @@ "class": 3, "rating": "D", "enabled": true, - "priority": 1, + "priority": 2, "group": "Beam Laser", "mount": "Turret" }, @@ -85,7 +85,7 @@ "class": 3, "rating": "D", "enabled": true, - "priority": 1, + "priority": 2, "group": "Beam Laser", "mount": "Turret" }, @@ -93,7 +93,7 @@ "class": 2, "rating": "E", "enabled": true, - "priority": 1, + "priority": 2, "group": "Cannon", "mount": "Turret" }, @@ -101,7 +101,7 @@ "class": 2, "rating": "E", "enabled": true, - "priority": 1, + "priority": 2, "group": "Cannon", "mount": "Turret" }, @@ -109,7 +109,7 @@ "class": 1, "rating": "F", "enabled": true, - "priority": 1, + "priority": 2, "group": "Beam Laser", "mount": "Turret" }, @@ -117,7 +117,7 @@ "class": 1, "rating": "F", "enabled": true, - "priority": 1, + "priority": 2, "group": "Beam Laser", "mount": "Turret" } @@ -142,20 +142,20 @@ "class": 0, "rating": "C", "enabled": true, - "priority": 1, + "priority": 2, "group": "Kill Warrant Scanner" }, { "class": 0, "rating": "C", "enabled": true, - "priority": 1, + "priority": 2, "group": "Cargo Scanner" }, { "class": 0, "rating": "F", - "enabled": true, + "enabled": false, "priority": 1, "group": "Countermeasure", "name": "Electronic Countermeasure" @@ -172,7 +172,7 @@ "class": 0, "rating": "I", "enabled": true, - "priority": 1, + "priority": 2, "group": "Countermeasure", "name": "Point Defence" } @@ -233,14 +233,14 @@ "class": 4, "rating": "A", "enabled": true, - "priority": 1, + "priority": 3, "group": "Fuel Scoop" }, { "class": 2, "rating": "A", "enabled": true, - "priority": 1, + "priority": 3, "group": "FSD Interdictor" } ] @@ -270,7 +270,7 @@ "totalDps": 29, "powerAvailable": 36, "powerRetracted": 23.93, - "powerDeployed": 35.56, + "powerDeployed": 35.36, "unladenRange": 18.49, "fullTankRange": 18.12, "ladenRange": 16.39, diff --git a/test/tests/test-controller-import.js b/test/tests/test-controller-import.js index e66cf744..2a373559 100644 --- a/test/tests/test-controller-import.js +++ b/test/tests/test-controller-import.js @@ -108,7 +108,7 @@ describe('Import Controller', function() { expect(scope.processed).toBeTruthy(); scope.import(); expect(angular.fromJson(localStorage.getItem('builds'))).toEqual({ - anaconda: { 'Test': '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA=' } + anaconda: { 'Test': '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===' } }); }); diff --git a/test/tests/test-service-serializer.js b/test/tests/test-service-serializer.js index 25000896..2380d159 100644 --- a/test/tests/test-service-serializer.js +++ b/test/tests/test-service-serializer.js @@ -3,7 +3,7 @@ describe("Serializer Service", function() { var Ship, Serializer, - code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b', + code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18QDBNA===.AwhMJBGaei+JCyyiA===', anaconda = DB.ships['anaconda'], testBuild, exportData; @@ -21,13 +21,20 @@ describe("Serializer Service", function() { exportData = Serializer.toDetailedBuild('Test', testBuild, code); }); - it("conforms to the ship-loadout schema", function() { + it("conforms to the v1 ship-loadout schema", function() { var shipLoadoutSchema = __json__['schemas/ship-loadout/1']; var validate = jsen(shipLoadoutSchema); var valid = validate(exportData); expect(valid).toBeTruthy(); }); + it("conforms to the v2 ship-loadout schema", function() { + var shipLoadoutSchema = __json__['schemas/ship-loadout/2']; + var validate = jsen(shipLoadoutSchema); + var valid = validate(exportData); + expect(valid).toBeTruthy(); + }); + it("contains the correct components and stats", function() { var anacondaTestExport = __json__['fixtures/anaconda-test-detailed-export']; expect(exportData.components).toEqual(anacondaTestExport.components);