mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c23fb3884 | ||
|
|
b707015d9c | ||
|
|
10d5611dcd | ||
|
|
9009a2a434 | ||
|
|
8b98a98faf | ||
|
|
44de3e4bbc | ||
|
|
ba2e9a12b0 | ||
|
|
57304f55c1 | ||
|
|
1eea358c35 | ||
|
|
f671b7c34f | ||
|
|
211028d80d | ||
|
|
c79359ea2f | ||
|
|
93f92da1df | ||
|
|
25020293ec | ||
|
|
4e7f1d3e8b | ||
|
|
e6ba0a14e8 | ||
|
|
b285a433b2 | ||
|
|
f19c786f64 | ||
|
|
806e545361 | ||
|
|
ae62781d53 | ||
|
|
3abfcf7c95 | ||
|
|
dc8b829d8a | ||
|
|
353396398b | ||
|
|
bf99b34596 | ||
|
|
f3af0f3a99 | ||
|
|
0fd4a8395e | ||
|
|
cb664003a5 | ||
|
|
4686f17d18 | ||
|
|
45c96dc136 | ||
|
|
389fdc8dfa | ||
|
|
b94e6126cd | ||
|
|
bee4f7e6bc | ||
|
|
345b7f5ffe | ||
|
|
f1b40eb38c | ||
|
|
f459c26bd7 | ||
|
|
825b678fb0 | ||
|
|
ce3818f99a | ||
|
|
94e2b60cd1 | ||
|
|
3bbef71a5e | ||
|
|
ca280673d1 | ||
|
|
ff477c035a | ||
|
|
1c0b76a8c2 | ||
|
|
6fb2247dd7 |
19
.travis.yml
Normal file
19
.travis.yml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
language: node_js
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
sudo: false
|
||||||
|
node_js:
|
||||||
|
- "0.12"
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- node_modules
|
||||||
|
- bower_components
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g gulp
|
||||||
|
- npm install -g bower
|
||||||
|
- bower install
|
||||||
|
script:
|
||||||
|
- gulp lint
|
||||||
|
- gulp build-prod
|
||||||
|
- gulp test
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
[ ](https://codeship.com/projects/85232) [](https://waffle.io/cmmcleod/coriolis) [](http://waffle.io/cmmcleod/coriolis)
|
[](https://travis-ci.org/cmmcleod/coriolis) [](https://waffle.io/cmmcleod/coriolis) [](http://waffle.io/cmmcleod/coriolis)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
The Coriolis project was inspired by [E:D Shipyard](http://www.edshipyard.com/) and, of course, [Elite Dangerous](http://www.elitedangerous.com). The ultimate goal of Coriolis is to provide rich features to support in-game play and planning while engaging the E:D community to support its development.
|
The Coriolis project was inspired by [E:D Shipyard](http://www.edshipyard.com/) and, of course, [Elite Dangerous](http://www.elitedangerous.com). The ultimate goal of Coriolis is to provide rich features to support in-game play and planning while engaging the E:D community to support its development.
|
||||||
|
|
||||||
Coriolis was created for non-commercial purposes. It is not endorsed by nor reflects the views or opinions of Frontier Developments.
|
Coriolis was created for non-commercial purposes. Coriolis was created using assets and imagery from Elite: Dangerous, with the permission of Frontier Developments plc, for non-commercial purposes. It is not endorsed by nor reflects the views or opinions of Frontier Developments and no employee of Frontier Developments was involved in the making of it.
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Please [submit issues](https://github.com/cmmcleod/coriolis/issues), or better yet [pull requests](http://www.elitedangerous.com) for any corrections or additions to the database or the code.
|
Please [submit issues](https://github.com/cmmcleod/coriolis/issues), or better yet [pull requests](https://github.com/cmmcleod/coriolis/pulls) for any corrections or additions to the database or the code.
|
||||||
|
|
||||||
### Feature Requests, Suggestions & Bugs
|
### Feature Requests, Suggestions & Bugs
|
||||||
|
|
||||||
@@ -31,7 +31,8 @@ See [Data wiki](https://github.com/cmmcleod/coriolis/wiki/Database) for details
|
|||||||
All Data and [associated JSON](https://github.com/cmmcleod/coriolis/tree/master/data) files are intellectual property and copyright of Frontier Developments plc ('Frontier', 'Frontier Developments') and are subject to their
|
All Data and [associated JSON](https://github.com/cmmcleod/coriolis/tree/master/data) files are intellectual property and copyright of Frontier Developments plc ('Frontier', 'Frontier Developments') and are subject to their
|
||||||
[terms and conditions](https://www.frontierstore.net/terms-and-conditions/).
|
[terms and conditions](https://www.frontierstore.net/terms-and-conditions/).
|
||||||
|
|
||||||
The code specificially for Coriolis.io is released under the MIT License.
|
The code (Javascript, CSS, HTML, and SVG files only) specificially for Coriolis.io is released under the MIT License.
|
||||||
|
|
||||||
Copyright (c) 2015 Coriolis.io, Colin McLeod
|
Copyright (c) 2015 Coriolis.io, Colin McLeod
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Generated by IcoMoon.io -->
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
|
|
||||||
<path d="M16 0c-8.837 0-16 7.163-16 16s7.163 16 16 16 16-7.163 16-16-7.163-16-16-16zM16 29c-7.18 0-13-5.82-13-13s5.82-13 13-13 13 5.82 13 13-5.82 13-13 13z"></path>
|
|
||||||
<path d="M21 8l-5 5-5-5-3 3 5 5-5 5 3 3 5-5 5 5 3-3-5-5 5-5z"></path>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 554 B |
3
app/icons/feather.svg
Normal file
3
app/icons/feather.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="724" height="1024" viewBox="0 0 1024 1024">
|
||||||
|
<path d="M0 1024c128-384 463-1024 1024-1024-263 211-384 704-576 704s-192 0-192 0l-192 320h-64z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 218 B |
@@ -1,6 +1,3 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="33" height="33" viewBox="0 0 33 33">
|
||||||
<!-- Generated by IcoMoon.io -->
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
|
|
||||||
<path d="M32 12h-12l4.485-4.485c-2.267-2.266-5.28-3.515-8.485-3.515s-6.219 1.248-8.485 3.515c-2.266 2.267-3.515 5.28-3.515 8.485s1.248 6.219 3.515 8.485c2.267 2.266 5.28 3.515 8.485 3.515s6.219-1.248 8.485-3.515c0.189-0.189 0.371-0.384 0.546-0.583l3.010 2.634c-2.933 3.349-7.239 5.464-12.041 5.464-8.837 0-16-7.163-16-16s7.163-16 16-16c4.418 0 8.418 1.791 11.313 4.687l4.687-4.687v12z"></path>
|
<path d="M32 12h-12l4.485-4.485c-2.267-2.266-5.28-3.515-8.485-3.515s-6.219 1.248-8.485 3.515c-2.266 2.267-3.515 5.28-3.515 8.485s1.248 6.219 3.515 8.485c2.267 2.266 5.28 3.515 8.485 3.515s6.219-1.248 8.485-3.515c0.189-0.189 0.371-0.384 0.546-0.583l3.010 2.634c-2.933 3.349-7.239 5.464-12.041 5.464-8.837 0-16-7.163-16-16s7.163-16 16-16c4.418 0 8.418 1.791 11.313 4.687l4.687-4.687v12z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 713 B After Width: | Height: | Size: 499 B |
@@ -1,6 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Generated by IcoMoon.io -->
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="33" height="33" viewBox="0 0 33 33">
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" viewBox="0 0 32 32">
|
|
||||||
<path d="M20 4.581v4.249c1.131 0.494 2.172 1.2 3.071 2.099 1.889 1.889 2.929 4.4 2.929 7.071s-1.040 5.182-2.929 7.071c-1.889 1.889-4.4 2.929-7.071 2.929s-5.182-1.040-7.071-2.929c-1.889-1.889-2.929-4.4-2.929-7.071s1.040-5.182 2.929-7.071c0.899-0.899 1.94-1.606 3.071-2.099v-4.249c-5.783 1.721-10 7.077-10 13.419 0 7.732 6.268 14 14 14s14-6.268 14-14c0-6.342-4.217-11.698-10-13.419zM14 0h4v16h-4z"></path>
|
<path d="M20 4.581v4.249c1.131 0.494 2.172 1.2 3.071 2.099 1.889 1.889 2.929 4.4 2.929 7.071s-1.040 5.182-2.929 7.071c-1.889 1.889-4.4 2.929-7.071 2.929s-5.182-1.040-7.071-2.929c-1.889-1.889-2.929-4.4-2.929-7.071s1.040-5.182 2.929-7.071c0.899-0.899 1.94-1.606 3.071-2.099v-4.249c-5.783 1.721-10 7.077-10 13.419 0 7.732 6.268 14 14 14s14-6.268 14-14c0-6.342-4.217-11.698-10-13.419zM14 0h4v16h-4z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 723 B After Width: | Height: | Size: 510 B |
@@ -63,10 +63,10 @@
|
|||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
<a href="https://github.com/cmmcleod/coriolis" target="_blank" title="Coriolis Github Project">Version <%= version %> - <%= date %></a>
|
<a href="https://github.com/cmmcleod/coriolis/releases/" target="_blank" title="Coriolis Github Project">Version <%= version %> - <%= date %></a>
|
||||||
</div>
|
</div>
|
||||||
<div style="max-width:50%" class="l">
|
<div style="max-width:50%" class="l">
|
||||||
Coriolis Shipyard was created for non-commercial purposes. It is not endorsed by nor reflects the views or opinions of Frontier Developments.
|
Coriolis was created using assets and imagery from Elite: Dangerous, with the permission of Frontier Developments plc, for non-commercial purposes. It is not endorsed by nor reflects the views or opinions of Frontier Developments and no employee of Frontier Developments was involved in the making of it.
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
angular.module('app', ['ui.router', 'ct.ui.router.extras.sticky', 'ui.sortable', 'shipyard', 'ngLodash', 'app.templates'])
|
angular.module('app', ['ui.router', 'ct.ui.router.extras.sticky', 'ui.sortable', 'shipyard', 'ngLodash', 'app.templates'])
|
||||||
.run(['$rootScope', '$location', '$window', '$document', '$state', 'commonArray', 'shipPurpose', 'shipSize', 'hardPointClass', 'GroupMap', 'Persist',
|
.run(['$rootScope', '$location', '$window', '$document', '$state', 'commonArray', 'shipPurpose', 'shipSize', 'hardPointClass', 'GroupMap', 'Persist', 'Discounts',
|
||||||
function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hpc, GroupMap, Persist) {
|
function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hpc, GroupMap, Persist, Discounts) {
|
||||||
// App is running as a standalone web app on tablet/mobile
|
// App is running as a standalone web app on tablet/mobile
|
||||||
var isStandAlone = $window.navigator.standalone || ($window.external && $window.external.msIsSiteMode && $window.external.msIsSiteMode());
|
var isStandAlone;
|
||||||
|
// This was causing issues on Windows phones ($window.external was causing Angular js to throw an exception). Backup is to try this and set isStandAlone to false if this fails.
|
||||||
|
try {
|
||||||
|
isStandAlone = $window.navigator.standalone || ($window.external && $window.external.msIsSiteMode && $window.external.msIsSiteMode());
|
||||||
|
} catch (ex) {
|
||||||
|
isStandAlone = false;
|
||||||
|
}
|
||||||
|
|
||||||
// Redirect any state transition errors to the error controller/state
|
// Redirect any state transition errors to the error controller/state
|
||||||
$rootScope.$on('$stateChangeError', function(e, toState, toParams, fromState, fromParams, error) {
|
$rootScope.$on('$stateChangeError', function(e, toState, toParams, fromState, fromParams, error) {
|
||||||
@@ -34,7 +40,7 @@ function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hp
|
|||||||
$rootScope.HPC = hpc;
|
$rootScope.HPC = hpc;
|
||||||
$rootScope.GMAP = GroupMap;
|
$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.035 }] };
|
||||||
$rootScope.discounts = { opts: [{ name: 'None', pct: 1 }, { name: 'Founders World - 10%', pct: 0.90 }] };
|
$rootScope. discounts = { opts: Discounts };
|
||||||
$rootScope.STATUS = ['', 'DISABLED', 'OFF', 'ON'];
|
$rootScope.STATUS = ['', 'DISABLED', 'OFF', 'ON'];
|
||||||
$rootScope.STATUS_CLASS = ['', 'disabled', 'warning', 'secondary-disabled'];
|
$rootScope.STATUS_CLASS = ['', 'disabled', 'warning', 'secondary-disabled'];
|
||||||
$rootScope.title = 'Coriolis';
|
$rootScope.title = 'Coriolis';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
angular.module('app').controller('OutfitController', ['$window', '$rootScope', '$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', function($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist) {
|
angular.module('app').controller('OutfitController', ['$window', '$rootScope', '$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', 'calcTotalRange', 'calcSpeed', function($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist, calcTotalRange, calcSpeed) {
|
||||||
var data = Ships[$p.shipId]; // Retrieve the basic ship properties, slots and defaults
|
var data = Ships[$p.shipId]; // Retrieve the basic ship properties, slots and defaults
|
||||||
var ship = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship instance
|
var ship = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship instance
|
||||||
var win = angular.element($window); // Angularized window object for event triggering
|
var win = angular.element($window); // Angularized window object for event triggering
|
||||||
@@ -11,6 +11,8 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
ship.buildWith(data.defaults); // Populate with default components
|
ship.buildWith(data.defaults); // Populate with default components
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ship.applyDiscounts($rootScope.discounts.ship, $rootScope.discounts.components);
|
||||||
|
|
||||||
$scope.buildName = $p.bn;
|
$scope.buildName = $p.bn;
|
||||||
$rootScope.title = ship.name + ($scope.buildName ? ' - ' + $scope.buildName : '');
|
$rootScope.title = ship.name + ($scope.buildName ? ' - ' + $scope.buildName : '');
|
||||||
$scope.ship = ship;
|
$scope.ship = ship;
|
||||||
@@ -39,8 +41,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
$scope.jrSeries = {
|
$scope.jrSeries = {
|
||||||
xMin: 0,
|
xMin: 0,
|
||||||
xMax: ship.cargoCapacity,
|
xMax: ship.cargoCapacity,
|
||||||
// Slightly higher than actual based bacuse components are excluded
|
yMax: ship.unladenRange,
|
||||||
yMax: ship.jumpRangeWithMass(ship.unladenMass),
|
|
||||||
yMin: 0,
|
yMin: 0,
|
||||||
func: function(cargo) { // X Axis is Cargo
|
func: function(cargo) { // X Axis is Cargo
|
||||||
return ship.jumpRangeWithMass(ship.unladenMass + $scope.fuel + cargo, $scope.fuel);
|
return ship.jumpRangeWithMass(ship.unladenMass + $scope.fuel + cargo, $scope.fuel);
|
||||||
@@ -56,8 +57,52 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
title: 'Jump Range',
|
title: 'Jump Range',
|
||||||
unit: 'LY'
|
unit: 'LY'
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
watch: $scope.fsd
|
};
|
||||||
|
|
||||||
|
$scope.trSeries = {
|
||||||
|
xMin: 0,
|
||||||
|
xMax: ship.cargoCapacity,
|
||||||
|
yMax: ship.unladenTotalRange,
|
||||||
|
yMin: 0,
|
||||||
|
func: function(cargo) { // X Axis is Cargo
|
||||||
|
return calcTotalRange(ship.unladenMass + cargo, $scope.fsd.c, $scope.fuel);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$scope.trChart = {
|
||||||
|
labels: {
|
||||||
|
xAxis: {
|
||||||
|
title: 'Cargo',
|
||||||
|
unit: 'T'
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
title: 'Total Range',
|
||||||
|
unit: 'LY'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.speedSeries = {
|
||||||
|
xMin: 0,
|
||||||
|
xMax: ship.cargoCapacity,
|
||||||
|
yMax: 500,
|
||||||
|
yMin: 0,
|
||||||
|
series: ['speed', 'boost'],
|
||||||
|
func: function(cargo) { // X Axis is Cargo
|
||||||
|
return calcSpeed(ship.unladenMass + $scope.fuel + cargo, ship.speed, ship.boost, $scope.th.c);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$scope.speedChart = {
|
||||||
|
labels: {
|
||||||
|
xAxis: {
|
||||||
|
title: 'Cargo',
|
||||||
|
unit: 'T'
|
||||||
|
},
|
||||||
|
yAxis: {
|
||||||
|
title: 'Speed',
|
||||||
|
unit: 'm/s'
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,8 +145,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
ship.useBulkhead(id);
|
ship.useBulkhead(id);
|
||||||
}
|
}
|
||||||
$scope.selectedSlot = null;
|
$scope.selectedSlot = null;
|
||||||
$scope.code = Serializer.fromShip(ship);
|
updateState(Serializer.fromShip(ship));
|
||||||
updateState();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,11 +155,24 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
$scope.reloadBuild = function() {
|
$scope.reloadBuild = function() {
|
||||||
if ($scope.buildName && $scope.savedCode) {
|
if ($scope.buildName && $scope.savedCode) {
|
||||||
Serializer.toShip(ship, $scope.savedCode); // Repopulate with components from last save
|
Serializer.toShip(ship, $scope.savedCode); // Repopulate with components from last save
|
||||||
$scope.code = $scope.savedCode;
|
updateState($scope.savedCode);
|
||||||
updateState();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip ship to D-class and no other components.
|
||||||
|
*/
|
||||||
|
$scope.stripBuild = function() {
|
||||||
|
for (var i = 0, l = ship.common.length - 1; i < l; i++) { // All except Fuel Tank
|
||||||
|
var id = ship.common[i].maxClass + 'D';
|
||||||
|
ship.use(ship.common[i], id, Components.common(i, id));
|
||||||
|
}
|
||||||
|
ship.hardpoints.forEach(function(slot) { ship.use(slot, null, null); });
|
||||||
|
ship.internal.forEach(function(slot) { ship.use(slot, null, null); });
|
||||||
|
ship.useBulkhead(0);
|
||||||
|
updateState(Serializer.fromShip(ship));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the current build. Will replace the saved build if there is one
|
* Save the current build. Will replace the saved build if there is one
|
||||||
* for this ship & with the exact name.
|
* for this ship & with the exact name.
|
||||||
@@ -132,7 +189,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
if ($scope.code != $scope.savedCode) {
|
if ($scope.code != $scope.savedCode) {
|
||||||
Persist.saveBuild(ship.id, $scope.buildName, $scope.code);
|
Persist.saveBuild(ship.id, $scope.buildName, $scope.code);
|
||||||
$scope.savedCode = $scope.code;
|
$scope.savedCode = $scope.code;
|
||||||
updateState();
|
updateState($scope.code);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -181,21 +238,18 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
*/
|
*/
|
||||||
$scope.togglePwr = function(c) {
|
$scope.togglePwr = function(c) {
|
||||||
ship.setSlotEnabled(c, !c.enabled);
|
ship.setSlotEnabled(c, !c.enabled);
|
||||||
$scope.code = Serializer.fromShip(ship);
|
updateState(Serializer.fromShip(ship));
|
||||||
updateState();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.incPriority = function(c) {
|
$scope.incPriority = function(c) {
|
||||||
if (ship.changePriority(c, c.priority + 1)) {
|
if (ship.changePriority(c, c.priority + 1)) {
|
||||||
$scope.code = Serializer.fromShip(ship);
|
updateState(Serializer.fromShip(ship));
|
||||||
updateState();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.decPriority = function(c) {
|
$scope.decPriority = function(c) {
|
||||||
if (ship.changePriority(c, c.priority - 1)) {
|
if (ship.changePriority(c, c.priority - 1)) {
|
||||||
$scope.code = Serializer.fromShip(ship);
|
updateState(Serializer.fromShip(ship));
|
||||||
updateState();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -214,11 +268,12 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
|
|
||||||
// Utilify functions
|
// Utilify functions
|
||||||
|
|
||||||
function updateState() {
|
function updateState(code) {
|
||||||
|
$scope.code = code;
|
||||||
$state.go('outfit', { shipId: ship.id, code: $scope.code, bn: $scope.buildName }, { location: 'replace', notify: false });
|
$state.go('outfit', { shipId: ship.id, code: $scope.code, bn: $scope.buildName }, { location: 'replace', notify: false });
|
||||||
$scope.jrSeries.xMax = ship.cargoCapacity;
|
$scope.speedSeries.xMax = $scope.trSeries.xMax = $scope.jrSeries.xMax = ship.cargoCapacity;
|
||||||
$scope.jrSeries.yMax = ship.jumpRangeWithMass(ship.unladenMass);
|
$scope.jrSeries.yMax = ship.unladenRange;
|
||||||
$scope.jrSeries.mass = ship.unladenMass;
|
$scope.trSeries.yMax = ship.unladenTotalRange;
|
||||||
win.triggerHandler('pwrchange');
|
win.triggerHandler('pwrchange');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,4 +282,9 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
$scope.selectedSlot = null;
|
$scope.selectedSlot = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Hide any open menu/slot/etc if the background is clicked
|
||||||
|
$scope.$on('discountChange', function() {
|
||||||
|
ship.applyDiscounts($rootScope.discounts.ship, $rootScope.discounts.components);
|
||||||
|
});
|
||||||
|
|
||||||
}]);
|
}]);
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
xAxis = d3.svg.axis().outerTickSize(0).orient('bottom').tickFormat(d3.format('.2r')),
|
xAxis = d3.svg.axis().outerTickSize(0).orient('bottom').tickFormat(d3.format('.2r')),
|
||||||
yAxis = d3.svg.axis().ticks(6).outerTickSize(0).orient('left').tickFormat(fmt),
|
yAxis = d3.svg.axis().ticks(6).outerTickSize(0).orient('left').tickFormat(fmt),
|
||||||
x = d3.scale.linear(),
|
x = d3.scale.linear(),
|
||||||
y = d3.scale.linear();
|
y = d3.scale.linear(),
|
||||||
|
data = [];
|
||||||
|
|
||||||
// Create chart
|
// Create chart
|
||||||
var svg = d3.select(element[0]).append('svg');
|
var svg = d3.select(element[0]).append('svg');
|
||||||
@@ -61,13 +62,35 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
|
|
||||||
// Create and Add tooltip
|
// Create and Add tooltip
|
||||||
var tip = vis.append('g').style('display', 'none');
|
var tip = vis.append('g').style('display', 'none');
|
||||||
tip.append('rect').attr('width', '4em').attr('height', '2em').attr('x', '0.5em').attr('y', '-1em').attr('class', 'tip');
|
tip.append('rect').attr('width', '4.5em').attr('height', '2em').attr('x', '0.5em').attr('y', '-1em').attr('class', 'tip');
|
||||||
tip.append('circle')
|
tip.append('circle')
|
||||||
.attr('class', 'marker')
|
.attr('class', 'marker')
|
||||||
.attr('r', 4);
|
.attr('r', 4);
|
||||||
tip.append('text').attr('class', 'label x').attr('y', '-0.25em');
|
tip.append('text').attr('class', 'label x').attr('y', '-0.25em');
|
||||||
tip.append('text').attr('class', 'label y').attr('y', '0.85em');
|
tip.append('text').attr('class', 'label y').attr('y', '0.85em');
|
||||||
|
|
||||||
|
vis.insert('path', ':first-child') // Area/Path to appear behind everything else
|
||||||
|
.data([data])
|
||||||
|
.attr('class', 'area')
|
||||||
|
.attr('fill', 'url(#gradient)')
|
||||||
|
.attr('d', area)
|
||||||
|
.on('mouseover', showTip)
|
||||||
|
.on('mouseout', hideTip)
|
||||||
|
.on('mousemove', moveTip)
|
||||||
|
.call(drag);
|
||||||
|
|
||||||
|
drag
|
||||||
|
.on('dragstart', function() {
|
||||||
|
dragging = true;
|
||||||
|
moveTip.call(this);
|
||||||
|
showTip();
|
||||||
|
})
|
||||||
|
.on('dragend', function() {
|
||||||
|
dragging = false;
|
||||||
|
hideTip();
|
||||||
|
})
|
||||||
|
.on('drag', moveTip);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Watch for changes in the series data (mass changes, etc)
|
* Watch for changes in the series data (mass changes, etc)
|
||||||
*/
|
*/
|
||||||
@@ -78,8 +101,9 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
var width = element[0].parentElement.offsetWidth,
|
var width = element[0].parentElement.offsetWidth,
|
||||||
height = width * 0.5,
|
height = width * 0.5,
|
||||||
w = width - margin.left - margin.right,
|
w = width - margin.left - margin.right,
|
||||||
h = height - margin.top - margin.bottom,
|
h = height - margin.top - margin.bottom;
|
||||||
data = [];
|
|
||||||
|
data.length = 0; // Reset Data array
|
||||||
|
|
||||||
if (series.xMax == series.xMin) {
|
if (series.xMax == series.xMin) {
|
||||||
var yVal = func(series.xMin);
|
var yVal = func(series.xMin);
|
||||||
@@ -95,7 +119,7 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
|
|
||||||
// Update Chart Size
|
// Update Chart Size
|
||||||
svg.attr('width', width).attr('height', height);
|
svg.attr('width', width).attr('height', height);
|
||||||
// Update domain and scale for axes;
|
// Update domain and scale for axes
|
||||||
x.range([0, w]).domain([series.xMin, series.xMax]).clamp(true);
|
x.range([0, w]).domain([series.xMin, series.xMax]).clamp(true);
|
||||||
xAxis.scale(x);
|
xAxis.scale(x);
|
||||||
xLbl.attr('transform', 'translate(0,' + h + ')');
|
xLbl.attr('transform', 'translate(0,' + h + ')');
|
||||||
@@ -106,30 +130,9 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
vis.selectAll('.y.axis').call(yAxis);
|
vis.selectAll('.y.axis').call(yAxis);
|
||||||
vis.selectAll('.x.axis').call(xAxis);
|
vis.selectAll('.x.axis').call(xAxis);
|
||||||
|
|
||||||
// Remove existing elements
|
vis.selectAll('path.area') // Area/Path to appear behind everything else
|
||||||
vis.selectAll('path.area').remove();
|
.data([data])
|
||||||
|
.attr('d', area);
|
||||||
vis.insert('path', ':first-child') // Area/Path to appear behind everything else
|
|
||||||
.datum(data)
|
|
||||||
.attr('class', 'area')
|
|
||||||
.attr('fill', 'url(#gradient)')
|
|
||||||
.attr('d', area)
|
|
||||||
.on('mouseover', showTip)
|
|
||||||
.on('mouseout', hideTip)
|
|
||||||
.on('mousemove', moveTip)
|
|
||||||
.call(drag);
|
|
||||||
|
|
||||||
drag
|
|
||||||
.on('dragstart', function() {
|
|
||||||
dragging = true;
|
|
||||||
moveTip.call(this);
|
|
||||||
showTip();
|
|
||||||
})
|
|
||||||
.on('dragend', function() {
|
|
||||||
dragging = false;
|
|
||||||
hideTip();
|
|
||||||
})
|
|
||||||
.on('drag', moveTip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTip() {
|
function showTip() {
|
||||||
@@ -143,10 +146,10 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function moveTip() {
|
function moveTip() {
|
||||||
var xPos = d3.mouse(this)[0], x0 = x.invert(xPos), y0 = func(x0), flip = (x0 / x.domain()[1] > 0.75);
|
var xPos = d3.mouse(this)[0], x0 = x.invert(xPos), y0 = func(x0), flip = (x0 / x.domain()[1] > 0.65);
|
||||||
tip.attr('transform', 'translate(' + x(x0) + ',' + y(y0) + ')');
|
tip.attr('transform', 'translate(' + x(x0) + ',' + y(y0) + ')');
|
||||||
tip.selectAll('rect').attr('x', flip ? '-4.5em' : '0.5em').style('text-anchor', flip ? 'end' : 'start');
|
tip.selectAll('rect').attr('x', flip ? '-5.75em' : '0.5em').style('text-anchor', flip ? 'end' : 'start');
|
||||||
tip.selectAll('text.label').attr('x', flip ? '-1em' : '1em').style('text-anchor', flip ? 'end' : 'start');
|
tip.selectAll('text.label').attr('x', flip ? '-2em' : '1em').style('text-anchor', flip ? 'end' : 'start');
|
||||||
tip.select('text.label.x').text(fmtLong(x0) + ' ' + labels.xAxis.unit);
|
tip.select('text.label.x').text(fmtLong(x0) + ' ' + labels.xAxis.unit);
|
||||||
tip.select('text.label.y').text(fmtLong(y0) + ' ' + labels.yAxis.unit);
|
tip.select('text.label.y').text(fmtLong(y0) + ' ' + labels.yAxis.unit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
|
|||||||
scope.bs = Persist.state;
|
scope.bs = Persist.state;
|
||||||
|
|
||||||
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
|
var insIndex = _.findIndex($rootScope.insurance.opts, 'name', Persist.getInsurance());
|
||||||
|
var savedDiscounts = Persist.getDiscount() || [1, 1];
|
||||||
$rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1 ? insIndex : 0];
|
$rootScope.insurance.current = $rootScope.insurance.opts[insIndex != -1 ? insIndex : 0];
|
||||||
$rootScope.discounts.current = $rootScope.discounts.opts[Persist.getDiscount() || 0];
|
$rootScope.discounts.ship = savedDiscounts[0];
|
||||||
|
$rootScope.discounts.components = savedDiscounts[1];
|
||||||
|
|
||||||
// Close menus if a navigation change event occurs
|
// Close menus if a navigation change event occurs
|
||||||
$rootScope.$on('$stateChangeStart', function() {
|
$rootScope.$on('$stateChangeStart', function() {
|
||||||
@@ -38,7 +40,8 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
|
|||||||
* Save selected discount option
|
* Save selected discount option
|
||||||
*/
|
*/
|
||||||
scope.updateDiscount = function() {
|
scope.updateDiscount = function() {
|
||||||
Persist.setDiscount($rootScope.discounts.opts.indexOf($rootScope.discounts.current));
|
Persist.setDiscount([$rootScope.discounts.ship, $rootScope.discounts.components]);
|
||||||
|
$rootScope.$broadcast('discountChange');
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.openMenu = function(e, menu) {
|
scope.openMenu = function(e, menu) {
|
||||||
|
|||||||
190
app/js/directives/directive-line-chart.js
Normal file
190
app/js/directives/directive-line-chart.js
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
angular.module('app').directive('lineChart', ['$window', function($window) {
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
scope: {
|
||||||
|
config: '=',
|
||||||
|
series: '='
|
||||||
|
},
|
||||||
|
link: function(scope, element) {
|
||||||
|
var seriesConfig = scope.series,
|
||||||
|
series = seriesConfig.series,
|
||||||
|
color = d3.scale.ordinal().range([ '#ff8c0d', '#1fb0ff', '#a05d56', '#d0743c']),
|
||||||
|
config = scope.config,
|
||||||
|
labels = config.labels,
|
||||||
|
margin = { top: 15, right: 15, bottom: 35, left: 60 },
|
||||||
|
fmt = d3.format('.3r'),
|
||||||
|
fmtLong = d3.format('.2f'),
|
||||||
|
func = seriesConfig.func,
|
||||||
|
drag = d3.behavior.drag(),
|
||||||
|
dragging = false,
|
||||||
|
// Define Scales
|
||||||
|
x = d3.scale.linear(),
|
||||||
|
y = d3.scale.linear(),
|
||||||
|
// Define Axes
|
||||||
|
xAxis = d3.svg.axis().scale(x).outerTickSize(0).orient('bottom').tickFormat(d3.format('.2r')),
|
||||||
|
yAxis = d3.svg.axis().scale(y).ticks(6).outerTickSize(0).orient('left').tickFormat(fmt),
|
||||||
|
data = [];
|
||||||
|
|
||||||
|
// Create chart
|
||||||
|
var svg = d3.select(element[0]).append('svg');
|
||||||
|
var vis = svg.append('g').attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
|
||||||
|
var lines = vis.append('g');
|
||||||
|
|
||||||
|
// Define Area
|
||||||
|
var line = d3.svg.line().y(function(d) { return y(d[1]); });
|
||||||
|
|
||||||
|
// Create Y Axis SVG Elements
|
||||||
|
var yTxt = vis.append('g').attr('class', 'y axis')
|
||||||
|
.append('text')
|
||||||
|
.attr('transform', 'rotate(-90)')
|
||||||
|
.attr('y', -50)
|
||||||
|
.attr('dy', '.1em')
|
||||||
|
.style('text-anchor', 'middle')
|
||||||
|
.text(labels.yAxis.title + ' (' + labels.yAxis.unit + ')');
|
||||||
|
// Create X Axis SVG Elements
|
||||||
|
var xLbl = vis.append('g').attr('class', 'x axis');
|
||||||
|
var xTxt = xLbl.append('text')
|
||||||
|
.attr('y', 30)
|
||||||
|
.attr('dy', '.1em')
|
||||||
|
.style('text-anchor', 'middle')
|
||||||
|
.text(labels.xAxis.title + ' (' + labels.xAxis.unit + ')');
|
||||||
|
|
||||||
|
// Create and Add tooltip
|
||||||
|
var tipWidth = (Math.max(labels.yAxis.unit.length, labels.xAxis.unit.length) * 1.25) + 2;
|
||||||
|
var tips = vis.append('g').style('display', 'none');
|
||||||
|
|
||||||
|
var background = vis.append('rect') // Background to capture hover/drag
|
||||||
|
.attr('fill-opacity', 0)
|
||||||
|
.on('mouseover', showTip)
|
||||||
|
.on('mouseout', hideTip)
|
||||||
|
.on('mousemove', moveTip)
|
||||||
|
.call(drag);
|
||||||
|
|
||||||
|
drag
|
||||||
|
.on('dragstart', function() {
|
||||||
|
dragging = true;
|
||||||
|
moveTip.call(this);
|
||||||
|
showTip();
|
||||||
|
})
|
||||||
|
.on('dragend', function() {
|
||||||
|
dragging = false;
|
||||||
|
hideTip();
|
||||||
|
})
|
||||||
|
.on('drag', moveTip);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watch for changes in the series data (mass changes, etc)
|
||||||
|
*/
|
||||||
|
scope.$watchCollection('series', render);
|
||||||
|
angular.element($window).bind('orientationchange resize render', render);
|
||||||
|
|
||||||
|
function render() {
|
||||||
|
var width = element[0].parentElement.offsetWidth,
|
||||||
|
height = width * 0.5,
|
||||||
|
xMax = seriesConfig.xMax,
|
||||||
|
xMin = seriesConfig.xMin,
|
||||||
|
yMax = seriesConfig.yMax,
|
||||||
|
yMin = seriesConfig.yMin,
|
||||||
|
w = width - margin.left - margin.right,
|
||||||
|
h = height - margin.top - margin.bottom,
|
||||||
|
s, val, yVal, delta;
|
||||||
|
|
||||||
|
data.length = 0; // Reset Data array
|
||||||
|
|
||||||
|
if (seriesConfig.xMax == seriesConfig.xMin) {
|
||||||
|
line.x(function(d, i) { return i * w; });
|
||||||
|
} else {
|
||||||
|
line.x(function(d) { return x(d[0]); });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (series) {
|
||||||
|
for (s = 0; s < series.length; s++) {
|
||||||
|
data.push([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xMax == xMin) {
|
||||||
|
yVal = func(xMin);
|
||||||
|
for (s = 0; s < series.length; s++) {
|
||||||
|
data[s].push( [ xMin, yVal[ series[s] ] ], [ 1, yVal[ series[s] ] ]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delta = (xMax - xMin) / 30; // Only render 30 points on the graph
|
||||||
|
for (val = xMin; val <= xMax; val += delta) {
|
||||||
|
yVal = func(val);
|
||||||
|
for (s = 0; s < series.length; s++) {
|
||||||
|
data[s].push([ val, yVal[ series[s] ] ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
var seriesData = [];
|
||||||
|
if (xMax == xMin) {
|
||||||
|
yVal = func(xMin);
|
||||||
|
seriesData.push([ xMin, yVal ], [ 1, yVal ]);
|
||||||
|
} else {
|
||||||
|
delta = (xMax - xMin) / 30; // Only render 30 points on the graph
|
||||||
|
for (val = xMin; val <= xMax; val += delta) {
|
||||||
|
seriesData.push([val, func(val) ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data.push(seriesData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update Chart Size
|
||||||
|
svg.attr('width', width).attr('height', height);
|
||||||
|
background.attr('height', h).attr('width', w);
|
||||||
|
|
||||||
|
// Update domain and scale for axes
|
||||||
|
x.range([0, w]).domain([xMin, xMax]).clamp(true);
|
||||||
|
xLbl.attr('transform', 'translate(0,' + h + ')');
|
||||||
|
xTxt.attr('x', w / 2);
|
||||||
|
y.range([h, 0]).domain([yMin, yMax]);
|
||||||
|
yTxt.attr('x', -h / 2);
|
||||||
|
vis.selectAll('.y.axis').call(yAxis);
|
||||||
|
vis.selectAll('.x.axis').call(xAxis);
|
||||||
|
|
||||||
|
lines.selectAll('path.line')
|
||||||
|
.data(data)
|
||||||
|
.attr('d', line) // Update existing series
|
||||||
|
.enter() // Add new series
|
||||||
|
.append('path')
|
||||||
|
.attr('class', 'line')
|
||||||
|
.attr('stroke', function(d, i) { return color(i); })
|
||||||
|
.attr('stroke-width', 2)
|
||||||
|
.attr('d', line);
|
||||||
|
|
||||||
|
var tip = tips.selectAll('g.tooltip').data(data).enter().append('g').attr('class', 'tooltip');
|
||||||
|
tip.append('rect').attr('width', tipWidth + 'em').attr('height', '2em').attr('x', '0.5em').attr('y', '-1em').attr('class', 'tip');
|
||||||
|
tip.append('circle').attr('class', 'marker').attr('r', 4);
|
||||||
|
tip.append('text').attr('class', 'label x').attr('y', '-0.25em');
|
||||||
|
tip.append('text').attr('class', 'label y').attr('y', '0.85em');
|
||||||
|
}
|
||||||
|
|
||||||
|
function showTip() {
|
||||||
|
tips.style('display', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideTip() {
|
||||||
|
if (!dragging) {
|
||||||
|
tips.style('display', 'none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function moveTip() {
|
||||||
|
var xPos = d3.mouse(this)[0], x0 = x.invert(xPos), y0 = func(x0), flip = (x0 / x.domain()[1] > 0.65);
|
||||||
|
var tip = tips.selectAll('g.tooltip').attr('transform', function(d, i) { return 'translate(' + x(x0) + ',' + y(series ? y0[series[i]] : y0) + ')'; });
|
||||||
|
tip.selectAll('rect').attr('x', flip ? (-tipWidth - 0.5) + 'em' : '0.5em').style('text-anchor', flip ? 'end' : 'start');
|
||||||
|
tip.selectAll('text.label').attr('x', flip ? '-1em' : '1em').style('text-anchor', flip ? 'end' : 'start');
|
||||||
|
tip.selectAll('text.label.x').text(fmtLong(x0) + ' ' + labels.xAxis.unit);
|
||||||
|
tips.selectAll('text.label.y').text(function(d, i) { return fmtLong(series ? y0[series[i]] : y0) + ' ' + labels.yAxis.unit; });
|
||||||
|
}
|
||||||
|
|
||||||
|
scope.$on('$destroy', function() {
|
||||||
|
angular.element($window).unbind('orientationchange resize render', render);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
@@ -8,7 +8,7 @@ angular.module('app').directive('slider', ['$window', function($window) {
|
|||||||
change: '&onChange'
|
change: '&onChange'
|
||||||
},
|
},
|
||||||
link: function(scope, element) {
|
link: function(scope, element) {
|
||||||
var margin = { top: -10, right: 140, bottom: 0, left: 50 },
|
var margin = { top: -10, right: 145, bottom: 0, left: 50 },
|
||||||
height = 40, // Height is fixed
|
height = 40, // Height is fixed
|
||||||
h = height - margin.top - margin.bottom,
|
h = height - margin.top - margin.bottom,
|
||||||
fmt = d3.format('.2f'),
|
fmt = d3.format('.2f'),
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
|
|||||||
*/
|
*/
|
||||||
this.setDiscount = function(val) {
|
this.setDiscount = function(val) {
|
||||||
if (this.lsEnabled) {
|
if (this.lsEnabled) {
|
||||||
return localStorage.setItem('discount', val);
|
return localStorage.setItem('discounts', angular.toJson(val));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
|
|||||||
*/
|
*/
|
||||||
this.getDiscount = function() {
|
this.getDiscount = function() {
|
||||||
if (this.lsEnabled) {
|
if (this.lsEnabled) {
|
||||||
return localStorage.getItem('discount');
|
return angular.fromJson(localStorage.getItem('discounts'));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, _) {
|
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, _) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the power usage type of a slot and it's particular component
|
* Returns the power usage type of a slot and it's particular component
|
||||||
@@ -28,7 +28,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
function Ship(id, properties, slots) {
|
function Ship(id, properties, slots) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.cargoScoop = { c: Components.cargoScoop(), type: 'SYS' };
|
this.cargoScoop = { c: Components.cargoScoop(), type: 'SYS' };
|
||||||
this.bulkheads = { incCost: true, maxClass: 8, discount: 1 };
|
this.bulkheads = { incCost: true, maxClass: 8 };
|
||||||
|
|
||||||
for (var p in properties) { this[p] = properties[p]; } // Copy all base properties from shipData
|
for (var p in properties) { this[p] = properties[p]; } // Copy all base properties from shipData
|
||||||
|
|
||||||
@@ -36,10 +36,11 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
var slotGroup = slots[slotType];
|
var slotGroup = slots[slotType];
|
||||||
var group = this[slotType] = []; // Initialize Slot group (Common, Hardpoints, Internal)
|
var group = this[slotType] = []; // Initialize Slot group (Common, Hardpoints, Internal)
|
||||||
for (var i = 0; i < slotGroup.length; i++) {
|
for (var i = 0; i < slotGroup.length; i++) {
|
||||||
group.push({ id: null, c: null, incCost: true, maxClass: slotGroup[i], discount: 1 });
|
group.push({ id: null, c: null, incCost: true, maxClass: slotGroup[i] });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.c = { incCost: true, discount: 1, c: { name: this.name, cost: this.cost } }; // Make a 'Ship' component similar to other components
|
// Make a Ship 'slot'/item similar to other slots
|
||||||
|
this.c = { incCost: true, type: 'SHIP', discountedCost: this.cost, c: { name: this.name, cost: this.cost } };
|
||||||
|
|
||||||
this.costList = _.union(this.internal, this.common, this.hardpoints);
|
this.costList = _.union(this.internal, this.common, this.hardpoints);
|
||||||
this.costList.push(this.bulkheads); // Add The bulkheads
|
this.costList.push(this.bulkheads); // Add The bulkheads
|
||||||
@@ -54,6 +55,9 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
this.powerList.unshift(this.common[2]); // Add FSD
|
this.powerList.unshift(this.common[2]); // Add FSD
|
||||||
this.powerList.unshift(this.common[0]); // Add Power Plant
|
this.powerList.unshift(this.common[0]); // Add Power Plant
|
||||||
|
|
||||||
|
this.shipDiscount = 1;
|
||||||
|
this.componentDiscount = 1;
|
||||||
|
|
||||||
this.priorityBands = [
|
this.priorityBands = [
|
||||||
{ deployed: 0, retracted: 0, retOnly: 0 },
|
{ deployed: 0, retracted: 0, retOnly: 0 },
|
||||||
{ deployed: 0, retracted: 0, retOnly: 0 },
|
{ deployed: 0, retracted: 0, retOnly: 0 },
|
||||||
@@ -81,7 +85,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
this.ladenMass = 0;
|
this.ladenMass = 0;
|
||||||
this.armourAdded = 0;
|
this.armourAdded = 0;
|
||||||
this.shieldMultiplier = 1;
|
this.shieldMultiplier = 1;
|
||||||
this.totalCost = this.cost;
|
this.totalCost = this.c.incCost ? this.c.discountedCost : 0;
|
||||||
this.unladenMass = this.mass;
|
this.unladenMass = this.mass;
|
||||||
this.armourTotal = this.armour;
|
this.armourTotal = this.armour;
|
||||||
|
|
||||||
@@ -106,6 +110,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
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
|
||||||
|
common[i].discountedCost = 0;
|
||||||
this.use(common[i], comps.common[i], Components.common(i, comps.common[i]), true);
|
this.use(common[i], comps.common[i], Components.common(i, comps.common[i]), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +124,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
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
|
||||||
|
hps[i].discountedCost = 0;
|
||||||
|
|
||||||
if (comps.hardpoints[i] !== 0) {
|
if (comps.hardpoints[i] !== 0) {
|
||||||
this.use(hps[i], comps.hardpoints[i], Components.hardpoints(comps.hardpoints[i]), true);
|
this.use(hps[i], comps.hardpoints[i], Components.hardpoints(comps.hardpoints[i]), true);
|
||||||
@@ -133,6 +139,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
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
|
||||||
|
internal[i].discountedCost = 0;
|
||||||
|
|
||||||
if (comps.internal[i] !== 0) {
|
if (comps.internal[i] !== 0) {
|
||||||
this.use(internal[i], comps.internal[i], Components.internal(comps.internal[i]), true);
|
this.use(internal[i], comps.internal[i], Components.internal(comps.internal[i]), true);
|
||||||
@@ -149,6 +156,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
var oldBulkhead = this.bulkheads.c;
|
var oldBulkhead = this.bulkheads.c;
|
||||||
this.bulkheads.id = index;
|
this.bulkheads.id = index;
|
||||||
this.bulkheads.c = Components.bulkheads(this.id, index);
|
this.bulkheads.c = Components.bulkheads(this.id, index);
|
||||||
|
this.bulkheads.discountedCost = this.bulkheads.c.cost * this.componentDiscount;
|
||||||
this.updateStats(this.bulkheads, this.bulkheads.c, oldBulkhead, preventUpdate);
|
this.updateStats(this.bulkheads, this.bulkheads.c, oldBulkhead, preventUpdate);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -164,18 +172,20 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
Ship.prototype.use = function(slot, id, component, preventUpdate) {
|
Ship.prototype.use = function(slot, id, component, preventUpdate) {
|
||||||
if (slot.id != id) { // Selecting a different component
|
if (slot.id != id) { // Selecting a different component
|
||||||
// Slot is an internal slot, is not being emptied, and the selected component group/type must be of unique
|
// Slot is an internal slot, is not being emptied, and the selected component group/type must be of unique
|
||||||
if (slot.cat != 2 && component && _.includes(['sg', 'rf', 'fs'], component.grp)) {
|
if (slot.cat == 2 && component && _.includes(['sg', 'rf', 'fs'], component.grp)) {
|
||||||
// Find another internal slot that already has this type/group installed
|
// Find another internal slot that already has this type/group installed
|
||||||
var similarSlot = this.findInternalByGroup(component.grp);
|
var similarSlot = this.findInternalByGroup(component.grp);
|
||||||
// If another slot has an installed component with of the same type
|
// If another slot has an installed component with of the same type
|
||||||
if (similarSlot && similarSlot !== slot) {
|
if (!preventUpdate && similarSlot && similarSlot !== slot) {
|
||||||
this.updateStats(similarSlot, null, similarSlot.c, true); // Update stats but don't trigger a global update
|
this.updateStats(similarSlot, null, similarSlot.c, true); // Update stats but don't trigger a global update
|
||||||
similarSlot.id = similarSlot.c = null; // Empty the slot
|
similarSlot.id = similarSlot.c = null; // Empty the slot
|
||||||
|
similarSlot.discountedCost = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var oldComponent = slot.c;
|
var oldComponent = slot.c;
|
||||||
slot.id = id;
|
slot.id = id;
|
||||||
slot.c = component;
|
slot.c = component;
|
||||||
|
slot.discountedCost = (component && component.cost) ? component.cost * this.componentDiscount : 0;
|
||||||
this.updateStats(slot, component, oldComponent, preventUpdate);
|
this.updateStats(slot, component, oldComponent, preventUpdate);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -232,17 +242,27 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
|
|
||||||
Ship.prototype.setCostIncluded = function(item, included) {
|
Ship.prototype.setCostIncluded = function(item, included) {
|
||||||
if (item.incCost != included && item.c) {
|
if (item.incCost != included && item.c) {
|
||||||
this.totalCost += included ? item.c.cost : -item.c.cost;
|
this.totalCost += included ? item.discountedCost : -item.discountedCost;
|
||||||
}
|
}
|
||||||
item.incCost = included;
|
item.incCost = included;
|
||||||
};
|
};
|
||||||
|
|
||||||
Ship.prototype.setSlotEnabled = function(slot, enabled) {
|
Ship.prototype.setSlotEnabled = function(slot, enabled) {
|
||||||
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
|
if (slot.enabled != enabled) { // Enabled state is changing
|
||||||
this.priorityBands[slot.priority][powerUsageType(slot, slot.c)] += enabled ? slot.c.power : -slot.c.power;
|
slot.enabled = enabled;
|
||||||
this.updatePower();
|
if (slot.c) {
|
||||||
|
this.priorityBands[slot.priority][powerUsageType(slot, slot.c)] += enabled ? slot.c.power : -slot.c.power;
|
||||||
|
|
||||||
|
if (slot.c.grp == 'sg') {
|
||||||
|
this.updateShieldStrength();
|
||||||
|
} else if (slot.c.grp == 'sb') {
|
||||||
|
this.shieldMultiplier += slot.c.shieldmul * (enabled ? 1 : -1);
|
||||||
|
this.updateShieldStrength();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updatePower();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
slot.enabled = enabled;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ship.prototype.getSlotStatus = function(slot, deployed) {
|
Ship.prototype.getSlotStatus = function(slot, deployed) {
|
||||||
@@ -277,12 +297,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
this.armourAdded -= old.armouradd;
|
this.armourAdded -= old.armouradd;
|
||||||
break;
|
break;
|
||||||
case 'sb':
|
case 'sb':
|
||||||
this.shieldMultiplier -= old.shieldmul;
|
this.shieldMultiplier -= slot.enabled ? old.shieldmul : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot.incCost && old.cost) {
|
if (slot.incCost && old.cost) {
|
||||||
this.totalCost -= old.cost;
|
this.totalCost -= old.cost * this.componentDiscount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old.power && slot.enabled) {
|
if (old.power && slot.enabled) {
|
||||||
@@ -307,12 +327,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
this.armourAdded += n.armouradd;
|
this.armourAdded += n.armouradd;
|
||||||
break;
|
break;
|
||||||
case 'sb':
|
case 'sb':
|
||||||
this.shieldMultiplier += n.shieldmul;
|
this.shieldMultiplier += slot.enabled ? n.shieldmul : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot.incCost && n.cost) {
|
if (slot.incCost && n.cost) {
|
||||||
this.totalCost += n.cost;
|
this.totalCost += n.cost * this.componentDiscount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n.power && slot.enabled) {
|
if (n.power && slot.enabled) {
|
||||||
@@ -351,31 +371,43 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
|
|
||||||
Ship.prototype.updateShieldStrength = function() {
|
Ship.prototype.updateShieldStrength = function() {
|
||||||
var sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
|
var sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
|
||||||
this.shieldStrength = sgSlot ? calcShieldStrength(this.mass, this.shields, sgSlot.c, this.shieldMultiplier) : 0;
|
this.shieldStrength = sgSlot && sgSlot.enabled ? calcShieldStrength(this.mass, this.shields, sgSlot.c, this.shieldMultiplier) : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Jump Range and total range calculations
|
* Jump Range and total range calculations
|
||||||
*/
|
*/
|
||||||
Ship.prototype.updateJumpStats = function() {
|
Ship.prototype.updateJumpStats = function() {
|
||||||
var fsd = this.common[2].c; // Frame Shift Drive;
|
var fsd = this.common[2].c; // Frame Shift Drive;
|
||||||
var fuelRemaining = this.fuelCapacity % fsd.maxfuel; // Fuel left after making N max jumps
|
|
||||||
var jumps = this.fuelCapacity / fsd.maxfuel;
|
|
||||||
this.unladenRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd, this.fuelCapacity); // Include fuel weight for jump
|
this.unladenRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd, this.fuelCapacity); // Include fuel weight for jump
|
||||||
this.fullTankRange = calcJumpRange(this.unladenMass + this.fuelCapacity, fsd, this.fuelCapacity); // Full Tanke
|
this.fullTankRange = calcJumpRange(this.unladenMass + this.fuelCapacity, fsd, this.fuelCapacity); // Full Tanke
|
||||||
this.ladenRange = calcJumpRange(this.ladenMass, fsd, this.fuelCapacity);
|
this.ladenRange = calcJumpRange(this.ladenMass, fsd, this.fuelCapacity);
|
||||||
this.maxJumpCount = Math.ceil(jumps); // Number of full fuel jumps + final jump to empty tank
|
this.unladenTotalRange = calcTotalRange(this.unladenMass, fsd, this.fuelCapacity);
|
||||||
|
this.ladenTotalRange = calcTotalRange(this.unladenMass + this.cargoCapacity, fsd, this.fuelCapacity);
|
||||||
|
this.maxJumpCount = Math.ceil(this.fuelCapacity / fsd.maxfuel);
|
||||||
|
};
|
||||||
|
|
||||||
// Going backwards, start with the last jump using the remaining fuel
|
/**
|
||||||
this.unladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + fuelRemaining, fsd, fuelRemaining) : 0;
|
* Recalculate all item costs and total based on discounts.
|
||||||
this.ladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining) : 0;
|
* @param {number} shipDiscount Ship cost multiplier discount (e.g. 0.9 === 10% discount)
|
||||||
|
* @param {number} componentDiscount Component cost multiplier discount (e.g. 0.75 === 25% discount)
|
||||||
|
*/
|
||||||
|
Ship.prototype.applyDiscounts = function(shipDiscount, componentDiscount) {
|
||||||
|
var total = 0;
|
||||||
|
var costList = this.costList;
|
||||||
|
|
||||||
// For each max fuel jump, calculate the max jump range based on fuel left in the tank
|
for (var i = 0, l = costList.length; i < l; i++) {
|
||||||
for (var j = 0, l = Math.floor(jumps); j < l; j++) {
|
var item = costList[i];
|
||||||
fuelRemaining += fsd.maxfuel;
|
if (item.c && item.c.cost) {
|
||||||
this.unladenTotalRange += calcJumpRange(this.unladenMass + fuelRemaining, fsd);
|
item.discountedCost = item.c.cost * (item.type == 'SHIP' ? shipDiscount : componentDiscount);
|
||||||
this.ladenTotalRange += calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd);
|
if (item.incCost) {
|
||||||
|
total += item.discountedCost;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.shipDiscount = shipDiscount;
|
||||||
|
this.componentDiscount = componentDiscount;
|
||||||
|
this.totalCost = total;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ship;
|
return Ship;
|
||||||
|
|||||||
@@ -165,6 +165,19 @@ angular.module('shipyard', ['ngLodash'])
|
|||||||
fmt: 'fRound'
|
fmt: 'fRound'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
/**
|
||||||
|
* Set of all available / theoretical discounts
|
||||||
|
*
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
.value('Discounts', {
|
||||||
|
'None': 1,
|
||||||
|
'5%': 0.95,
|
||||||
|
'10%': 0.90,
|
||||||
|
'15%': 0.85,
|
||||||
|
'20%': 0.80,
|
||||||
|
'25%': 0.75
|
||||||
|
})
|
||||||
/**
|
/**
|
||||||
* Calculate the maximum single jump range based on mass and a specific FSD
|
* Calculate the maximum single jump range based on mass and a specific FSD
|
||||||
*
|
*
|
||||||
@@ -175,6 +188,27 @@ angular.module('shipyard', ['ngLodash'])
|
|||||||
*/
|
*/
|
||||||
.value('calcJumpRange', function(mass, fsd, fuel) {
|
.value('calcJumpRange', function(mass, fsd, fuel) {
|
||||||
return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Calculate the total range based on mass and a specific FSD, and all fuel available
|
||||||
|
*
|
||||||
|
* @param {number} mass Mass of a ship: laden, unlanden, partially laden, etc
|
||||||
|
* @param {object} fsd The FDS object/component with maxfuel, fuelmul, fuelpower, optmass
|
||||||
|
* @param {number} fuel The total fuel available
|
||||||
|
* @return {number} Distance in Light Years
|
||||||
|
*/
|
||||||
|
.value('calcTotalRange', function(mass, fsd, fuel) {
|
||||||
|
var fuelRemaining = fuel % fsd.maxfuel; // Fuel left after making N max jumps
|
||||||
|
var jumps = 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;
|
||||||
|
totalRange += Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||||
|
}
|
||||||
|
return totalRange;
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.
|
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.
|
||||||
@@ -187,9 +221,6 @@ angular.module('shipyard', ['ngLodash'])
|
|||||||
* @return {number} Approximate shield strengh in MJ
|
* @return {number} Approximate shield strengh in MJ
|
||||||
*/
|
*/
|
||||||
.value('calcShieldStrength', function(mass, shields, sg, multiplier) {
|
.value('calcShieldStrength', function(mass, shields, sg, multiplier) {
|
||||||
if (!sg) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (mass <= sg.minmass) {
|
if (mass <= sg.minmass) {
|
||||||
return shields * multiplier * sg.minmul;
|
return shields * multiplier * sg.minmul;
|
||||||
}
|
}
|
||||||
@@ -200,4 +231,20 @@ angular.module('shipyard', ['ngLodash'])
|
|||||||
return shields * multiplier * (sg.optmul + (mass - sg.optmass) / (sg.maxmass - sg.optmass) * (sg.maxmul - sg.optmul));
|
return shields * multiplier * (sg.optmul + (mass - sg.optmass) / (sg.maxmass - sg.optmass) * (sg.maxmul - sg.optmul));
|
||||||
}
|
}
|
||||||
return shields * multiplier * sg.maxmul;
|
return shields * multiplier * sg.maxmul;
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Calculate the a ships speed based on mass, and thrusters. Currently Innacurate / Incomplete :(
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @param {number} mass Current mass of the ship
|
||||||
|
* @param {number} baseSpeed Base speed m/s for ship
|
||||||
|
* @param {number} baseBoost Base boost m/s for ship
|
||||||
|
* @param {object} thrusters The shield generator used
|
||||||
|
* @return {object} Approximate speed and boost speed in m/s
|
||||||
|
*/
|
||||||
|
.value('calcSpeed', function(mass, baseSpeed, baseBoost) { //, thrusters) {
|
||||||
|
//var speed = baseSpeed * (1 + ((thrusters.optmass / mass) * 0.1 ) ); // TODO: find thruser coefficient(s)
|
||||||
|
//var boost = baseBoost * (1 + ((thrusters.optmass / mass) * 0.1 ) );
|
||||||
|
|
||||||
|
return { boost: baseSpeed, speed: baseBoost };
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
|
|
||||||
.chart {
|
.chart {
|
||||||
.user-select-none();
|
.user-select-none();
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|
||||||
width: 33%;
|
width: 33%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
@@ -23,6 +21,7 @@
|
|||||||
&[ng-click] {
|
&[ng-click] {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,5 +62,3 @@ svg {
|
|||||||
stroke-width: 1px;
|
stroke-width: 1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.smallTablet({
|
.smallTablet({
|
||||||
|
position: static;
|
||||||
position: initial;
|
position: initial;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,11 +139,6 @@ table.total {
|
|||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
tbody tr:hover {
|
|
||||||
background-color: @warning-bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.smallTablet({
|
.smallTablet({
|
||||||
width: 50%;
|
width: 50%;
|
||||||
});
|
});
|
||||||
@@ -152,7 +147,7 @@ table.total {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
});
|
});
|
||||||
|
|
||||||
&.dbl {
|
&.half {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
|
|
||||||
.tablet({
|
.tablet({
|
||||||
@@ -162,8 +157,22 @@ table.total {
|
|||||||
});
|
});
|
||||||
|
|
||||||
.smallTablet({
|
.smallTablet({
|
||||||
overflow-x: auto;
|
width: 100% !important;
|
||||||
-webkit-overflow-scrolling: touch;
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
&.third {
|
||||||
|
width: 33%;
|
||||||
|
|
||||||
|
.smallTablet({
|
||||||
|
.axis.x {
|
||||||
|
g.tick:nth-child(2n + 1) text {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
.largePhone({
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -177,7 +186,7 @@ table.total {
|
|||||||
|
|
||||||
#componentPriority {
|
#componentPriority {
|
||||||
.tablet({
|
.tablet({
|
||||||
text.primary, text.warning, text.primary-bg {
|
text.primary, text.warning, text.primary-bg, text.secondary {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
border-right: 1px solid @primary-disabled;
|
border-right: 1px solid @primary-disabled;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-top: 0.2em;
|
padding-top: 0.2em;
|
||||||
|
padding-left: 0.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.empty {
|
.empty {
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ thead {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
tbody tr {
|
tbody tr {
|
||||||
|
|
||||||
&.tr {
|
&.tr {
|
||||||
@@ -55,6 +54,12 @@ tbody tr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.highlight {
|
||||||
|
&:hover {
|
||||||
|
background-color: @warning-bg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
line-height: 1.4em;
|
line-height: 1.4em;
|
||||||
padding: 0 0.3em;
|
padding: 0 0.3em;
|
||||||
|
|||||||
@@ -53,8 +53,12 @@
|
|||||||
<li><select ng-model="insurance.current" ng-options="ins.name for (i,ins) in insurance.opts" ng-change="updateInsurance()"></select></li>
|
<li><select ng-model="insurance.current" ng-options="ins.name for (i,ins) in insurance.opts" ng-change="updateInsurance()"></select></li>
|
||||||
</ul><br>
|
</ul><br>
|
||||||
<ul>
|
<ul>
|
||||||
Discount
|
Ship Discount
|
||||||
<li><select ng-model="discounts.current" ng-options="d.name for (i,d) in discounts.opts" ng-change="updateDiscount()"></select></li>
|
<li><select ng-model="discounts.ship" ng-options="i for (i,d) in discounts.opts" ng-change="updateDiscount()"></select></li>
|
||||||
|
</ul><br>
|
||||||
|
<ul>
|
||||||
|
Component Discount
|
||||||
|
<li><select ng-model="discounts.components" ng-options="i for (i,d) in discounts.opts" ng-change="updateDiscount()"></select></li>
|
||||||
</ul>
|
</ul>
|
||||||
<hr />
|
<hr />
|
||||||
<ul>
|
<ul>
|
||||||
|
|||||||
@@ -16,6 +16,9 @@
|
|||||||
<button ui-sref="outfit({shipId: ship.id,code:null, bn: buildName})" ng-disabled="!code">
|
<button ui-sref="outfit({shipId: ship.id,code:null, bn: buildName})" ng-disabled="!code">
|
||||||
<svg class="icon lg"><use xlink:href="#switch"></use></svg><span class="button-lbl">Reset</span>
|
<svg class="icon lg"><use xlink:href="#switch"></use></svg><span class="button-lbl">Reset</span>
|
||||||
</button>
|
</button>
|
||||||
|
<button ng-click="stripBuild()">
|
||||||
|
<svg class="icon lg"><use xlink:href="#feather"></use></svg><span class="button-lbl">Low-Weight</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -53,7 +56,7 @@
|
|||||||
<td>{{fRound(ship.speed)}} <u>m/s</u></td>
|
<td>{{fRound(ship.speed)}} <u>m/s</u></td>
|
||||||
<td>{{fRound(ship.boost)}} <u>m/s</u></td>
|
<td>{{fRound(ship.boost)}} <u>m/s</u></td>
|
||||||
<td>{{ship.armourTotal}} <span ng-if="ship.armourAdded">({{ship.armour}} + {{ship.armourAdded}})</span></td>
|
<td>{{ship.armourTotal}} <span ng-if="ship.armourAdded">({{ship.armour}} + {{ship.armourAdded}})</span></td>
|
||||||
<td>{{fRound(ship.shieldStrength)}} <u>MJ</u> <span ng-if="ship.shieldMultiplier > 1">({{fRPct(ship.shieldMultiplier)}})</span></td>
|
<td>{{fRound(ship.shieldStrength)}} <u>MJ</u> <span ng-if="ship.shieldMultiplier > 1 && ship.shieldStrength > 0">({{fRPct(ship.shieldMultiplier)}})</span></td>
|
||||||
<td>{{fRound(ship.unladenMass)}} <u>T</u></td>
|
<td>{{fRound(ship.unladenMass)}} <u>T</u></td>
|
||||||
<td>{{fRound(ship.ladenMass)}} <u>T</u></td>
|
<td>{{fRound(ship.ladenMass)}} <u>T</u></td>
|
||||||
<td>{{fRound(ship.cargoCapacity)}} <u>T</u></td>
|
<td>{{fRound(ship.cargoCapacity)}} <u>T</u></td>
|
||||||
@@ -193,7 +196,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group dbl" id="componentPriority">
|
<div class="group half" id="componentPriority">
|
||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="main">
|
<tr class="main">
|
||||||
@@ -207,7 +210,7 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td ng-click="togglePwr(c)">{{pp.c.class}}{{pp.c.rating}}</td>
|
<td>{{pp.c.class}}{{pp.c.rating}}</td>
|
||||||
<td class="le shorten">Power Plant</td>
|
<td class="le shorten">Power Plant</td>
|
||||||
<td><u>SYS</u></td>
|
<td><u>SYS</u></td>
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
@@ -217,7 +220,7 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td style="line-height:0;" colspan="8"><hr style="margin: 0 0 3px;background: #ff8c0d;border: 0;height: 1px;" /></td></tr>
|
<tr><td style="line-height:0;" colspan="8"><hr style="margin: 0 0 3px;background: #ff8c0d;border: 0;height: 1px;" /></td></tr>
|
||||||
<tr ng-repeat="c in powerList | orderBy:pwrPredicate:pwrDesc" ng-if="c.c.power" ng-class="{disabled:!c.enabled}">
|
<tr class="highlight" ng-repeat="c in powerList | orderBy:pwrPredicate:pwrDesc" ng-if="c.c.power" ng-class="{disabled:!c.enabled}">
|
||||||
<td style="width:1em;" ng-click="togglePwr(c)">{{c.c.class}}{{c.c.rating}}</td>
|
<td style="width:1em;" ng-click="togglePwr(c)">{{c.c.class}}{{c.c.rating}}</td>
|
||||||
<td class="le shorten" ng-click="togglePwr(c)" ng-bind="cName(c)"></td>
|
<td class="le shorten" ng-click="togglePwr(c)" ng-bind="cName(c)"></td>
|
||||||
<td ng-click="togglePwr(c)"><u ng-bind="c.type"></u></td>
|
<td ng-click="togglePwr(c)"><u ng-bind="c.type"></u></td>
|
||||||
@@ -233,41 +236,60 @@
|
|||||||
<div style="margin-top: 1em" power-bands bands="priorityBands" available="ship.powerAvailable"></div>
|
<div style="margin-top: 1em" power-bands bands="priorityBands" available="ship.powerAvailable"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group dbl">
|
<div class="group half">
|
||||||
<table style="width:100%">
|
<table style="width:100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="main">
|
<tr class="main">
|
||||||
<th colspan="2" class="sortable le" ng-click="sortCost(cName)">Component</th>
|
<th colspan="2" class="sortable le" ng-click="sortCost(cName)">
|
||||||
<th class="sortable le" ng-click="sortCost('c.cost')">Credits</th>
|
Component
|
||||||
|
<div class="r">
|
||||||
|
<u ng-if="discounts.ship < 1">[Ship {{fRPct(1 - discounts.ship)}} off]</u>
|
||||||
|
<u ng-if="discounts.components < 1">[Components {{fRPct(1 - discounts.components)}} off]</u>
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
<th class="sortable le" ng-click="sortCost('discountedCost')">Credits</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="c in costList | orderBy:costPredicate:costDesc" ng-if="c.c.cost > 0" ng-class="{disabled:!c.incCost}">
|
<tr class="highlight" ng-repeat="item in costList | orderBy:costPredicate:costDesc" ng-if="item.c.cost > 0" ng-class="{disabled:!item.incCost}">
|
||||||
<td class="toggleable" style="width:1em;" ng-click="toggleCost(c)">{{c.c.class}}{{c.c.rating}}</td>
|
<td class="toggleable" style="width:1em;" ng-click="toggleCost(item)">{{item.c.class}}{{item.c.rating}}</td>
|
||||||
<td class="le toggleable shorten" ng-bind="cName(c)" ng-click="toggleCost(c)"></td>
|
<td class="le toggleable shorten" ng-click="toggleCost(item)">{{cName(item)}}</td>
|
||||||
<td class="ri toggleable" ng-click="toggleCost(c)">{{fCrd(discounts.current.pct * c.c.cost)}} <u>CR</u></td>
|
<td class="ri toggleable" ng-click="toggleCost(item)">{{fCrd(item.discountedCost)}} <u>CR</u></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<table class="total">
|
<table class="total">
|
||||||
<tr class="ri">
|
<tr class="ri">
|
||||||
<td class="lbl">Total</td>
|
<td class="lbl">Total</td>
|
||||||
<td>{{fCrd(ship.totalCost * discounts.current.pct)}} <u>CR</u></td>
|
<td>{{fCrd(ship.totalCost)}} <u>CR</u></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="ri">
|
<tr class="ri">
|
||||||
<td class="lbl">Insurance</td>
|
<td class="lbl">Insurance</td>
|
||||||
<td>{{fCrd(ship.totalCost * discounts.current.pct * insurance.current.pct)}} <u>CR</u></td>
|
<td>{{fCrd(ship.totalCost * insurance.current.pct)}} <u>CR</u></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="group dbl">
|
<div class="group half">
|
||||||
<h1>Jump Range</h1>
|
<h1>Jump Range</h1>
|
||||||
<div class="cen">
|
<div line-chart config="jrChart" series="jrSeries"></div>
|
||||||
<div area-chart config="jrChart" series="jrSeries"></div>
|
</div>
|
||||||
<div slider max="ship.fuelCapacity" unit="'T'" on-change="::fuelChange(val)" style="position:relative; margin: 0 auto;">
|
|
||||||
|
<div class="group half">
|
||||||
|
<h1>Total Range</h1>
|
||||||
|
<div line-chart config="trChart" series="trSeries"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- TODO: Add back in once calcSpeed is dynamic and accurate
|
||||||
|
<div class="group third">
|
||||||
|
<h1>Thruster Speed</h1>
|
||||||
|
<div line-chart config="speedChart" series="speedSeries"></div>
|
||||||
|
</div>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<div class="group half">
|
||||||
|
<div slider max="ship.fuelCapacity" unit="'T'" on-change="::fuelChange(val)" style="position:relative; margin: 0 auto;">
|
||||||
<svg class="icon xl primary-disabled" style="position:absolute;height: 100%;"><use xlink:href="#fuel"></use></svg>
|
<svg class="icon xl primary-disabled" style="position:absolute;height: 100%;"><use xlink:href="#fuel"></use></svg>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -123,28 +123,28 @@
|
|||||||
"class": 1,
|
"class": 1,
|
||||||
"rating": "I",
|
"rating": "I",
|
||||||
"cost": 1017200,
|
"cost": 1017200,
|
||||||
"mass": 21
|
"mass": 4
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Military Grade Composite",
|
"name": "Military Grade Composite",
|
||||||
"class": 1,
|
"class": 1,
|
||||||
"rating": "I",
|
"rating": "I",
|
||||||
"cost": 2288600,
|
"cost": 2288600,
|
||||||
"mass": 42
|
"mass": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Mirrored Surface Composite",
|
"name": "Mirrored Surface Composite",
|
||||||
"class": 1,
|
"class": 1,
|
||||||
"rating": "I",
|
"rating": "I",
|
||||||
"cost": 5408800,
|
"cost": 5408800,
|
||||||
"mass": 42
|
"mass": 8
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Reactive Surface Composite",
|
"name": "Reactive Surface Composite",
|
||||||
"class": 1,
|
"class": 1,
|
||||||
"rating": "I",
|
"rating": "I",
|
||||||
"cost": 5993700,
|
"cost": 5993700,
|
||||||
"mass": 42
|
"mass": 8
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"cobra_mk_iii": [
|
"cobra_mk_iii": [
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 320,
|
"boost": 320,
|
||||||
"agility": 8,
|
"agility": 8,
|
||||||
"shields": 60,
|
"shields": 60,
|
||||||
"armour": 90,
|
"armour": 162,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 35
|
"mass": 35
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 240,
|
"boost": 240,
|
||||||
"agility": 2,
|
"agility": 2,
|
||||||
"shields": 350,
|
"shields": 350,
|
||||||
"armour": 525,
|
"armour": 945,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 400
|
"mass": 400
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 340,
|
"boost": 340,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 140,
|
"shields": 140,
|
||||||
"armour": 210,
|
"armour": 378,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 280
|
"mass": 280
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 400,
|
"boost": 400,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 80,
|
"shields": 80,
|
||||||
"armour": 120,
|
"armour": 216,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 180
|
"mass": 180
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 350,
|
"boost": 350,
|
||||||
"agility": 10,
|
"agility": 10,
|
||||||
"shields": 60,
|
"shields": 60,
|
||||||
"armour": 40,
|
"armour": 72,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 50
|
"mass": 50
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 300,
|
"boost": 300,
|
||||||
"agility": 0,
|
"agility": 0,
|
||||||
"shields": 200,
|
"shields": 200,
|
||||||
"armour": 300,
|
"armour": 540,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 580
|
"mass": 580
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 350,
|
"boost": 350,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 300,
|
"shields": 300,
|
||||||
"armour": 225,
|
"armour": 405,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 250
|
"mass": 250
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 300,
|
"boost": 300,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 50,
|
"shields": 50,
|
||||||
"armour": 50,
|
"armour": 90,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 14
|
"mass": 14
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 380,
|
"boost": 380,
|
||||||
"agility": 2,
|
"agility": 2,
|
||||||
"shields": 180,
|
"shields": 180,
|
||||||
"armour": 270,
|
"armour": 486,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 400
|
"mass": 400
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 380,
|
"boost": 380,
|
||||||
"agility": 2,
|
"agility": 2,
|
||||||
"shields": 220,
|
"shields": 220,
|
||||||
"armour": 220,
|
"armour": 396,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 580
|
"mass": 580
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 280,
|
"boost": 280,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 260,
|
"shields": 260,
|
||||||
"armour": 260,
|
"armour": 468,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 350
|
"mass": 350
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 320,
|
"boost": 320,
|
||||||
"agility": 8,
|
"agility": 8,
|
||||||
"shields": 40,
|
"shields": 40,
|
||||||
"armour": 60,
|
"armour": 108,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 25
|
"mass": 25
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 350,
|
"boost": 350,
|
||||||
"agility": 3,
|
"agility": 3,
|
||||||
"shields": 90,
|
"shields": 90,
|
||||||
"armour": 90,
|
"armour": 162,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 155
|
"mass": 155
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 300,
|
"boost": 300,
|
||||||
"agility": 2,
|
"agility": 2,
|
||||||
"shields": 120,
|
"shields": 120,
|
||||||
"armour": 120,
|
"armour": 216,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 420
|
"mass": 420
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 200,
|
"boost": 200,
|
||||||
"agility": 0,
|
"agility": 0,
|
||||||
"shields": 240,
|
"shields": 240,
|
||||||
"armour": 240,
|
"armour": 432,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 1000
|
"mass": 1000
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 400,
|
"boost": 400,
|
||||||
"agility": 6,
|
"agility": 6,
|
||||||
"shields": 105,
|
"shields": 105,
|
||||||
"armour": 70,
|
"armour": 126,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 60
|
"mass": 60
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"boost": 340,
|
"boost": 340,
|
||||||
"agility": 9,
|
"agility": 9,
|
||||||
"shields": 240,
|
"shields": 240,
|
||||||
"armour": 160,
|
"armour": 288,
|
||||||
"fuelcost": 50,
|
"fuelcost": 50,
|
||||||
"mass": 230
|
"mass": 230
|
||||||
},
|
},
|
||||||
|
|||||||
56
package.json
56
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "coriolis_shipyard",
|
"name": "coriolis_shipyard",
|
||||||
"version": "0.12.1",
|
"version": "0.14.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/cmmcleod/coriolis"
|
"url": "https://github.com/cmmcleod/coriolis"
|
||||||
@@ -9,33 +9,35 @@
|
|||||||
"engine": "node >= 0.12.2",
|
"engine": "node >= 0.12.2",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"angular-mocks": "^1.3.16",
|
"angular-mocks": "1.3.x",
|
||||||
"async": "^0.9.0",
|
"async": "0.9.x",
|
||||||
"del": "^1.1.1",
|
"del": "1.2.x",
|
||||||
"gulp": "^3.8.11",
|
"gulp": "3.9.x",
|
||||||
"gulp-angular-templatecache": "^1.6.0",
|
"gulp-angular-templatecache": "1.6.x",
|
||||||
"gulp-concat": "^2.5.2",
|
"gulp-concat": "2.5.x",
|
||||||
"gulp-eslint": "^0.13.2",
|
"gulp-eslint": "0.13.x",
|
||||||
"gulp-htmlmin": "^1.1.1",
|
"gulp-htmlmin": "1.1.x",
|
||||||
"gulp-jasmine": "^2.0.1",
|
"gulp-jasmine": "2.0.x",
|
||||||
"gulp-jsonlint": "^1.0.2",
|
"gulp-jsonlint": "1.1.x",
|
||||||
"gulp-less": "^3.0.2",
|
"gulp-less": "3.0.x",
|
||||||
"gulp-manifest": "0.0.6",
|
"gulp-manifest": "0.0.6",
|
||||||
"gulp-minify-css": "^1.0.0",
|
"gulp-minify-css": "1.1.x",
|
||||||
"gulp-rev-all": "0.8.18",
|
"gulp-rev-all": "0.8.18",
|
||||||
"gulp-sourcemaps": "^1.5.1",
|
"gulp-sourcemaps": "1.5.x",
|
||||||
"gulp-svgmin": "^1.1.2",
|
"gulp-svgmin": "1.1.x",
|
||||||
"gulp-svgstore": "^5.0.1",
|
"gulp-svgstore": "5.0.x",
|
||||||
"gulp-template": "^3.0.0",
|
"gulp-template": "3.0.x",
|
||||||
"gulp-uglify": "^1.2.0",
|
"gulp-uglify": "1.2.x",
|
||||||
"gulp-util": "^3.0.4",
|
"gulp-util": "3.0.x",
|
||||||
"jasmine-core": "^2.3.4",
|
"jasmine-core": "2.3.x",
|
||||||
"json-concat": "0.0.0",
|
"json-concat": "0.0.x",
|
||||||
"karma": "^0.12.36",
|
"karma": "0.12.x",
|
||||||
"karma-chrome-launcher": "^0.1.12",
|
"karma-jasmine": "0.3.x",
|
||||||
"karma-jasmine": "^0.3.5",
|
"karma-mocha-reporter": "1.0.x",
|
||||||
"main-bower-files": "^2.6.2",
|
"karma-phantomjs-launcher": "0.2.x",
|
||||||
"run-sequence": "^1.0.2",
|
"main-bower-files": "2.8.x",
|
||||||
"uglify-js": "^2.4.19"
|
"phantomjs": "1.9.x",
|
||||||
|
"run-sequence": "1.1.x",
|
||||||
|
"uglify-js": "2.4.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,21 +14,13 @@ module.exports = function(config) {
|
|||||||
'../build/app*.js',
|
'../build/app*.js',
|
||||||
'tests/**/*.js'
|
'tests/**/*.js'
|
||||||
],
|
],
|
||||||
// list of files to exclude
|
reporters: ['mocha'],
|
||||||
exclude: [],
|
|
||||||
// preprocess matching files before serving them to the browser
|
|
||||||
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
|
|
||||||
preprocessors: {},
|
|
||||||
// test results reporter to use
|
|
||||||
// possible values: 'dots', 'progress'
|
|
||||||
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
|
|
||||||
reporters: ['progress'],
|
|
||||||
port: 9876,
|
port: 9876,
|
||||||
colors: true,
|
colors: true,
|
||||||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
|
||||||
logLevel: config.LOG_INFO,
|
logLevel: config.LOG_INFO,
|
||||||
autoWatch: false,
|
autoWatch: false,
|
||||||
browsers: ['Chrome'],
|
browsers: ['PhantomJS'],
|
||||||
singleRun: false
|
singleRun: false
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
describe("Ship Factory", function() {
|
describe("Ship Factory", function() {
|
||||||
|
|
||||||
var Ship;
|
var Ship;
|
||||||
|
var Components;
|
||||||
|
|
||||||
beforeEach(module('shipyard'));
|
beforeEach(module('shipyard'));
|
||||||
beforeEach(inject(['Ship', function (_Ship_) {
|
beforeEach(inject(['Ship', 'Components', function (_Ship_, _Components_) {
|
||||||
Ship = _Ship_;
|
Ship = _Ship_;
|
||||||
|
Components = _Components_;
|
||||||
}]));
|
}]));
|
||||||
|
|
||||||
it("can build all ships", function() {
|
it("can build all ships", function() {
|
||||||
@@ -32,39 +34,120 @@ describe("Ship Factory", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("resets and rebuilds properly", function() {
|
it("resets and rebuilds properly", function() {
|
||||||
var id = 'cobra_mk_iii';
|
var id = 'cobra_mk_iii';
|
||||||
var cobra = DB.ships[id];
|
var cobra = DB.ships[id];
|
||||||
var shipA = new Ship(id, cobra.properties, cobra.slots);
|
var shipA = new Ship(id, cobra.properties, cobra.slots);
|
||||||
var shipB = new Ship(id, cobra.properties, cobra.slots);
|
var shipB = new Ship(id, cobra.properties, cobra.slots);
|
||||||
var testShip = new Ship(id, cobra.properties, cobra.slots);
|
var testShip = new Ship(id, cobra.properties, cobra.slots);
|
||||||
|
|
||||||
var buildA = cobra.defaults;
|
var buildA = cobra.defaults;
|
||||||
var buildB = {
|
var buildB = {
|
||||||
common:['4A', '4A', '4A', '3D', '3A', '3A', '4C'],
|
common:['4A', '4A', '4A', '3D', '3A', '3A', '4C'],
|
||||||
hardpoints: ['0s', '0s', '2d', '2d', 0, '04'],
|
hardpoints: ['0s', '0s', '2d', '2d', 0, '04'],
|
||||||
internal: ['45', '03', '2b', '2o', '27', '53']
|
internal: ['45', '03', '2b', '2o', '27', '53']
|
||||||
};
|
};
|
||||||
|
|
||||||
shipA.buildWith(buildA); // Build A
|
shipA.buildWith(buildA); // Build A
|
||||||
shipB.buildWith(buildB);// Build B
|
shipB.buildWith(buildB);// Build B
|
||||||
testShip.buildWith(buildA);
|
testShip.buildWith(buildA);
|
||||||
|
|
||||||
for(var p in testShip) {
|
for(var p in testShip) {
|
||||||
expect(testShip[p]).toEqual(shipA[p], p + ' does not match');
|
expect(testShip[p]).toEqual(shipA[p], p + ' does not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
testShip.buildWith(buildB);
|
testShip.buildWith(buildB);
|
||||||
|
|
||||||
for(var p in testShip) {
|
for(var p in testShip) {
|
||||||
expect(testShip[p]).toEqual(shipB[p], p + ' does not match');
|
expect(testShip[p]).toEqual(shipB[p], p + ' does not match');
|
||||||
}
|
}
|
||||||
|
|
||||||
testShip.buildWith(buildA);
|
testShip.buildWith(buildA);
|
||||||
|
|
||||||
for(var p in testShip) {
|
for(var p in testShip) {
|
||||||
expect(testShip[p]).toEqual(shipA[p], p + ' does not match');
|
expect(testShip[p]).toEqual(shipA[p], p + ' does not match');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("discounts hull and components properly", function() {
|
||||||
|
var id = 'cobra_mk_iii';
|
||||||
|
var cobra = DB.ships[id];
|
||||||
|
var testShip = new Ship(id, cobra.properties, cobra.slots);
|
||||||
|
testShip.buildWith(cobra.defaults);
|
||||||
|
|
||||||
|
var originalHullCost = testShip.cost;
|
||||||
|
var originalTotalCost = testShip.totalCost;
|
||||||
|
var discount = 0.9;
|
||||||
|
|
||||||
|
expect(testShip.c.discountedCost).toEqual(originalHullCost, 'Hull cost does not match');
|
||||||
|
|
||||||
|
testShip.applyDiscounts(discount, discount);
|
||||||
|
|
||||||
|
// Floating point errors cause miniscule decimal places which are handled in the app by rounding/formatting
|
||||||
|
|
||||||
|
expect(Math.floor(testShip.c.discountedCost)).toEqual(Math.floor(originalHullCost * discount), 'Discounted Hull cost does not match');
|
||||||
|
expect(Math.floor(testShip.totalCost)).toEqual(Math.floor(originalTotalCost * discount), 'Discounted Total cost does not match');
|
||||||
|
|
||||||
|
testShip.applyDiscounts(1, 1); // No discount, 100% of cost
|
||||||
|
|
||||||
|
expect(testShip.c.discountedCost).toEqual(originalHullCost, 'Hull cost does not match');
|
||||||
|
expect(testShip.totalCost).toEqual(originalTotalCost, 'Total cost does not match');
|
||||||
|
|
||||||
|
testShip.applyDiscounts(discount, 1); // Only discount hull
|
||||||
|
|
||||||
|
expect(Math.floor(testShip.c.discountedCost)).toEqual(Math.round(originalHullCost * discount), 'Discounted Hull cost does not match');
|
||||||
|
expect(testShip.totalCost).toEqual(originalTotalCost - originalHullCost + testShip.c.discountedCost, 'Total cost does not match');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
it("enforces a single shield generator", function() {
|
||||||
|
var id = 'anaconda';
|
||||||
|
var anacondaData = DB.ships[id];
|
||||||
|
var anaconda = new Ship(id, anacondaData.properties, anacondaData.slots);
|
||||||
|
anaconda.buildWith(anacondaData.defaults);
|
||||||
|
|
||||||
|
expect(anaconda.internal[2].c.grp).toEqual('sg', 'Anaconda default shield generator slot');
|
||||||
|
|
||||||
|
anaconda.use(anaconda.internal[1], '4j', Components.internal('4j')); // 6E Shield Generator
|
||||||
|
|
||||||
|
expect(anaconda.internal[2].c).toEqual(null, 'Anaconda default shield generator slot is empty');
|
||||||
|
expect(anaconda.internal[2].id).toEqual(null, 'Anaconda default shield generator slot id is null');
|
||||||
|
expect(anaconda.internal[1].id).toEqual('4j', 'Slot 1 should have SG 4j in it');
|
||||||
|
expect(anaconda.internal[1].c.grp).toEqual('sg','Slot 1 should have SG 4j in it');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("enforces a single shield fuel scoop", function() {
|
||||||
|
var id = 'anaconda';
|
||||||
|
var anacondaData = DB.ships[id];
|
||||||
|
var anaconda = new Ship(id, anacondaData.properties, anacondaData.slots);
|
||||||
|
anaconda.buildWith(anacondaData.defaults);
|
||||||
|
|
||||||
|
anaconda.use(anaconda.internal[4], '32', Components.internal('32')); // 4A Fuel Scoop
|
||||||
|
expect(anaconda.internal[4].c.grp).toEqual('fs', 'Anaconda fuel scoop slot');
|
||||||
|
|
||||||
|
anaconda.use(anaconda.internal[3], '32', Components.internal('32'));
|
||||||
|
|
||||||
|
expect(anaconda.internal[4].c).toEqual(null, 'Anaconda original fuel scoop slot is empty');
|
||||||
|
expect(anaconda.internal[4].id).toEqual(null, 'Anaconda original fuel scoop slot id is null');
|
||||||
|
expect(anaconda.internal[3].id).toEqual('32', 'Slot 1 should have FS 32 in it');
|
||||||
|
expect(anaconda.internal[3].c.grp).toEqual('fs','Slot 1 should have FS 32 in it');
|
||||||
|
});
|
||||||
|
|
||||||
|
it("enforces a single refinery", function() {
|
||||||
|
var id = 'anaconda';
|
||||||
|
var anacondaData = DB.ships[id];
|
||||||
|
var anaconda = new Ship(id, anacondaData.properties, anacondaData.slots);
|
||||||
|
anaconda.buildWith(anacondaData.defaults);
|
||||||
|
|
||||||
|
anaconda.use(anaconda.internal[4], '23', Components.internal('23')); // 4E Refinery
|
||||||
|
expect(anaconda.internal[4].c.grp).toEqual('rf', 'Anaconda refinery slot');
|
||||||
|
|
||||||
|
anaconda.use(anaconda.internal[3], '23', Components.internal('23'));
|
||||||
|
|
||||||
|
expect(anaconda.internal[4].c).toEqual(null, 'Anaconda original refinery slot is empty');
|
||||||
|
expect(anaconda.internal[4].id).toEqual(null, 'Anaconda original refinery slot id is null');
|
||||||
|
expect(anaconda.internal[3].id).toEqual('23', 'Slot 1 should have RF 23 in it');
|
||||||
|
expect(anaconda.internal[3].c.grp).toEqual('rf','Slot 1 should have RF 23 in it');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user