Pass tests.

This commit is contained in:
Jonathan Harris
2015-08-30 06:05:12 +01:00
parent bf47a81dc1
commit fda966be02
3 changed files with 78 additions and 16 deletions

View File

@@ -117,7 +117,7 @@ angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', '
var comps = detailedBuild.components; var comps = detailedBuild.components;
var priorities = [ 0 ]; // cargoScoop var priorities = [ 0 ]; // cargoScoop
var enabled = [ false ]; // assume cargoScoop disabled var enabled = [ true ]; // assume cargoScoop enabled
var shipData = ShipsDB[shipId]; var shipData = ShipsDB[shipId];
var ship = new Ship(shipId, shipData.properties, shipData.slots); var ship = new Ship(shipId, shipData.properties, shipData.slots);
var bulkheads = Components.bulkheadIndex(comps.standard.bulkheads); var bulkheads = Components.bulkheadIndex(comps.standard.bulkheads);
@@ -151,9 +151,9 @@ angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', '
priorities = priorities.concat(_.map(comps.hardpoints, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; }), priorities = priorities.concat(_.map(comps.hardpoints, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; }),
_.map(comps.utility, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; }), _.map(comps.utility, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; }),
_.map(comps.internal, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; })); _.map(comps.internal, function(c) { return (!c || c.priority === undefined) ? 0 : c.priority - 1; }));
enabled = enabled.concat(_.map(comps.hardpoints, function(c) { return (!c || c.enabled === undefined) ? false : c.enabled; }), enabled = enabled.concat(_.map(comps.hardpoints, function(c) { return (!c || c.enabled === undefined) ? true : c.enabled * 1; }),
_.map(comps.utility, function(c) { return (!c || c.enabled === undefined) ? false : c.enabled; }), _.map(comps.utility, function(c) { return (!c || c.enabled === undefined) ? true : c.enabled * 1; }),
_.map(comps.internal, function(c) { return (!c || c.enabled === undefined) ? false : c.enabled; })); _.map(comps.internal, function(c) { return (!c || c.enabled === undefined) ? true : c.enabled * 1; }));
ship.buildWith({ bulkheads: bulkheads, common: common, hardpoints: hardpoints, internal: internal }, priorities, enabled); ship.buildWith({ bulkheads: bulkheads, common: common, hardpoints: hardpoints, internal: internal }, priorities, enabled);

View File

