Compare commits

...

15 Commits
1.1.0 ... 1.3.0

Author SHA1 Message Date
Colin McLeod
f0bdcd5557 Bumping version to 1.3.0 2015-07-20 13:42:38 -07:00
Colin McLeod
b1ee0e44f3 Linting fixes, update unit test 2015-07-20 13:42:21 -07:00
Colin McLeod
c96e6afbd7 Power Distributor required for Boost. Resolves #17 2015-07-20 13:37:03 -07:00
Colin McLeod
77334341ea Armour value improved by bulkhead 2015-07-20 00:55:51 -07:00
Colin McLeod
5f22743778 Bumping to version 1.2.0 2015-07-19 22:30:30 -07:00
Colin McLeod
03986cb88a Massive refactor for 3rd party import 2015-07-19 21:32:14 -07:00
Colin McLeod
c796adf40d Add Persist.getAll for backup purposes 2015-07-18 16:50:50 -07:00
Colin McLeod
2890ff5537 Add description to export modal 2015-07-18 16:50:03 -07:00
Colin McLeod
a6ba61a2bf Change loadout schema slightly 2015-07-18 14:46:22 -07:00
Colin McLeod
db5e080992 Change meta description 2015-07-18 14:45:36 -07:00
Colin McLeod
63d7f98e2c Fix total jump range calculation bug 2015-07-18 14:45:08 -07:00
Colin McLeod
7997ff6ae9 Correct Beta insurance rate 2015-07-17 09:07:16 -07:00
Colin McLeod
b3126cf6b6 Renaming data test for consistency 2015-07-15 21:11:23 -07:00
Colin McLeod
ab1ea53ce3 Implement export for 3rd Party sites 2015-07-15 16:13:17 -07:00
Colin McLeod
82a87cb653 Adjust select menu size for smaller windows 2015-07-15 15:31:40 -07:00
84 changed files with 4652 additions and 210 deletions

View File

@@ -5,7 +5,7 @@
<link rel="stylesheet" href="/app.css">
<!-- Standard headers -->
<meta name="description" content="A ship outfitting and comparison tool for Elite Dangerous">
<meta name="description" content="A ship builder, outfitting and comparison tool for Elite Dangerous">
<meta name="mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="manifest" href="/images/logo/manifest.json">

View File

@@ -38,7 +38,7 @@ function($rootScope, $location, $window, $doc, $state, CArr, sz, hpc, GroupMap,
$rootScope.SZ = sz;
$rootScope.HPC = hpc;
$rootScope.GMAP = GroupMap;
$rootScope.insurance = { opts: [{ name: 'Standard', pct: 0.05 }, { name: 'Alpha', pct: 0.025 }, { name: 'Beta', pct: 0.035 }] };
$rootScope.insurance = { opts: [{ name: 'Standard', pct: 0.05 }, { name: 'Alpha', pct: 0.025 }, { name: 'Beta', pct: 0.0375 }] };
$rootScope. discounts = { opts: Discounts };
$rootScope.STATUS = ['', 'DISABLED', 'OFF', 'ON'];
$rootScope.STATUS_CLASS = ['', 'disabled', 'warning', 'secondary-disabled'];

View File

@@ -46,7 +46,7 @@ angular.module('app').config(['$provide', '$stateProvider', '$urlRouterProvider'
// Modal States and views
.state('modal', { abstract: true, views: { 'modal': { templateUrl: 'views/_modal.html', controller: 'ModalController' } } })
.state('modal.about', { views: { 'modal-content': { templateUrl: 'views/modal-about.html' } } })
.state('modal.export', { params: { title: null, data: null, promise: null }, views: { 'modal-content': { templateUrl: 'views/modal-export.html', controller: 'ExportController' } } })
.state('modal.export', { params: { title: null, data: null, promise: null, description: null }, views: { 'modal-content': { templateUrl: 'views/modal-export.html', controller: 'ExportController' } } })
.state('modal.import', { params: { obj: null }, views: { 'modal-content': { templateUrl: 'views/modal-import.html', controller: 'ImportController' } } })
.state('modal.link', { params: { url: null }, views: { 'modal-content': { templateUrl: 'views/modal-link.html', controller: 'LinkController' } } })
.state('modal.delete', { views: { 'modal-content': { templateUrl: 'views/modal-delete.html', controller: 'DeleteController' } } });

View File

@@ -1,11 +1,12 @@
angular.module('app').controller('ExportController', ['$scope', '$stateParams', function($scope, $stateParams) {
$scope.title = $stateParams.title || 'Export';
$scope.description = $stateParams.description;
if ($stateParams.promise) {
$scope.export = 'Generating...';
$stateParams.promise.then(function(data) {
$scope.export = data;
$scope.export = (typeof data === 'object') ? angular.toJson(data, true) : data;
});
} else {
$scope.export = angular.toJson($stateParams.data, true);

View File

@@ -1,57 +1,111 @@
angular.module('app').controller('ImportController', ['$scope', '$stateParams', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function($scope, $stateParams, Ships, Ship, Persist, Serializer) {
angular.module('app').controller('ImportController', ['lodash', '$rootScope', '$scope', '$stateParams', 'ShipsDB', 'Ship', 'Persist', 'Serializer', function(_, $rootScope, $scope, $stateParams, Ships, Ship, Persist, Serializer) {
$scope.jsonValid = false;
$scope.importData = null;
$scope.importJSON = null;
$scope.errorMsg = null;
$scope.canEdit = true;
$scope.builds = $stateParams.obj || null;
$scope.ships = Ships;
$scope.validateJson = function() {
var importObj = null;
$scope.jsonValid = false;
$scope.errorMsg = null;
$scope.builds = null;
function validateBuild(shipId, code, name) {
var shipData = Ships[shipId];
if (!$scope.importData) { return; }
if (!shipData) {
throw '"' + shipId + '" is not a valid Ship Id!';
}
if (typeof name != 'string' || name.length < 3) {
throw shipData.properties.name + ' build "' + name + '" must be a string at least 3 characters long!';
}
if (typeof code != 'string' || code.length < 10) {
throw shipData.properties.name + ' build "' + name + '" is not valid!';
}
try {
Serializer.toShip(new Ship(shipId, shipData.properties, shipData.slots), code);
} catch (e) {
throw shipData.properties.name + ' build "' + name + '" is not valid!';
}
}
function detailedJsonToBuild(detailedBuild) {
var ship;
if (!detailedBuild.name) {
throw 'Build Name missing!';
}
try {
importObj = angular.fromJson($scope.importData);
ship = Serializer.fromDetailedBuild(detailedBuild);
} catch (e) {
throw detailedBuild.ship + ' Build "' + detailedBuild.name + '": Invalid data';
}
return { shipId: ship.id, name: detailedBuild.name, code: Serializer.fromShip(ship) };
}
function importBackup(importData) {
if (importData.builds && typeof importData.builds == 'object') {
for (var shipId in importData.builds) {
for (var buildName in importData.builds[shipId]) {
validateBuild(shipId, importData.builds[shipId][buildName], buildName);
}
}
$scope.builds = importData.builds;
} else {
throw 'builds must be an object!';
}
if (importData.comparisons) {
// TODO: check ship/builds exist for comparison
$scope.comparisons = importData.comparisons;
}
if (importData.discounts instanceof Array && importData.discounts.length == 2) {
$scope.discounts = importData.discounts;
}
if (typeof importData.insurance == 'string' && importData.insurance.length > 3) {
$scope.insurance = importData.insurance;
}
}
function importDetailedArray(importArr) {
var builds = {};
for (var i = 0, l = importArr.length; i < l; i++) {
var build = detailedJsonToBuild(importArr[i]);
if (!builds[build.shipId]) {
builds[build.shipId] = {};
}
builds[build.shipId][build.name] = build.code;
}
$scope.builds = builds;
}
$scope.validateJson = function() {
var importData = null;
$scope.jsonValid = false;
$scope.errorMsg = null;
$scope.builds = $scope.discounts = $scope.comparisons = $scope.insurance = null;
if (!$scope.importJSON) { return; }
try {
importData = angular.fromJson($scope.importJSON);
} catch (e) {
$scope.errorMsg = 'Cannot Parse JSON!';
return;
}
if (typeof importObj != 'object') {
$scope.errorMsg = 'Must be an object!';
if (!importData || typeof importData != 'object') {
$scope.errorMsg = 'Must be an object or array!';
return;
}
if ((!importObj.builds || !Object.keys(importObj.builds).length)) {
$scope.errorMsg = 'No builds in data';
return;
}
for (var shipId in importObj.builds) {
var shipData = Ships[shipId];
if (shipData) {
for (var buildName in importObj.builds[shipId]) {
if (typeof importObj.builds[shipId][buildName] != 'string') {
$scope.errorMsg = shipData.properties.name + ' build "' + buildName + '" must be a string!';
return;
}
try {
// Actually build the ship with the code to ensure it's valid
Serializer.toShip(new Ship(shipId, shipData.properties, shipData.slots), importObj.builds[shipId][buildName]);
} catch (e) {
$scope.errorMsg = shipData.properties.name + ' build "' + buildName + '" is not valid!';
return;
}
}
} else {
$scope.errorMsg = '"' + shipId + '"" is not a valid Ship Id!';
return;
try {
if (importData instanceof Array) { // Must be detailed export json
importDetailedArray(importData);
} else if (importData.ship && importData.name) { // Using JSON from a single ship build export
importDetailedArray([importData]); // Convert to array with singleobject
} else { // Using Backup JSON
importBackup(importData);
}
$scope.builds = importObj.builds;
} catch (e) {
$scope.errorMsg = e;
return;
}
$scope.jsonValid = true;
@@ -61,32 +115,73 @@ angular.module('app').controller('ImportController', ['$scope', '$stateParams',
return Persist.getBuild(shipId, name) !== null;
};
$scope.hasComparison = function(name) {
return Persist.getComparison(name) !== null;
};
$scope.process = function() {
var builds = $scope.builds;
for (var shipId in builds) {
for (var buildName in builds[shipId]) {
var code = builds[shipId][buildName];
// Update builds object such that orginal name retained, but can be renamed
builds[shipId][buildName] = {
code: code,
useName: buildName
};
if ($scope.builds) {
var builds = $scope.builds;
for (var shipId in builds) {
for (var buildName in builds[shipId]) {
var code = builds[shipId][buildName];
// Update builds object such that orginal name retained, but can be renamed
builds[shipId][buildName] = {
code: code,
useName: buildName
};
}
}
}
if ($scope.comparisons) {
var comparisons = $scope.comparisons;
for (var name in comparisons) {
comparisons[name].useName = name;
}
}
$scope.processed = true;
};
$scope.import = function() {
var builds = $scope.builds;
for (var shipId in builds) {
for (var buildName in builds[shipId]) {
var build = builds[shipId][buildName];
var name = build.useName.trim();
if (name) {
Persist.saveBuild(shipId, name, build.code);
if ($scope.builds) {
var builds = $scope.builds;
for (var shipId in builds) {
for (var buildName in builds[shipId]) {
var build = builds[shipId][buildName];
var name = build.useName.trim();
if (name) {
Persist.saveBuild(shipId, name, build.code);
}
}
}
}
if ($scope.comparisons) {
var comparisons = $scope.comparisons;
for (var comp in comparisons) {
var comparison = comparisons[comp];
var useName = comparison.useName.trim();
if (useName) {
Persist.saveComparison(useName, comparison.builds, comparison.facets);
}
}
}
if ($scope.discounts) {
$rootScope.discounts.ship = $scope.discounts[0];
$rootScope.discounts.components = $scope.discounts[1];
$rootScope.$broadcast('discountChange');
Persist.setDiscount($scope.discounts);
}
if ($scope.insurance) {
$rootScope.insurance.current = $scope.insurance;
Persist.setInsurance($scope.insurance);
}
$scope.$parent.dismiss();
};

View File

@@ -219,12 +219,9 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
if ($scope.buildName) {
$state.go('modal.export', {
data: Serializer.toJsonBuild(
$scope.buildName,
ship,
$state.href($state.current.name, $state.params, { absolute: true }),
$scope.code || Serializer.fromShip(ship)
)
title: $scope.buildName + ' Export',
description: 'A detailed JSON export of your build for use in other sites and tools',
data: Serializer.toDetailedBuild($scope.buildName, ship, $scope.code || Serializer.fromShip(ship))
});
}
};
@@ -374,6 +371,10 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.costTab = tab;
};
$scope.pdWarning = function(pd) {
return pd.enginecapacity < ship.boostEnergy;
};
// Hide any open menu/slot/etc if the background is clicked
$scope.$on('close', function() {
$scope.selectedSlot = null;

View File

@@ -2,7 +2,7 @@ angular.module('app').directive('componentSelect', function() {
// Generting the HTML in this manner is MUCH faster than using an angular template.
function appendGroup(list, opts, cid, mass) {
function appendGroup(list, opts, cid, mass, checkWarning) {
var prevClass = null, prevRating = null;
for (var i = 0; i < opts.length; i++) {
var o = opts[i];
@@ -18,6 +18,10 @@ angular.module('app').directive('componentSelect', function() {
list.push(' active');
}
if (checkWarning && checkWarning(opts[i])) {
list.push(' warning');
}
list.push((o.maxmass && mass > o.maxmass) ? ' disabled"' : '" cpid="', id, '">');
if (o.mode) {
@@ -47,7 +51,8 @@ angular.module('app').directive('componentSelect', function() {
opts: '=', // Component Options object
groups: '=', // Groups of Component Options
mass: '=', // Current ship unladen mass
s: '=' // Current Slot
s: '=', // Current Slot
warning: '=' // Check warning function
},
link: function(scope, element) {
var list = [];
@@ -64,12 +69,12 @@ angular.module('app').directive('componentSelect', function() {
var grp = groups[g];
var grpCode = grp[Object.keys(grp)[0]].grp; // Nasty operation to get the grp property of the first/any single component
list.push('<div id="', grpCode, '" class="select-group">', g, '</div><ul>');
appendGroup(list, grp, cid, mass);
appendGroup(list, grp, cid, mass, scope.warning);
list.push('</ul>');
}
} else {
list.push('<ul>');
appendGroup(list, opts, cid, mass);
appendGroup(list, opts, cid, mass, scope.warning);
list.push('</ul>');
}

View File

@@ -1,4 +1,4 @@
angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Persist', 'ShipsDB', function(_, $rootScope, Persist, ships) {
angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', '$state', 'Persist', 'Serializer', 'ShipsDB', function(_, $rootScope, $state, Persist, Serializer, ships) {
return {
restrict: 'E',
@@ -18,17 +18,6 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
$rootScope.discounts.ship = savedDiscounts[0];
$rootScope.discounts.components = savedDiscounts[1];
// Close menus if a navigation change event occurs
$rootScope.$on('$stateChangeStart', function() {
scope.openedMenu = null;
});
// Listen to close event to close opened menus or modals
$rootScope.$on('close', function() {
scope.openedMenu = null;
$rootScope.showAbout = false;
});
/**
* Save selected insurance option
*/
@@ -44,6 +33,28 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
$rootScope.$broadcast('discountChange');
};
scope.backup = function(e) {
e.preventDefault();
e.stopPropagation();
scope.openedMenu = null;
$state.go('modal.export', {
title: 'Backup',
data: Persist.getAll(),
description: 'Backup of all Coriolis data to save or transfer to another browser/device'
});
};
scope.detailedExport = function(e) {
e.preventDefault();
e.stopPropagation();
scope.openedMenu = null;
$state.go('modal.export', {
title: 'Detailed Export',
data: Serializer.toDetailedExport(scope.allBuilds),
description: 'Detailed export of all builds for use with other tools and sites'
});
};
scope.openMenu = function(e, menu) {
e.stopPropagation();
if (menu == scope.openedMenu) {
@@ -58,16 +69,15 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
scope.openedMenu = menu;
};
scope.about = function(e) {
e.preventDefault();
e.stopPropagation();
// Close menus if a navigation change event occurs
$rootScope.$on('$stateChangeStart', function() {
scope.openedMenu = null;
$rootScope.showAbout = true;
};
});
$rootScope.hideAbout = function() {
$rootScope.showAbout = false;
};
// Listen to close event to close opened menus or modals
$rootScope.$on('close', function() {
scope.openedMenu = null;
});
scope.$watchCollection('allBuilds', function() {
scope.buildsList = Object.keys(scope.allBuilds).sort();

View File

@@ -4,6 +4,9 @@
angular.module('app').service('Persist', ['$window', 'lodash', function($window, _) {
var LS_KEY_BUILDS = 'builds';
var LS_KEY_COMPARISONS = 'comparisons';
var LS_KEY_COST_TAB = 'costTab';
var LS_KEY_INSURANCE = 'insurance';
var LS_KEY_DISCOUNTS = 'discounts';
var localStorage = $window.localStorage;
var buildJson = null;
var comparisonJson = null;
@@ -117,7 +120,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
}
this.comparisons[name] = {
facets: facets,
builds: _.map(builds, function(b) { return { shipId: b.id, buildName: b.buildName }; })
builds: _.map(builds, function(b) { return { shipId: b.id || b.shipId, buildName: b.buildName }; })
};
localStorage.setItem(LS_KEY_COMPARISONS, angular.toJson(this.comparisons));
this.state.hasComparisons = true;
@@ -162,13 +165,23 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
}
};
this.getAll = function() {
var data = {};
data[LS_KEY_BUILDS] = this.builds;
data[LS_KEY_COMPARISONS] = this.comparisons;
data[LS_KEY_INSURANCE] = this.getInsurance();
data[LS_KEY_DISCOUNTS] = this.getDiscount();
return data;
};
/**
* Get the saved insurance type
* @return {string} The name of the saved insurance type of null
*/
this.getInsurance = function() {
if (this.lsEnabled) {
return localStorage.getItem('insurance');
return localStorage.getItem(LS_KEY_INSURANCE);
}
return null;
};
@@ -179,7 +192,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
*/
this.setInsurance = function(name) {
if (this.lsEnabled) {
return localStorage.setItem('insurance', name);
return localStorage.setItem(LS_KEY_INSURANCE, name);
}
};
@@ -189,7 +202,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
*/
this.setDiscount = function(val) {
if (this.lsEnabled) {
return localStorage.setItem('discounts', angular.toJson(val));
return localStorage.setItem(LS_KEY_DISCOUNTS, angular.toJson(val));
}
};
@@ -199,7 +212,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
*/
this.getDiscount = function() {
if (this.lsEnabled) {
return angular.fromJson(localStorage.getItem('discounts'));
return angular.fromJson(localStorage.getItem(LS_KEY_DISCOUNTS));
}
return null;
};
@@ -210,7 +223,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
*/
this.setCostTab = function(tabName) {
if (this.lsEnabled) {
return localStorage.setItem('costTab', tabName);
return localStorage.setItem(LS_KEY_COST_TAB, tabName);
}
};
@@ -220,7 +233,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
*/
this.getCostTab = function() {
if (this.lsEnabled) {
return localStorage.getItem('costTab');
return localStorage.getItem(LS_KEY_COST_TAB);
}
return null;
};

View File

@@ -1,7 +1,7 @@
/**
* Service managing seralization and deserialization of models for use in URLs and persistene.
*/
angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', function(_, GroupMap, MountMap) {
angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', 'ShipsDB', 'Ship', 'Components', '$state', function(_, GroupMap, MountMap, ShipsDB, Ship, Components, $state) {
/**
* Serializes the ships selected components for all slots to a URL friendly string.
@@ -66,18 +66,18 @@ angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', f
);
};
this.toJsonBuild = function(buildName, ship, url, code) {
this.toDetailedBuild = function(buildName, ship, code) {
var standard = ship.common,
hardpoints = ship.hardpoints,
internal = ship.internal;
var data = {
$schema: 'http://cdn.coriolis.io/schemas/ship-loadout/1-draft.json#',
$schema: 'http://cdn.coriolis.io/schemas/ship-loadout/1.json#',
name: buildName,
ship: ship.name,
references: [{
name: 'Coriolis.io',
url: url,
url: $state.href('outfit', { shipId: ship.id, code: code, bn: buildName }, { absolute: true }),
code: code,
shipId: ship.id
}],
@@ -108,6 +108,61 @@ angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', f
return data;
};
this.fromDetailedBuild = function(detailedBuild) {
var shipId = _.findKey(ShipsDB, { properties: { name: detailedBuild.ship } });
if (!shipId) {
throw 'No such ship: ' + detailedBuild.ship;
}
var comps = detailedBuild.components;
var shipData = ShipsDB[shipId];
var ship = new Ship(shipId, shipData.properties, shipData.slots);
var bulkheads = Components.bulkheadIndex(comps.standard.bulkheads);
if (bulkheads < 0) {
throw 'Invalid bulkheads: ' + comps.standard.bulkheads;
}
var common = _.map(
['powerPlant', 'thrusters', 'frameShiftDrive', 'lifeSupport', 'powerDistributor', 'sensors', 'fuelTank'],
function(c) {
if (!comps.standard[c].class || !comps.standard[c].rating) {
throw 'Invalid value for ' + c;
}
return comps.standard[c].class + comps.standard[c].rating;
}
);
var internal = _.map(comps.internal, function(c) { return c ? Components.findInternalId(c.group, c.class, c.rating, c.name) : 0; });
var hardpoints = _.map(comps.hardpoints, function(c) {
return c ? Components.findHardpointId(c.group, c.class, c.rating, c.name, MountMap[c.mount], c.missile) : 0;
});
hardpoints = hardpoints.concat(_.map(comps.utility, function(c) {
return c ? Components.findHardpointId(c.group, c.class, c.rating, c.name, MountMap[c.mount]) : 0;
}));
ship.buildWith({ bulkheads: bulkheads, common: common, hardpoints: hardpoints, internal: internal });
return ship;
};
this.toDetailedExport = function(builds) {
var data = [];
for (var shipId in builds) {
for (var buildName in builds[shipId]) {
var code = builds[shipId][buildName];
var shipData = ShipsDB[shipId];
var ship = new Ship(shipId, shipData.properties, shipData.slots);
this.toShip(ship, code);
data.push(this.toDetailedBuild(buildName, ship, code));
}
}
return data;
};
this.fromComparison = function(name, builds, facets, predicate, desc) {
var shipBuilds = [];
@@ -165,6 +220,9 @@ angular.module('app').service('Serializer', ['lodash', 'GroupMap', 'MountMap', f
if (slot.c.mode) {
o.mount = MountMap[slot.c.mode];
}
if (slot.c.missile) {
o.missile = slot.c.missile;
}
return o;
}
return null;

View File

@@ -1,4 +1,4 @@
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, _) {
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'lodash', 'ArmourMultiplier', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, _, ArmourMultiplier) {
/**
* Returns the power usage type of a slot and it's particular component
@@ -84,10 +84,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.cargoCapacity = 0;
this.ladenMass = 0;
this.armourAdded = 0;
this.armourMultiplier = 1;
this.shieldMultiplier = 1;
this.totalCost = this.c.incCost ? this.c.discountedCost : 0;
this.unladenMass = this.hullMass;
this.armour = this.baseArmour;
this.totalDps = 0;
this.bulkheads.c = null;
@@ -158,6 +158,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.bulkheads.id = index;
this.bulkheads.c = Components.bulkheads(this.id, index);
this.bulkheads.discountedCost = this.bulkheads.c.cost * this.componentCostMultiplier;
this.armourMultiplier = ArmourMultiplier[index];
this.updateStats(this.bulkheads, this.bulkheads.c, oldBulkhead, preventUpdate);
};
@@ -359,7 +360,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
}
this.ladenMass = this.unladenMass + this.cargoCapacity + this.fuelCapacity;
this.armour = this.armourAdded + this.baseArmour;
this.armour = this.armourAdded + Math.round(this.baseArmour * this.armourMultiplier);
if (!preventUpdate) {
if (powerChange) {

View File

@@ -10,6 +10,13 @@ angular.module('shipyard', ['ngLodash'])
// Create 'angularized' references to DB.This will aid testing
.constant('ShipsDB', DB.ships)
.constant('ComponentsDB', DB.components)
.value('ArmourMultiplier', [
1, // Lightweight
1.4, // Reinforced
1.945, // Military
1.945, // Mirrored
1.945 // Reactive
])
.value('commonArray', [
'Power Plant',
'Thrusters',
@@ -32,7 +39,7 @@ angular.module('shipyard', ['ngLodash'])
// Internal
fs: 'Fuel Scoop',
sc: 'Scanners',
sc: 'Scanner',
am: 'Auto Field-Maintenance Unit',
cr: 'Cargo Rack',
fi: 'FSD Interdictor',
@@ -69,7 +76,10 @@ angular.module('shipyard', ['ngLodash'])
.value('MountMap', {
'F': 'Fixed',
'G': 'Gimballed',
'T': 'Turret'
'T': 'Turret',
'Fixed': 'F',
'Gimballed': 'G',
'Turret': 'T'
})
.value('shipSize', [
'N/A',
@@ -205,13 +215,13 @@ angular.module('shipyard', ['ngLodash'])
*/
.value('calcTotalRange', function(mass, fsd, fuel) {
var fuelRemaining = fuel % fsd.maxfuel; // Fuel left after making N max jumps
var jumps = fuel / fsd.maxfuel;
var jumps = Math.floor(fuel / fsd.maxfuel);
mass += fuelRemaining;
// Going backwards, start with the last jump using the remaining fuel
var totalRange = fuelRemaining > 0 ? Math.pow(fuelRemaining / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass : 0;
// For each max fuel jump, calculate the max jump range based on fuel left in the tank
for (var j = 0, l = Math.floor(jumps); j < l; j++) {
fuelRemaining += fsd.maxfuel;
// For each max fuel jump, calculate the max jump range based on fuel mass left in the tank
for (var j = 0; j < jumps; j++) {
mass += fsd.maxfuel;
totalRange += Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
}
return totalRange;

View File

@@ -32,6 +32,41 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
return null;
};
this.findInternalId = function(groupName, clss, rating, name) {
var group = C.internal[groupName];
if (!group) {
throw 'Invalid internal group: ' + groupName;
}
for (var i = 0, l = group.length; i < l; i++) {
if (group[i].class == clss && group[i].rating == rating && ((!name && !group[i].name) || group[i].name == name)) {
return group[i].id;
}
}
return 0;
};
this.findHardpointId = function(groupName, clss, rating, name, mode, missile) {
var group = C.hardpoints[groupName];
if (!group) {
throw 'Invalid hardpoint group: ' + groupName;
}
for (var i = 0, l = group.length; i < l; i++) {
if (group[i].class == clss && group[i].rating == rating && group[i].mode == mode
&& ((!name && !group[i].name) || group[i].name == name)
&& ((!missile && !group[i].missile) || group[i].missile == missile)
) {
return group[i].id;
}
}
return 0;
};
/**
* Looks up the bulkhead component for a specific ship and bulkhead
* @param {string} shipId Unique ship Id/Key
@@ -42,6 +77,10 @@ angular.module('shipyard').service('Components', ['lodash', 'ComponentsDB', 'Shi
return C.bulkheads[shipId][bulkheadsId];
};
this.bulkheadIndex = function(bulkheadName) {
return ['Lightweight Alloy', 'Reinforced Alloy', 'Military Grade Composite', 'Mirrored Surface Composite', 'Reactive Surface Composite'].indexOf(bulkheadName);
};
/**
* Creates a new ComponentSet that contains all available components
* that the specified ship is eligible to use.

View File

@@ -66,3 +66,7 @@
color: @warning-disabled;
fill: @warning-disabled;
}
.bg-warning-disabled {
background-color: @warning-disabled;
}

View File

@@ -29,7 +29,7 @@ select {
padding: 0.5em 0;
width: 100%;
margin: 0;
max-height: 550px;
max-height: 400px;
overflow-y: auto;
overflow-x: hidden;
z-index: 0;
@@ -77,18 +77,10 @@ select {
stroke: @primary-disabled;
&:hover {
border-color: @primary;
color: @primary;
stroke: @primary;
}
&.disabled {
cursor: not-allowed;
color: @disabled;
stroke: @disabled;
}
&.active {
color: @secondary;
stroke: @secondary;
}
}
.lc, .c {
@@ -96,15 +88,27 @@ select {
padding: 0.1em 0.2em;
margin: 0.3em;
&:hover {
border:1px solid @primary;
&.warning {
border-color: @warning-disabled;
color: @warning-disabled;
stroke: @warning-disabled;
&:hover {
border-color: @warning;
color: @warning;
stroke: @warning;
}
}
&.disabled {
border:1px solid @disabled;
border-color: @disabled;
color: @disabled;
stroke: @disabled;
}
&.active {
border:1px solid @secondary;
border-color: @secondary;
color: @secondary;
stroke: @secondary;
}
}

View File

@@ -24,8 +24,9 @@
"description": "3rd Party references and/or links to this build/loadout",
"type": "array",
"items": {
"type": "object",
"required": ["name","url"],
"type": "object",
"required": ["name","url"],
"additionalProperties": true,
"properties": {
"name": {
"description": "The name of the 3rd party, .e.g 'Coriolis.io' or 'E:D Shipyard'",
@@ -34,13 +35,6 @@
"url": {
"description": "The link/url to the 3rd party referencing this build/loadout",
"type": "string"
},
"shipId": {
"type": "string"
},
"code": {
"description": "The serialized code or string for the build/loadout",
"type": "string"
}
}
}

View File

@@ -63,7 +63,8 @@
<hr />
<ul>
Builds & Comparisons
<li><a href="#" class="block" ui-sref="modal.export({data: {builds: allBuilds}})">Export</a></li>
<li><a href="#" class="block" ng-click="backup($event)">Backup</a></li>
<li><a href="#" class="block" ng-click="detailedExport($event)">Detailed Export</a></li>
<li><a href="#" class="block" ui-sref="modal.import">Import</a></li>
<li><a href="#" class="block" ui-sref="modal.delete">Delete All</a></li>
</ul>

View File

@@ -1,4 +1,5 @@
<h2 ng-bind="title"></h2>
<div ng-if="description" ng-bind="description"></div>
<div>
<textarea class="cb json" ng-click="onTextClick($event)" ng-bind="export"></textarea>
</div>

View File

@@ -1,24 +1,38 @@
<h2>Import</h2>
<div ng-show="!processed">
<textarea class="cb json" ng-model="importData" ng-change="validateJson()" placeholder="Paste JSON Here"></textarea>
<textarea class="cb json" ng-model="importJSON" ng-change="validateJson()" placeholder="Paste JSON Here"></textarea>
<button class="l" ng-click="process()" ng-disabled="!jsonValid">Proceed</button>
<div class="l warning" style="margin-left:3em;">{{errorMsg}}</div>
</div>
<div ng-show="processed">
<table class="l" style="overflow:hidden;margin: 1em 0; width: 100%;">
<thead><tr><th>Ship</th><th>Build Name</th><th>Action</th></tr></thead>
<thead><tr><th style="text-align:left">Ship</th><th style="text-align:left">Build Name</th><th>Action</th></tr></thead>
<tbody ng-repeat="(shipId,shipBuilds) in builds">
<tr class="cb" ng-repeat="(buildName, b) in shipBuilds">
<td>{{ships[shipId].properties.name}}</td>
<td><input type="text" ng-model="b.useName"/></td>
<td ng-class="{warning: hasBuild(shipId, b.useName) == true, disabled: b.useName == ''}">
<td style="text-align:center" ng-class="{warning: hasBuild(shipId, b.useName) == true, disabled: b.useName == ''}">
<span ng-show="b.useName">{{ hasBuild(shipId, b.useName)? 'Overwrite' : 'Create' }}</span>
<span ng-show="b.useName == ''">Skip</span>
</td>
</tr>
</tbody>
</table>
<table class="l" style="overflow:hidden;margin: 1em 0; width: 100%;" ng-if="comparisons">
<thead><tr><th style="text-align:left">Comparison</th><th>Action</th></tr></thead>
<tbody>
<tr class="cb" ng-repeat="(name, comparison) in comparisons">
<td><input type="text" ng-model="comparison.useName"/></td>
<td style="text-align:center" ng-class="{warning: hasComparison(comparison.useName) == true, disabled: comparison.useName == ''}">
<span ng-show="comparison.useName">{{ hasComparison(comparison.useName)? 'Overwrite' : 'Create' }}</span>
<span ng-show="comparison.useName == ''">Skip</span>
</td>
</tr>
</tbody>
</table>
<button class="cl l" ng-click="import()"><svg class="icon"><use xlink:href="#download"></use></svg> Import</button>
<button class="l" style="margin-left: 2em;" ng-click="processed = false" ng-show="canEdit">Edit JSON</button>
</div>

View File

@@ -19,9 +19,9 @@
<button ng-click="stripBuild()">
<svg class="icon lg"><use xlink:href="#feather"></use></svg><span class="button-lbl">Low-Weight</span>
</button>
<!-- <button ng-click="exportBuild($event)" ng-disabled="!buildName">
<button ng-click="exportBuild($event)" ng-disabled="!buildName">
<svg class="icon lg"><use xlink:href="#download"></use></svg><span class="button-lbl">Export</span>
</button> -->
</button>
</div>
</div>
@@ -32,7 +32,7 @@
<th rowspan="2">Size</th>
<th rowspan="2">Agility</th>
<th rowspan="2">Speed</th>
<th rowspan="2">Boost</th>
<th rowspan="2" ng-class="{'bg-warning-disabled': pd.c.enginecapacity < ship.boostEnergy}">Boost</th>
<th rowspan="2">DPS</th>
<th rowspan="2">Armour</th>
<th rowspan="2">Shields</th>
@@ -60,9 +60,16 @@
<td ng-bind="SZ[ship.class]"></td>
<td>{{ship.agility}}/10</td>
<td>{{fRound(ship.speed)}} <u>m/s</u></td>
<td>{{fRound(ship.boost)}} <u>m/s</u></td>
<td>
<span ng-if="pd.c.enginecapacity >= ship.boostEnergy">{{fRound(ship.boost)}} <u>m/s</u></span>
<span class="warning" ng-if="pd.c.enginecapacity < ship.boostEnergy">0 <svg class="icon"><use xlink:href="#warning"></use></svg></span>
</td>
<td>{{fRound(ship.totalDps)}}</td>
<td>{{ship.armour}} <span ng-if="ship.armourAdded">({{ship.baseArmour}} + {{ship.armourAdded}})</span></td>
<td>
{{ship.armour}}
<span ng-if="ship.armourAdded || ship.armourMultiplier > 1">(<span ng-if="ship.armourMultiplier > 1">{{fRPct(ship.armourMultiplier)}}</span>
<span ng-if="ship.armourAdded">+ {{ship.armourAdded}}</span>)</span>
</td>
<td>{{fRound(ship.shieldStrength)}} <u>MJ</u> <span ng-if="ship.shieldMultiplier > 1 && ship.shieldStrength > 0">({{fRPct(ship.shieldMultiplier)}})</span></td>
<td>{{ship.hullMass}} <u>T</u></td>
<td>{{fRound(ship.unladenMass)}} <u>T</u></td>
@@ -144,7 +151,7 @@
<div component-select class="select" s="ls" opts="availCS.common[3]" ng-if="selectedSlot==ls" ng-click="select('c',ls,$event)"></div>
</div>
<div class="slot" ng-click="selectSlot($event, pd)" ng-class="{selected: selectedSlot==pd}">
<div class="details">
<div class="details" ng-class="{warning: pd.c.enginecapacity < ship.boostEnergy}">
<div class="sz">{{::pd.maxClass}}</div>
<div class="l">{{pd.id}} Power Distributor</div>
<div class="r">{{pd.c.mass}} <u>T</u></div>
@@ -153,7 +160,7 @@
<div class="l">SYS: {{pd.c.systemcapacity}} <u>MJ</u> / {{pd.c.systemrecharge}} <u>MW</u></div>
<div class="l">ENG: {{pd.c.enginecapacity}} <u>MJ</u> / {{pd.c.enginerecharge}} <u>MW</u></div>
</div>
<div component-select class="select" s="pd" opts="availCS.common[4]" ng-if="selectedSlot==pd" ng-click="select('c',pd,$event)"></div>
<div component-select class="select" s="pd" warning="pdWarning" opts="availCS.common[4]" ng-if="selectedSlot==pd" ng-click="select('c',pd,$event)"></div>
</div>
<div class="slot" ng-click="selectSlot($event, ss)" ng-class="{selected: selectedSlot==ss}">
<div class="details">

View File

@@ -1,5 +1,5 @@
{
"Beam Lasers" : [
"Beam Laser": [
{
"id": "0u",
"grp": "bl",

View File

@@ -1,5 +1,5 @@
{
"Burst Lasers": [
"Burst Laser": [
{
"id": "14",
"grp": "ul",

View File

@@ -1,5 +1,5 @@
{
"Cannons": [
"Cannon": [
{
"id": "1q",
"grp": "c",

View File

@@ -1,5 +1,5 @@
{
"Cargo Scanners": [
"Cargo Scanner": [
{
"id": "0d",
"grp": "cs",

View File

@@ -1,5 +1,5 @@
{
"Countermeasures": [
"Countermeasure": [
{
"id": "00",
"grp": "cm",

View File

@@ -1,5 +1,5 @@
{
"Fragment Cannons": [
"Fragment Cannon": [
{
"id": "1t",
"grp": "fc",

View File

@@ -1,5 +1,5 @@
{
"Frame Shift Wake Scanners": [
"Frame Shift Wake Scanner": [
{
"id": "0i",
"grp": "ws",

View File

@@ -1,5 +1,5 @@
{
"Kill Warrant Scanners": [
"Kill Warrant Scanner": [
{
"id": "0n",
"grp": "kw",

View File

@@ -1,5 +1,5 @@
{
"Mine Launchers": [
"Mine Launcher": [
{
"id": "2j",
"grp": "nl",

View File

@@ -1,5 +1,5 @@
{
"Mining Lasers": [
"Mining Laser": [
{
"id": "2l",
"grp": "ml",

View File

@@ -1,5 +1,5 @@
{
"Missile Racks": [
"Missile Rack": [
{
"id": "2f",
"grp": "mr",

View File

@@ -1,5 +1,5 @@
{
"Multi-cannons": [
"Multi-cannon": [
{
"id": "26",
"grp": "mc",

View File

@@ -1,5 +1,5 @@
{
"Plasma Accelerators": [
"Plasma Accelerator": [
{
"id": "1g",
"grp": "pa",

View File

@@ -1,5 +1,5 @@
{
"Pulse Lasers": [
"Pulse Laser": [
{
"id": "1d",
"grp": "pl",

View File

@@ -1,5 +1,5 @@
{
"Rail Guns": [
"Rail Gun": [
{
"id": "29",
"grp": "rg",

View File

@@ -1,5 +1,5 @@
{
"Shield Boosters": [
"Shield Booster": [
{
"id": "08",
"grp": "sb",

View File

@@ -1,5 +1,5 @@
{
"Torpedo Pylons": [
"Torpedo Pylon": [
{
"id": "2h",
"grp": "tp",

View File

@@ -1,5 +1,5 @@
{
"Auto Field-Maintenance Units": [
"Auto Field-Maintenance Unit": [
{
"id": "1f",
"grp": "am",

View File

@@ -1,5 +1,5 @@
{
"Cargo Racks": [
"Cargo Rack": [
{ "id": "00", "grp": "cr", "class": 1, "rating": "E", "cost": 1000, "capacity": 2 },
{ "id": "01", "grp": "cr", "class": 2, "rating": "E", "cost": 3250, "capacity": 4 },
{ "id": "02", "grp": "cr", "class": 3, "rating": "E", "cost": 10563, "capacity": 8 },

View File

@@ -1,5 +1,5 @@
{
"Collector Limpet Controllers": [
"Collector Limpet Controller": [
{ "id": "Cf", "grp":"cc", "class":7, "rating":"E", "cost": 437400, "mass": 32.0, "power":0.41, "range":1.36, "maximum": 4, "time":300 },
{ "id": "Cg", "grp":"cc", "class":7, "rating":"D", "cost": 874800, "mass": 32.0, "power":0.55, "range":1.02, "maximum": 4, "time":600 },
{ "id": "Ch", "grp":"cc", "class":7, "rating":"C", "cost":1749600, "mass": 80.0, "power":0.69, "range":1.70, "maximum": 4, "time":510 },

View File

@@ -1,5 +1,5 @@
{
"Docking Computers": [
"Docking Computer": [
{
"id": "24",
"grp": "dc",

View File

@@ -1,5 +1,5 @@
{
"FSD Interdictors": [
"FSD Interdictor": [
{
"id": "6p",
"grp": "fi",

View File

@@ -1,5 +1,5 @@
{
"Fuel Scoops": [
"Fuel Scoop": [
{
"id": "3q",
"grp": "fs",

View File

@@ -1,5 +1,5 @@
{
"Fuel Transfer Limpet Controllers": [
"Fuel Transfer Limpet Controller": [
{ "id": "Ff", "grp":"fx", "class":7, "rating":"E", "cost": 437400, "mass": 80.0, "power":0.55, "range":1.02, "maximum": 8 },
{ "id": "Fg", "grp":"fx", "class":7, "rating":"D", "cost": 874800, "mass": 32.0, "power":0.41, "range":1.36, "maximum": 8 },
{ "id": "Fh", "grp":"fx", "class":7, "rating":"C", "cost":1749600, "mass": 80.0, "power":0.69, "range":1.70, "maximum": 8 },

View File

@@ -1,5 +1,5 @@
{
"Hatch Breaker Limpet Controllers": [
"Hatch Breaker Limpet Controller": [
{
"id": "7d",
"grp": "hb",

View File

@@ -1,5 +1,5 @@
{
"Hull Reinforcement Packages": [
"Hull Reinforcement Package": [
{
"id": "2e",
"grp": "hr",

View File

@@ -1,5 +1,5 @@
{
"Prismatic Shield Generators": [
"Prismatic Shield Generator": [
{ "id": "p6", "grp": "psg", "class": 1, "rating": "A", "cost": 132195, "mass": 2.5, "power": 2.52, "minmass": 13, "optmass": 25, "maxmass": 63, "minmul": 2.04, "optmul": 1.44, "maxmul": 0.84 },
{ "id": "p5", "grp": "psg", "class": 2, "rating": "A", "cost": 240336, "mass": 5, "power": 3.15, "minmass": 23, "optmass": 55, "maxmass": 138, "minmul": 2.04, "optmul": 1.44, "maxmul": 0.84 },
{ "id": "p4", "grp": "psg", "class": 3, "rating": "A", "cost": 761868, "mass": 10, "power": 3.78, "minmass": 83, "optmass": 165, "maxmass": 413, "minmul": 2.04, "optmul": 1.44, "maxmul": 0.84 },

View File

@@ -1,5 +1,5 @@
{
"Prospector Limpet Controllers": [
"Prospector Limpet Controller": [
{ "id": "Pf", "grp":"pc", "class":7, "rating":"E", "cost": 437400, "mass": 80.0, "power":0.55, "range": 5.10, "maximum": 8 },
{ "id": "Pg", "grp":"pc", "class":7, "rating":"D", "cost": 874800, "mass": 32.0, "power":0.41, "range": 6.80, "maximum": 8 },
{ "id": "Ph", "grp":"pc", "class":7, "rating":"C", "cost":1749600, "mass": 80.0, "power":0.69, "range": 8.50, "maximum": 8 },

View File

@@ -1,5 +1,5 @@
{
"Refineries": [
"Refinery": [
{
"id": "23",
"grp": "rf",

View File

@@ -1,9 +1,9 @@
{
"Scanners": [
"Scanner": [
{
"id": "2f",
"grp": "sc",
"name": "Adv. Discovery Scanner",
"name": "Advanced Discovery Scanner",
"class": 1,
"rating": "C",
"cost": 1545000,
@@ -14,7 +14,7 @@
{
"id": "2g",
"grp": "sc",
"name": "Inter. Discovery Scanner",
"name": "Intermediate Discovery Scanner",
"class": 1,
"rating": "D",
"cost": 505000,

View File

@@ -1,5 +1,5 @@
{
"Shield Cell Banks": [
"Shield Cell Bank": [
{ "id": "65", "grp": "scb", "class": 8, "rating": "E", "cost": 697584, "mass": 160, "power": 1.44, "cells": 5, "rechargeRating": "C", "recharge": 0 },
{ "id": "64", "grp": "scb", "class": 8, "rating": "D", "cost": 1743961, "mass": 64, "power": 1.92, "cells": 3, "rechargeRating": "C", "recharge": 0 },
{ "id": "63", "grp": "scb", "class": 8, "rating": "C", "cost": 4359903, "mass": 160, "power": 2.4, "cells": 4, "rechargeRating": "B", "recharge": 0 },

View File

@@ -1,5 +1,5 @@
{
"Shield Generators": [
"Shield Generator": [
{ "id": "4t", "grp": "sg", "class": 8, "rating": "E", "cost": 2007241, "mass": 160, "power": 2.4, "minmass": 900, "optmass": 1800, "maxmass": 4500, "minmul": 1.3, "optmul": 0.8, "maxmul": 0.3 },
{ "id": "4s", "grp": "sg", "class": 8, "rating": "D", "cost": 6021722, "mass": 64, "power": 3.2, "minmass": 900, "optmass": 1800, "maxmass": 4500, "minmul": 1.4, "optmul": 0.9, "maxmul": 0.4 },
{ "id": "4r", "grp": "sg", "class": 8, "rating": "C", "cost": 18065165, "mass": 160, "power": 4, "minmass": 900, "optmass": 1800, "maxmass": 4500, "minmul": 1.5, "optmul": 1, "maxmul": 0.5 },

View File

@@ -7,6 +7,7 @@
"hullCost": 39993,
"speed": 220,
"boost": 320,
"boostEnergy": 9,
"agility": 8,
"baseShieldStrength": 60,
"baseArmour": 162,

View File

@@ -7,6 +7,7 @@
"hullCost": 141889932,
"speed": 180,
"boost": 240,
"boostEnergy": 29,
"agility": 2,
"baseShieldStrength": 350,
"baseArmour": 945,

View File

@@ -7,6 +7,7 @@
"hullCost": 6135658,
"speed": 250,
"boost": 340,
"boostEnergy": 14,
"agility": 6,
"baseShieldStrength": 140,
"baseArmour": 378,

View File

@@ -7,6 +7,7 @@
"hullCost": 235787,
"speed": 280,
"boost": 400,
"boostEnergy": 11,
"agility": 6,
"baseShieldStrength": 80,
"baseArmour": 216,

View File

@@ -7,6 +7,7 @@
"hullCost": 461341,
"speed": 283,
"boost": 384,
"boostEnergy": 11,
"agility": 8,
"baseShieldStrength": 118,
"baseArmour": 216,

View File

@@ -7,6 +7,7 @@
"hullCost": 1635691,
"speed": 242,
"boost": 316,
"boostEnergy": 14,
"agility": 5,
"baseShieldStrength": 146,
"baseArmour": 270,

View File

@@ -7,6 +7,7 @@
"hullCost": 10446,
"speed": 240,
"boost": 350,
"boostEnergy": 9,
"agility": 10,
"baseShieldStrength": 60,
"baseArmour": 72,

View File

@@ -7,6 +7,7 @@
"hullCost": 18969990,
"speed": 180,
"boost": 300,
"boostEnergy": 21,
"agility": 2,
"baseShieldStrength": 200,
"baseArmour": 540,

View File

@@ -7,6 +7,7 @@
"hullCost": 51232230,
"speed": 260,
"boost": 350,
"boostEnergy": 21,
"agility": 6,
"baseShieldStrength": 300,
"baseArmour": 405,

View File

@@ -8,6 +8,7 @@
"speed": 200,
"boost": 300,
"agility": 6,
"boostEnergy": 7,
"baseShieldStrength": 50,
"baseArmour": 90,
"hullMass": 14,

View File

@@ -7,6 +7,7 @@
"hullCost": 21077784,
"speed": 300,
"boost": 380,
"boostEnergy": 21,
"agility": 2,
"baseShieldStrength": 180,
"baseArmour": 486,

View File

@@ -7,6 +7,7 @@
"hullCost": 2481552,
"speed": 277,
"boost": 380,
"boostEnergy": 11,
"agility": 6,
"baseShieldStrength": 197,
"baseArmour": 144,

View File

@@ -7,6 +7,7 @@
"hullCost": 47798079,
"speed": 300,
"boost": 380,
"boostEnergy": 17,
"agility": 2,
"baseShieldStrength": 220,
"baseArmour": 396,

View File

@@ -7,6 +7,7 @@
"hullCost": 55171395,
"speed": 230,
"boost": 280,
"boostEnergy": 24,
"agility": 6,
"baseShieldStrength": 260,
"baseArmour": 468,

View File

@@ -7,6 +7,7 @@
"hullCost": 12887,
"speed": 220,
"boost": 320,
"boostEnergy": 7,
"agility": 8,
"baseShieldStrength": 40,
"baseArmour": 108,

View File

@@ -7,6 +7,7 @@
"hullCost": 865782,
"speed": 220,
"boost": 350,
"boostEnergy": 11,
"agility": 3,
"baseShieldStrength": 90,
"baseArmour": 162,

View File

@@ -7,6 +7,7 @@
"hullCost": 16881511,
"speed": 180,
"boost": 300,
"boostEnergy": 11,
"agility": 2,
"baseShieldStrength": 120,
"baseArmour": 216,

View File

@@ -7,6 +7,7 @@
"hullCost": 73255168,
"speed": 130,
"boost": 200,
"boostEnergy": 21,
"agility": 0,
"baseShieldStrength": 240,
"baseArmour": 432,

View File

@@ -7,6 +7,7 @@
"hullCost": 95893,
"speed": 320,
"boost": 400,
"boostEnergy": 11,
"agility": 6,
"baseShieldStrength": 105,
"baseArmour": 126,

View File

@@ -7,6 +7,7 @@
"hullCost": 4689629,
"speed": 210,
"boost": 340,
"boostEnergy": 17,
"agility": 9,
"baseShieldStrength": 240,
"baseArmour": 288,

View File

@@ -1,6 +1,6 @@
{
"name": "coriolis_shipyard",
"version": "1.1.0",
"version": "1.3.0",
"repository": {
"type": "git",
"url": "https://github.com/cmmcleod/coriolis"

View File

@@ -30,23 +30,23 @@ function writeDB(err, arr) {
var shipOrder = Object.keys(arr[0]).sort();
var internalOrder = Object.keys(arr[3]).sort();
var hpOrder = [
"Pulse Lasers",
"Burst Lasers",
"Beam Lasers",
"Multi-cannons",
"Cannons",
"Fragment Cannons",
"Rail Guns",
"Plasma Accelerators",
"Missile Racks",
"Torpedo Pylons",
"Mine Launchers",
"Mining Lasers",
"Cargo Scanners",
"Countermeasures",
"Frame Shift Wake Scanners",
"Kill Warrant Scanners",
"Shield Boosters"
"Pulse Laser",
"Burst Laser",
"Beam Laser",
"Multi-cannon",
"Cannon",
"Fragment Cannon",
"Rail Gun",
"Plasma Accelerator",
"Missile Rack",
"Torpedo Pylon",
"Mine Launcher",
"Mining Laser",
"Cargo Scanner",
"Countermeasure",
"Frame Shift Wake Scanner",
"Kill Warrant Scanner",
"Shield Booster"
];
for (var i = 0; i < internalOrder.length; i++) {

View File

@@ -0,0 +1,220 @@
{
"$schema": "http://cdn.coriolis.io/schemas/ship-loadout/1.json#",
"name": "Test",
"ship": "Anaconda",
"references": [
{
"name": "Coriolis.io",
"url": "http://localhost:3300/outfit/anaconda/48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b?bn=Test",
"code": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b",
"shipId": "anaconda"
}
],
"components": {
"standard": {
"bulkheads": "Reactive Surface Composite",
"powerPlant": {
"class": 8,
"rating": "A"
},
"thrusters": {
"class": 6,
"rating": "A"
},
"frameShiftDrive": {
"class": 6,
"rating": "A"
},
"lifeSupport": {
"class": 5,
"rating": "A"
},
"powerDistributor": {
"class": 8,
"rating": "A"
},
"sensors": {
"class": 8,
"rating": "A"
},
"fuelTank": {
"class": 5,
"rating": "C"
}
},
"hardpoints": [
{
"class": 4,
"rating": "A",
"group": "Plasma Accelerator",
"mount": "Fixed"
},
{
"class": 3,
"rating": "D",
"group": "Beam Laser",
"mount": "Turret"
},
{
"class": 3,
"rating": "D",
"group": "Beam Laser",
"mount": "Turret"
},
{
"class": 3,
"rating": "D",
"group": "Beam Laser",
"mount": "Turret"
},
{
"class": 2,
"rating": "E",
"group": "Cannon",
"mount": "Turret"
},
{
"class": 2,
"rating": "E",
"group": "Cannon",
"mount": "Turret"
},
{
"class": 1,
"rating": "F",
"group": "Beam Laser",
"mount": "Turret"
},
{
"class": 1,
"rating": "F",
"group": "Beam Laser",
"mount": "Turret"
}
],
"utility": [
{
"class": 0,
"rating": "A",
"group": "Shield Booster"
},
{
"class": 0,
"rating": "A",
"group": "Shield Booster"
},
null,
{
"class": 0,
"rating": "C",
"group": "Kill Warrant Scanner"
},
{
"class": 0,
"rating": "C",
"group": "Cargo Scanner"
},
{
"class": 0,
"rating": "F",
"group": "Countermeasure",
"name": "Electronic Countermeasure"
},
{
"class": 0,
"rating": "I",
"group": "Countermeasure",
"name": "Chaff Launcher"
},
{
"class": 0,
"rating": "I",
"group": "Countermeasure",
"name": "Point Defence"
}
],
"internal": [
{
"class": 7,
"rating": "A",
"group": "Shield Generator"
},
{
"class": 6,
"rating": "A",
"group": "Shield Cell Bank"
},
{
"class": 6,
"rating": "E",
"group": "Cargo Rack"
},
{
"class": 5,
"rating": "D",
"group": "Hull Reinforcement Package"
},
{
"class": 5,
"rating": "E",
"group": "Cargo Rack"
},
null,
null,
{
"class": 4,
"rating": "E",
"group": "Cargo Rack"
},
{
"class": 4,
"rating": "E",
"group": "Cargo Rack"
},
{
"class": 4,
"rating": "A",
"group": "Fuel Scoop"
},
{
"class": 2,
"rating": "A",
"group": "FSD Interdictor"
}
]
},
"stats": {
"class": 3,
"hullCost": 141889932,
"speed": 180,
"boost": 240,
"boostEnergy": 29,
"agility": 2,
"baseShieldStrength": 350,
"baseArmour": 945,
"hullMass": 400,
"masslock": 23,
"shipCostMultiplier": 1,
"componentCostMultiplier": 1,
"fuelCapacity": 32,
"cargoCapacity": 128,
"ladenMass": 1339.2,
"armour": 2078,
"armourAdded": 240,
"armourMultiplier": 1.95,
"shieldMultiplier": 1.4,
"totalCost": 882362049,
"unladenMass": 1179.2,
"totalDps": 29,
"powerAvailable": 36,
"powerRetracted": 23.93,
"powerDeployed": 35.56,
"unladenRange": 18.49,
"fullTankRange": 18.12,
"ladenRange": 16.39,
"unladenTotalRange": 73.21,
"ladenTotalRange": 66.15,
"maxJumpCount": 4,
"shieldStrength": 833
}
}

50
test/fixtures/expected-builds.json vendored Normal file
View File

@@ -0,0 +1,50 @@
{
"type_6_transporter": {
"Cargo": "02A4D4A2D2D2D4C-----04040303430101.Iw1-kA==.Aw1-kA==",
"Miner": "03A4D4A2D2D2D4C2l2l---040403451q0101.Iw1-kA==.Aw1-kA==",
"Hopper": "02A4D4A2D1A2D4C1717---030302024300-.Iw1-kA==.Aw1-kA=="
},
"type_7_transport": {
"Cargo": "02A5D5A4D3D3D5C--------0505040403480101.Iw18aQ==.Aw18aQ==",
"Miner": "04D5D5A4D2D3D5C--2l2l----0505041v03450000.Iw18aQ==.Aw18aQ=="
},
"federal_dropship": {
"Cargo": "04D5D5A5D3D4D4C-1717------05040448020201.Iw18aQ==.Aw18aQ=="
},
"asp": {
"Miner": "25A5A5A4D4A5A5C0s0s24242l2l---04054a1q02022o27.Iw18WQ==.Aw18WQ=="
},
"imperial_clipper": {
"Cargo": "03A5D5A5D4D5D4C--0s0s----0605450302020101.Iw18aQ==.Aw18aQ==",
"Dream": "26A6A5A5D6A5A4C0v0v0s0s0404040n4k5n5d2b29292o-.Iw18aQ==.Aw18aQ==",
"Current": "04A6A5A5D4A5A4C----------------.Iw18aQ==.Aw18aQ=="
},
"type_9_heavy": {
"Current": "04A7D6A5D5D4D6C---------0706054a0303020224.Iw18eQ==.Aw18eQ=="
},
"python": {
"Cargo": "04A6D5A4D6D6D5C---------050505040448020201.Iw18eQ==.Aw18eQ==",
"Miner": "06A6A5A4D6A6A5C0v0v0v2m2m0404--050505Ce4a1v02022o.Iw18eQ==.Aw18eQ==",
"Dream": "27A6A5A4D7A6A5C0v0v0v27270404040m5n5n4f2d2d032t0201.Iw18eQ==.Aw18eQ==",
"Missile": "07E6E5E4E7E6E5C2f2g2d2ePh----04044j03---002h.Iw18eQ==.Aw18eQ=="
},
"anaconda": {
"Dream": "48A7A6A5D8A8A5C2c0o0o0o1m1m0q0q0404040l0b0100004k5n5n112d2d040303326b.Iw18ZlA=.Aw18ZlA=",
"Cargo": "04A6D6A5D5D8D5C----------------0605050504040445030301.Iw18ZlA=.Aw18ZlA=",
"Current": "04A6D6A5D5A8D5C----------------0605050504040403034524.Iw18ZlA=.Aw18ZlA=",
"Explorer": "04A6D6A5D5A8D5C--------0202------f7050505040s372f2i4524.Iw18ZlA=.Aw18ZlA=",
"Test": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA="
},
"diamondback_explorer": {
"Explorer": "02A4D5A3D3D3D5C---0202--320p432i2f.Iw1-kA==.Aw1-kA=="
},
"vulture": {
"Bounty Hunter": "34A4C4A3D5A4A3C1e1e0404-0l4a5d27662j.Iw19kA==.Aw19kA=="
},
"fer_de_lance": {
"Attack": "25A5C4A4D6A4A3C1r0s0s0s0s000404-04-4a-5d27-.Iw18aQ==.Aw18aQ=="
},
"eagle": {
"Figther": "42A3A3A1D2A2A2C0p0p24-40532j.Iw19A===.Aw19A==="
}
}

50
test/fixtures/old-valid-export.json vendored Normal file
View File

@@ -0,0 +1,50 @@
{
"builds": {
"type_6_transporter": {
"Cargo": "02A4D4A2D2D2D4C-----04040303430101",
"Miner": "03A4D4A2D2D2D4C2l2l---040403451q0101",
"Hopper": "02A4D4A2D1A2D4C1717---030302024300-"
},
"type_7_transport": {
"Cargo": "02A5D5A4D3D3D5C--------0505040403480101",
"Miner": "04D5D5A4D2D3D5C--2l2l----0505041v03450000"
},
"federal_dropship": {
"Cargo": "04D5D5A5D3D4D4C-1717------05040448020201"
},
"asp": {
"Miner": "25A5A5A4D4A5A5C0s0s24242l2l---04054a1q02022o27"
},
"imperial_clipper": {
"Cargo": "03A5D5A5D4D5D4C--0s0s----0605450302020101",
"Dream": "26A6A5A5D6A5A4C0v0v0s0s0404040n4k5n5d2b29292o-.AwRj4yWU1I==.CwBhCYy6YRigzLIA",
"Current": "04A6A5A5D4A5A4C----------------.AwRj4yWU1I==.CwBhCYy6YRigzLIA"
},
"type_9_heavy": {
"Current": "04A7D6A5D5D4D6C---------0706054a0303020224.AwRj4yoo.EwBhEYy6dsg="
},
"python": {
"Cargo": "04A6D5A4D6D6D5C---------050505040448020201.Iw18eQ==.Aw18eQ==",
"Miner": "06A6A5A4D6A6A5C0v0v0v2m2m0404--050505Ce4a1v02022o.Iw18eQ==.IwBhBYy6dkCYg===",
"Dream": "27A6A5A4D7A6A5C0v0v0v27270404040m5n5n4f2d2d032t0201.Iw1+gDBxA===.EwBhEYy6e0WEA==="
},
"anaconda": {
"Dream": "48A7A6A5D8A8A5C2c0o0o0o1m1m0q0q0404040l0b0100004k5n5n112d2d040303326b.AwRj4yo5dig=.MwBhCYy6du3ARiA=",
"Cargo": "04A6D6A5D5D8D5C----------------0605050504040445030301.Iw18ZlA=.Aw18ZlA=",
"Current": "04A6D6A5D5A8D5C----------------0605050504040403034524.Iw18ZlA=.Aw18ZlA=",
"Explorer": "04A6D6A5D5A8D5C--------0202------f7050505040s372f2i4524.AwRj4yVKJthA.AwhMIyungRhEA==="
},
"diamondback_explorer": {
"Explorer": "02A4D5A3D3D3D5C---0202--320p432i2f.AwRj4zTI.AwiMIypI"
},
"vulture": {
"Bounty Hunter": "34A4C4A3D5A4A3C1e1e0404-0l4a5d27662j.AwRj4y2I.MwBhBYy6wJmAjLIA"
},
"fer_de_lance": {
"Attack": "25A5C4A4D6A4A3C1r0s0s0s0s000404-04-4a-5d27-.Iw18aQ==.CwBhrSu8EZyA"
},
"eagle": {
"Figther": "42A3A3A1D2A2A2C0p0p24-40532j.AwRj49iA.AwgsIkEZigmIA==="
}
}
}

66
test/fixtures/valid-backup.json vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"builds": {
"type_6_transporter": {
"Cargo": "02A4D4A2D2D2D4C-----04040303430101",
"Miner": "03A4D4A2D2D2D4C2l2l---040403451q0101",
"Hopper": "02A4D4A2D1A2D4C1717---030302024300-"
},
"type_7_transport": {
"Cargo": "02A5D5A4D3D3D5C--------0505040403480101",
"Miner": "04D5D5A4D2D3D5C--2l2l----0505041v03450000"
},
"federal_dropship": {
"Cargo": "04D5D5A5D3D4D4C-1717------05040448020201"
},
"asp": {
"Miner": "25A5A5A4D4A5A5C0s0s24242l2l---04054a1q02022o27"
},
"cobra_mk_iii": {
"Example": "24A4A4A3D3A3A4C0s0s2d2d0m0445032b2o2753.AwRj4yKA.CwBhEYyrKhmMQ===",
},
"imperial_clipper": {
"Cargo": "03A5D5A5D4D5D4C--0s0s----0605450302020101",
"Multi-purpose": "26A4A5A5D6A5A4C0v0v272704090j0h064f2c0302020101",
"Current": "05A6D5A5D6A5A4C0v0v27270404050n4m05035d29292o01.AwRj4yrI.AwhMIyuBGNiA",
"Dream": "26A6A5A5D6A5A4C0v0v0s0s04040c0n064f5d2b02022o0d.AwRj49UlmI==.AwiMIyuo"
},
"type_9_heavy": {
"Cargo": "04A6D6A5D4D4D5C---------07064f040303010201.AwRj4yoo.EwBhEYy6dsg="
},
"python": {
"Cargo": "04A6D5A4D6D6D5C---------050505044a03020201",
"Miner": "04A6D5A4D6D6D5C---2m2m----050505044d1v02022o"
},
"anaconda": {
"Dream": "48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404040l0b0100034k5n05050404040303326b.AwRj4yo5dig=.MwBhEYy6duwEziA=",
"Cargo": "03A7D6A5D4D8D5C----------------060505054d040403030301.AwRj4yuqg===.Aw18ZlA="
},
"diamondback_explorer": {
"Explorer": "02A4D5A3D3D3D5C-------320p432i2f.AwRj4zTI.AwiMIypI"
}
},
"comparisons": {
"Test": {
"facets": [ 9, 6, 4, 1, 3, 2 ],
"builds": [
{
"shipId": "anaconda",
"buildName": "Dream"
},
{
"shipId": "asp",
"buildName": "Miner"
},
{
"shipId": "diamondback_explorer",
"buildName": "Explorer"
}
]
}
},
"insurance": "Beta",
"discounts": [
1,
1
]
}

3620
test/fixtures/valid-detailed-export.json vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,8 @@ module.exports = function(config) {
basePath: '',
frameworks: ['jasmine', 'fixture'],
preprocessors: {
'../build/schemas/**/*.json': ['json_fixtures']
'../build/schemas/**/*.json': ['json_fixtures'],
'fixtures/**/*.json': ['json_fixtures']
},
files: [
'../build/lib*.js',
@@ -11,10 +12,11 @@ module.exports = function(config) {
'../node_modules/jsen/dist/jsen.js',
'../build/app*.js',
'../build/schemas/**/*.json',
'fixtures/**/*.json',
'tests/**/*.js',
],
jsonFixturesPreprocessor: {
stripPrefix: '.*build',
jsonFixturesPreprocessor: {
stripPrefix: '.*(/build/)',
variableName: '__json__'
},
reporters: ['mocha'],

View File

@@ -0,0 +1,140 @@
describe('Import Controller', function() {
beforeEach(module('app'));
var importController, $rootScope, $stateParams, scope;
var eventStub = {
preventDefault: function(){ },
stopPropagation: function(){ }
};
beforeEach(inject(function(_$rootScope_, $controller) {
$rootScope = _$rootScope_;
$rootScope.discounts = {
ship: 1,
components: 1
};
$stateParams = { };
scope = $rootScope.$new();
scope.$parent.dismiss = function() {};
var store = {};
spyOn(localStorage, 'getItem').and.callFake(function (key) {
return store[key];
});
spyOn(localStorage, 'setItem').and.callFake(function (key, value) {
return store[key] = value + '';
});
spyOn(localStorage, 'clear').and.callFake(function () {
store = {};
});
importController = $controller('ImportController', { $rootScope: $rootScope, $scope: scope, $stateParams: $stateParams });
}));
describe('Import Backup', function() {
it('imports a valid backup', function() {
var importData = __json__['fixtures/valid-backup'];
scope.importJSON = angular.toJson(importData);
scope.validateJson();
expect(scope.jsonValid).toBeTruthy();
expect(scope.errorMsg).toEqual(null);
scope.process();
expect(scope.processed).toBeTruthy();
scope.import();
expect(angular.fromJson(localStorage.getItem('builds'))).toEqual(importData.builds);
expect(angular.fromJson(localStorage.getItem('comparisons'))).toEqual(importData.comparisons);
expect(localStorage.getItem('insurance')).toEqual(importData.insurance);
expect(angular.fromJson(localStorage.getItem('discounts'))).toEqual(importData.discounts);
});
it('imports an old valid backup', function() {
var importData = __json__['fixtures/old-valid-export'];
scope.importJSON = angular.toJson(importData);
scope.validateJson();
expect(scope.jsonValid).toBeTruthy();
expect(scope.errorMsg).toEqual(null);
scope.process();
expect(scope.processed).toBeTruthy();
scope.import();
expect(angular.fromJson(localStorage.getItem('builds'))).toEqual(importData.builds);
});
it('catches an invalid backup', function() {
var importData = __json__['fixtures/valid-backup'];
scope.importJSON = 'null';
scope.validateJson();
expect(scope.jsonValid).toBeFalsy();
expect(scope.errorMsg).toEqual('Must be an object or array!');
scope.importJSON = '{ "builds": "Should not be a string" }';
scope.validateJson();
expect(scope.jsonValid).toBeFalsy();
expect(scope.errorMsg).toEqual('builds must be an object!');
scope.importJSON = angular.toJson(importData).replace('anaconda', 'invalid_ship');
scope.validateJson();
expect(scope.jsonValid).toBeFalsy();
expect(scope.errorMsg).toEqual('"invalid_ship" is not a valid Ship Id!');
scope.importJSON = angular.toJson(importData).replace('Dream', '');
scope.validateJson();
expect(scope.jsonValid).toBeFalsy();
expect(scope.errorMsg).toEqual('Imperial Clipper build "" must be a string at least 3 characters long!');
});
});
describe('Import Detailed Build', function() {
it('imports a valid build', function() {
var importData = __json__['fixtures/anaconda-test-detailed-export'];
scope.importJSON = angular.toJson(importData);
scope.validateJson();
expect(scope.jsonValid).toBeTruthy();
expect(scope.errorMsg).toEqual(null);
scope.process();
expect(scope.processed).toBeTruthy();
scope.import();
expect(angular.fromJson(localStorage.getItem('builds'))).toEqual({
anaconda: { 'Test': '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.Iw18ZlA=.Aw18ZlA=' }
});
});
it('catches an invalid build', function() {
var importData = __json__['fixtures/anaconda-test-detailed-export'];
scope.importJSON = angular.toJson(importData).replace('components', 'comps');
scope.validateJson();
expect(scope.jsonValid).toBeFalsy();
expect(scope.errorMsg).toEqual('Anaconda Build "Test": Invalid data');
});
});
describe('Import Detaild Builds Array', function() {
it('imports all builds', function() {
var importData = __json__['fixtures/valid-detailed-export'];
var expectedBuilds = __json__['fixtures/expected-builds'];
scope.importJSON = angular.toJson(importData);
scope.validateJson();
expect(scope.jsonValid).toBeTruthy();
expect(scope.errorMsg).toEqual(null);
scope.process();
expect(scope.processed).toBeTruthy();
scope.import();
var builds = angular.fromJson(localStorage.getItem('builds'));
for (var s in builds) {
for (var b in builds[s]) {
expect(builds[s][b]).toEqual(expectedBuilds[s][b]);
}
}
});
});
});

View File

@@ -1,7 +1,7 @@
describe("Outfit Controller", function() {
beforeEach(module('app'));
var outfitController, scope;
var outfitController, $rootScope, $stateParams, scope;
var eventStub = {
preventDefault: function(){ },

View File

@@ -25,7 +25,7 @@ describe('Database', function() {
}
});
it('has valid internal components', function() {
it('has unique IDs for every internal component', function() {
var ids = {};
var groups = DB.components.internal;

View File

@@ -1,39 +1,55 @@
describe("Serializer Service", function() {
beforeEach(module('app'));
var Ship, Serializer;
var Ship,
Serializer,
code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b',
anaconda = DB.ships['anaconda'],
testBuild,
exportData;
beforeEach(inject(function (_Ship_, _Serializer_) {
Ship = _Ship_;
Serializer = _Serializer_;
}));
describe("Detailed Export", function() {
var code = '48A6A6A5A8A8A5C2c0o0o0o1m1m0q0q0404-0l0b0100034k5n052d04--0303326b.AwRj4yo5dig=.MwBhEYy6duwEziA',
url = 'http://a.test.url.com',
anaconda = DB.ships['anaconda'],
testBuild,
exportData;
describe("To Detailed Build", function() {
beforeEach(function() {
testBuild = new Ship('anaconda', anaconda.properties, anaconda.slots);
Serializer.toShip(testBuild, code);
exportData = Serializer.toJsonBuild('Test Build', testBuild, url, code);
exportData = Serializer.toDetailedBuild('Test', testBuild, code);
});
it("conforms to the ship-loadout schema", function() {
var shipLoadoutSchema = __json__['/schemas/ship-loadout/1-draft'];
var shipLoadoutSchema = __json__['schemas/ship-loadout/1'];
var validate = jsen(shipLoadoutSchema);
var valid = validate(exportData);
expect(valid).toBeTruthy();
});
xit("contains the correct components", function() {
// TODO: implement
it("contains the correct components and stats", function() {
var anacondaTestExport = __json__['fixtures/anaconda-test-detailed-export'];
expect(exportData.components).toEqual(anacondaTestExport.components);
expect(exportData.stats).toEqual(anacondaTestExport.stats);
expect(exportData.ship).toEqual(anacondaTestExport.ship);
expect(exportData.name).toEqual(anacondaTestExport.name);
});
xit("contains the correct stats", function() {
// TODO: implement
});
describe("From Detailed Build", function() {
it("builds the ship correctly", function() {
var anacondaTestExport = __json__['fixtures/anaconda-test-detailed-export'];
testBuildA = new Ship('anaconda', anaconda.properties, anaconda.slots);
Serializer.toShip(testBuildA, code);
testBuildB = Serializer.fromDetailedBuild(anacondaTestExport);
for(var p in testBuildB) {
expect(testBuildB[p]).toEqual(testBuildA[p], p + ' does not match');
}
});
});