@@ -97,7 +97,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.bulkheads.c = null; this.bulkheads.c = null;
this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true); this.useBulkhead(comps && comps.bulkheads ? comps.bulkheads : 0, true);
this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0; this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0;
this.cargoScoop.enabled = enabled ? enabled[0] * 1 : true; this.cargoScoop.enabled = enabled ? Boolean(enabled[0]) : true;
for (i = 0, l = this.priorityBands.length; i < l; i++) { for (i = 0, l = this.priorityBands.length; i < l; i++) {
this.priorityBands[i].deployed = 0; this.priorityBands[i].deployed = 0;
@@ -111,7 +111,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (i = 0; i < cl; i++) { for (i = 0; i < cl; i++) {
common[i].cat = 0; common[i].cat = 0;
common[i].enabled = enabled ? enabled[i + 1] * 1 : true; common[i].enabled = enabled ? Boolean(enabled[i + 1]) : true;
common[i].priority = priorities ? priorities[i + 1] * 1 : 0; common[i].priority = priorities ? priorities[i + 1] * 1 : 0;
common[i].type = 'SYS'; common[i].type = 'SYS';
common[i].c = common[i].id = null; // Resetting 'old' component if there was one 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++) { for (i = 0, l = hps.length; i < l; i++) {
hps[i].cat = 1; hps[i].cat = 1;
hps[i].enabled = enabled ? enabled[cl + i] * 1 : true; hps[i].enabled = enabled ? Boolean(enabled[cl + i]) : true;
hps[i].priority = priorities ? priorities[cl + i] * 1 : 0; hps[i].priority = priorities ? priorities[cl + i] * 1 : 0;
hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS'; hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS';
hps[i].c = hps[i].id = null; // Resetting 'old' component if there was one 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++) { for (i = 0, l = internal.length; i < l; i++) {
internal[i].cat = 2; internal[i].cat = 2;
internal[i].enabled = enabled ? enabled[cl + i] * 1 : true; internal[i].enabled = enabled ? Boolean(enabled[cl + i]) : true;
internal[i].priority = priorities ? priorities[cl + i] * 1 : 0; internal[i].priority = priorities ? priorities[cl + i] * 1 : 0;
internal[i].type = 'SYS'; internal[i].type = 'SYS';
internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one

View File

@@ -1,5 +1,5 @@
{ {
"$schema": "http://cdn.coriolis.io/schemas/ship-loadout/1.json#", "$schema": "http://cdn.coriolis.io/schemas/ship-loadout/2.json#",
"name": "Test", "name": "Test",
"ship": "Anaconda", "ship": "Anaconda",
"references": [ "references": [
@@ -15,79 +15,109 @@
"bulkheads": "Reactive Surface Composite", "bulkheads": "Reactive Surface Composite",
"powerPlant": { "powerPlant": {
"class": 8, "class": 8,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"thrusters": { "thrusters": {
"class": 6, "class": 6,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"frameShiftDrive": { "frameShiftDrive": {
"class": 6, "class": 6,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"lifeSupport": { "lifeSupport": {
"class": 5, "class": 5,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"powerDistributor": { "powerDistributor": {
"class": 8, "class": 8,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"sensors": { "sensors": {
"class": 8, "class": 8,
"rating": "A" "rating": "A",
"enabled": true,
"priority": 1
}, },
"fuelTank": { "fuelTank": {
"class": 5, "class": 5,
"rating": "C" "rating": "C",
"enabled": true,
"priority": 1
} }
}, },
"hardpoints": [ "hardpoints": [
{ {
"class": 4, "class": 4,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Plasma Accelerator", "group": "Plasma Accelerator",
"mount": "Fixed" "mount": "Fixed"
}, },
{ {
"class": 3, "class": 3,
"rating": "D", "rating": "D",
"enabled": true,
"priority": 1,
"group": "Beam Laser", "group": "Beam Laser",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 3, "class": 3,
"rating": "D", "rating": "D",
"enabled": true,
"priority": 1,
"group": "Beam Laser", "group": "Beam Laser",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 3, "class": 3,
"rating": "D", "rating": "D",
"enabled": true,
"priority": 1,
"group": "Beam Laser", "group": "Beam Laser",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 2, "class": 2,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cannon", "group": "Cannon",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 2, "class": 2,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cannon", "group": "Cannon",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 1, "class": 1,
"rating": "F", "rating": "F",
"enabled": true,
"priority": 1,
"group": "Beam Laser", "group": "Beam Laser",
"mount": "Turret" "mount": "Turret"
}, },
{ {
"class": 1, "class": 1,
"rating": "F", "rating": "F",
"enabled": true,
"priority": 1,
"group": "Beam Laser", "group": "Beam Laser",
"mount": "Turret" "mount": "Turret"
} }
@@ -96,39 +126,53 @@
{ {
"class": 0, "class": 0,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Shield Booster" "group": "Shield Booster"
}, },
{ {
"class": 0, "class": 0,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Shield Booster" "group": "Shield Booster"
}, },
null, null,
{ {
"class": 0, "class": 0,
"rating": "C", "rating": "C",
"enabled": true,
"priority": 1,
"group": "Kill Warrant Scanner" "group": "Kill Warrant Scanner"
}, },
{ {
"class": 0, "class": 0,
"rating": "C", "rating": "C",
"enabled": true,
"priority": 1,
"group": "Cargo Scanner" "group": "Cargo Scanner"
}, },
{ {
"class": 0, "class": 0,
"rating": "F", "rating": "F",
"enabled": true,
"priority": 1,
"group": "Countermeasure", "group": "Countermeasure",
"name": "Electronic Countermeasure" "name": "Electronic Countermeasure"
}, },
{ {
"class": 0, "class": 0,
"rating": "I", "rating": "I",
"enabled": true,
"priority": 1,
"group": "Countermeasure", "group": "Countermeasure",
"name": "Chaff Launcher" "name": "Chaff Launcher"
}, },
{ {
"class": 0, "class": 0,
"rating": "I", "rating": "I",
"enabled": true,
"priority": 1,
"group": "Countermeasure", "group": "Countermeasure",
"name": "Point Defence" "name": "Point Defence"
} }
@@ -137,26 +181,36 @@
{ {
"class": 7, "class": 7,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Shield Generator" "group": "Shield Generator"
}, },
{ {
"class": 6, "class": 6,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Shield Cell Bank" "group": "Shield Cell Bank"
}, },
{ {
"class": 6, "class": 6,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cargo Rack" "group": "Cargo Rack"
}, },
{ {
"class": 5, "class": 5,
"rating": "D", "rating": "D",
"enabled": true,
"priority": 1,
"group": "Hull Reinforcement Package" "group": "Hull Reinforcement Package"
}, },
{ {
"class": 5, "class": 5,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cargo Rack" "group": "Cargo Rack"
}, },
null, null,
@@ -164,21 +218,29 @@
{ {
"class": 4, "class": 4,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cargo Rack" "group": "Cargo Rack"
}, },
{ {
"class": 4, "class": 4,
"rating": "E", "rating": "E",
"enabled": true,
"priority": 1,
"group": "Cargo Rack" "group": "Cargo Rack"
}, },
{ {
"class": 4, "class": 4,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "Fuel Scoop" "group": "Fuel Scoop"
}, },
{ {
"class": 2, "class": 2,
"rating": "A", "rating": "A",
"enabled": true,
"priority": 1,
"group": "FSD Interdictor" "group": "FSD Interdictor"
} }
] ]