Compare commits

...

72 Commits

Author SHA1 Message Date
Colin McLeod
1350de1910 Empty retrofitting table color fix 2015-06-30 21:55:38 -07:00
Colin McLeod
89d3fd69e1 UI tweaks for mobile 2015-06-30 21:46:05 -07:00
Colin McLeod
7325081ec9 Version 1.0.0 :D 2015-06-30 21:09:19 -07:00
Colin McLeod
680872a302 Retrofitting costs added to outfit page 2015-06-30 21:06:12 -07:00
Colin McLeod
a3c65d6c69 Code comments 2015-06-30 19:25:57 -07:00
Colin McLeod
a189265326 Fix svg click bug in Chrome 2015-06-30 19:25:36 -07:00
Colin McLeod
b447e913ff no need to abbreviate shield details 2015-06-29 16:28:41 -07:00
Colin McLeod
b5a249fb4b Change latest version date format 2015-06-29 16:27:56 -07:00
Colin McLeod
ae081c147e Fix negative power for limpet controllers 2015-06-29 15:42:35 -07:00
Colin McLeod
3ce0d0bdd8 Add dps to outfit page 2015-06-29 15:03:04 -07:00
Colin McLeod
a71abd9fe3 Bumping version to 0.14.1 2015-06-29 14:59:30 -07:00
Colin McLeod
f1d804e3a1 Adding total DPS to outfit page and comparisons 2015-06-29 11:57:29 -07:00
Colin McLeod
aa7479d111 Updating Federal Dropship agility 2015-06-29 10:36:49 -07:00
Colin McLeod
7c23fb3884 Bumping version to 0.14.0 2015-06-26 11:00:46 -07:00
Colin McLeod
b707015d9c Fix power plant toggle power bug 2015-06-26 11:00:11 -07:00
Colin McLeod
10d5611dcd Seperate discounts for ship and components, added discounts for 5,10,15,20,25 percent off 2015-06-25 20:26:22 -07:00
Colin McLeod
9009a2a434 Bumping to 0.13.4, fixing courier bulkhead mass 2015-06-24 13:17:23 -07:00
Colin McLeod
8b98a98faf lint fix 2015-06-23 23:47:27 -07:00
Colin McLeod
44de3e4bbc Minor CSS refactor, outfit page tweak 2015-06-23 23:45:30 -07:00
Colin McLeod
ba2e9a12b0 Tweak chart axis labels 2015-06-23 11:47:23 -07:00
Colin McLeod
57304f55c1 Merge pull request #62 from Maverick-JM/master
Fixes for Windows phone and IE
2015-06-23 11:47:09 -07:00
Maverick
1eea358c35 Typo in the comments :). 2015-06-23 23:10:04 +10:00
Maverick
f671b7c34f Fix for the top menu not working in IE 11 (and probably older IE too). 2015-06-23 23:04:07 +10:00
Maverick
211028d80d Fix for the whole app not working on Windows phones as a Windows phone, this was somewhat vexing :)). 2015-06-23 22:27:24 +10:00
Justin Murtagh
c79359ea2f Merge pull request #6 from cmmcleod/master
Update my fork.
2015-06-23 22:04:34 +10:00
Colin McLeod
93f92da1df Adding line chart, adding speed function 2015-06-19 19:04:45 -07:00
Colin McLeod
25020293ec Fix unique internal component regression bug, add tests, bump to 0.13.3 2015-06-19 10:29:26 -07:00
Colin McLeod
4e7f1d3e8b Updating README and disclaimer text 2015-06-18 16:32:45 -07:00
Colin McLeod
e6ba0a14e8 Minor tweak to slot size position 2015-06-18 15:51:58 -07:00
Colin McLeod
b285a433b2 Bumping version to 0.13.2 2015-06-18 09:52:48 -07:00
Colin McLeod
f19c786f64 Update ship armour stats 2015-06-18 09:52:18 -07:00
Colin McLeod
806e545361 Fix charts in comparison page 2015-06-17 23:32:56 -07:00
Colin McLeod
ae62781d53 Bump version to 0.13.0 2015-06-17 23:17:15 -07:00
Colin McLeod
3abfcf7c95 Tweak chart axis UI 2015-06-17 23:12:27 -07:00
Colin McLeod
dc8b829d8a fix: total range calculation bug 2015-06-17 20:41:54 -07:00
Colin McLeod
353396398b Linting fix 2015-06-17 20:41:11 -07:00
Colin McLeod
bf99b34596 Tweak outfit page charts responsiveness 2015-06-16 15:28:06 -07:00
Colin McLeod
f3af0f3a99 Toggling shield and boosters updates shield strength 2015-06-16 15:27:41 -07:00
Colin McLeod
0fd4a8395e Tweak area chart tooltip 2015-06-16 15:26:47 -07:00
Colin McLeod
cb664003a5 Tweak slider 2015-06-16 15:26:22 -07:00
Colin McLeod
4686f17d18 Strip build should reset bulkheads 2015-06-16 15:26:05 -07:00
Colin McLeod
45c96dc136 Icon tweaks, added feather icon 2015-06-16 15:25:25 -07:00
Colin McLeod
389fdc8dfa Removing unused svg icon 2015-06-15 23:25:42 -07:00
Colin McLeod
b94e6126cd Chart performance tweaks, UI tweaks 2015-06-15 21:46:55 -07:00
Colin McLeod
bee4f7e6bc Fix strip build bug, and update state 2015-06-15 18:18:27 -07:00
Colin McLeod
345b7f5ffe Removing codeship, adding travis build status to readme 2015-06-15 18:08:41 -07:00
Colin McLeod
f1b40eb38c Adding gulp back to package.json 2015-06-15 18:06:09 -07:00
Colin McLeod
f459c26bd7 Locking down npm dependencies, add caching to travis 2015-06-15 18:03:02 -07:00
Colin McLeod
825b678fb0 Total Range chart feature added 2015-06-15 17:43:28 -07:00
Colin McLeod
ce3818f99a Use Travis CI instead of Codeship 2015-06-15 17:32:18 -07:00
Colin McLeod
94e2b60cd1 Changing version link 2015-06-15 17:31:27 -07:00
Colin McLeod
3bbef71a5e Merge pull request #58 from shearn89/strip-ship
Adding in 'Strip Ship' functionality.
2015-06-15 16:26:01 -07:00
Alex Shearn
ca280673d1 Fixing indentation 2015-06-15 22:09:18 +01:00
Alex Shearn
ff477c035a Moving button as per comments 2015-06-15 20:28:15 +01:00
Alex Shearn
1c0b76a8c2 Adding in 'Strip Ship' functionality.
This commit adds a simple button next to the save/reload icons that strips the ship to maximum class, D-rated modules, and no optional modules. Still needs a custom icon! May try to add in future things like 'all cargo' or 'fill empty with...' options.
2015-06-15 20:07:13 +01:00
Colin McLeod
bef741332d Bumping version to 0.12.1 2015-06-15 10:11:34 -07:00
Colin McLeod
f54620ee24 Imperial Courier shield correction 2015-06-15 10:11:12 -07:00
Colin McLeod
7d28e69b1c Bumping version to 0.12.0 2015-06-15 09:32:59 -07:00
Colin McLeod
abfe1b4a68 Updating base shield strength for Diamondback ships 2015-06-15 09:31:33 -07:00
Colin McLeod
59e400d7b8 Detailed suface scanner power management special case 2015-06-14 18:58:27 -07:00
Colin McLeod
4b3bb3bcde License readme tweak 2015-06-14 18:58:05 -07:00
Colin McLeod
a4a562bd40 Linting fixes 2015-06-14 17:47:16 -07:00
Colin McLeod
a1506d4f37 Selectable power bands, with right click to clear feature 2015-06-14 17:26:21 -07:00
Colin McLeod
8b0f58cb69 Right-click to clear slots feature 2015-06-14 17:26:04 -07:00
Colin McLeod
1a14674352 Updating License details to comply with Frontier terms and conditions 2015-06-14 17:25:28 -07:00
Colin McLeod
a2c32dd908 Bumping version to 0.11.1 2015-06-13 00:56:08 -07:00
Colin McLeod
eb7383b31e Lint fix 2015-06-13 00:44:15 -07:00
Colin McLeod
2106ec0e93 Ship building edge case, plus unit test to cover change 2015-06-13 00:43:10 -07:00
Colin McLeod
5649dc9079 Adding founders world discount 2015-06-12 23:40:32 -07:00
Colin McLeod
0d09607d30 Ship build, reset bug 2015-06-12 23:38:33 -07:00
Colin McLeod
d7415ea44a Updating hull prices for diamondback scout+exp, imperial courier 2015-06-12 20:14:56 -07:00
Justin Murtagh
6fb2247dd7 Merge pull request #5 from cmmcleod/master
Merge back post-responsive priority stuff.
2015-06-12 07:12:13 +10:00
58 changed files with 1183 additions and 331 deletions

19
.travis.yml Normal file
View 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

View File

@@ -1,4 +1,4 @@
[ ![Codeship Status for cmmcleod/coriolis](https://codeship.com/projects/637858c0-f2a5-0132-7af7-5ed004d44c71/status?branch=master)](https://codeship.com/projects/85232) [![Tasks in Ready](https://badge.waffle.io/cmmcleod/coriolis.png?label=ready&title=Ready)](https://waffle.io/cmmcleod/coriolis) [![Tasks in Progress](https://badge.waffle.io/cmmcleod/coriolis.svg?label=in%20progress&title=In%20Progress)](http://waffle.io/cmmcleod/coriolis)
[![Build Status](https://travis-ci.org/cmmcleod/coriolis.svg?branch=master)](https://travis-ci.org/cmmcleod/coriolis) [![Tasks in Ready](https://badge.waffle.io/cmmcleod/coriolis.png?label=ready&title=Ready)](https://waffle.io/cmmcleod/coriolis) [![Tasks in Progress](https://badge.waffle.io/cmmcleod/coriolis.svg?label=in%20progress&title=In%20Progress)](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.
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
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
@@ -28,12 +28,15 @@ See [Data wiki](https://github.com/cmmcleod/coriolis/wiki/Database) for details
## License
The MIT License
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/).
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
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
of this software (Javascript, CSS, HTML, and SVG files only), and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is

View File

@@ -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
View 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

View File

@@ -1,6 +1,3 @@
<?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">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="33" height="33" viewBox="0 0 33 33">
<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>

Before

Width:  |  Height:  |  Size: 713 B

After

Width:  |  Height:  |  Size: 499 B

View File

@@ -1,6 +1,4 @@
<?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">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="33" height="33" viewBox="0 0 33 33">
<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>

Before

Width:  |  Height:  |  Size: 723 B

After

Width:  |  Height:  |  Size: 510 B

View File

@@ -63,10 +63,10 @@
<footer>
<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 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>
</footer>

View File

@@ -1,8 +1,14 @@
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',
function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hpc, 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, Discounts) {
// 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
$rootScope.$on('$stateChangeError', function(e, toState, toParams, fromState, fromParams, error) {
@@ -33,12 +39,19 @@ function($rootScope, $location, $window, $doc, $state, CArr, shipPurpose, sz, hp
$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. discounts = { opts: Discounts };
$rootScope.STATUS = ['', 'DISABLED', 'OFF', 'ON'];
$rootScope.STATUS_CLASS = ['', 'disabled', 'warning', 'secondary-disabled'];
$rootScope.title = 'Coriolis';
$rootScope.cName = function(c) {
return c.c ? c.c.name ? c.c.name : GroupMap[c.c.grp] : null;
/**
* Returns the name of the component mounted in the specified slot
* @param {Object} slot The slot object
* @return {String} The component name
*/
$rootScope.cName = function(slot) {
return slot.c ? slot.c.name ? slot.c.name : GroupMap[slot.c.grp] : null;
};
// Formatters

View File

@@ -1,7 +1,8 @@
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 win = angular.element($window); // Angularized window object for event triggering
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 win = angular.element($window); // Angularized window object for event triggering
var retrofitShip = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship for retrofit comparison
// Update the ship instance with the code (if provided) or the 'factory' defaults.
if ($p.code) {
@@ -30,17 +31,32 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.selectedSlot = null;
$scope.savedCode = Persist.getBuild(ship.id, $scope.buildName);
$scope.canSave = Persist.isEnabled();
$scope.allBuilds = Persist.builds;
$scope.fuel = 0;
$scope.pwrDesc = false;
$scope.pwrPredicate = 'type';
$scope.retroDesc = false;
$scope.retroPredicate = 'netCost';
$scope.costDesc = true;
$scope.costPredicate = 'c.cost';
$scope.costTab = 'retrofit';
if ($scope.savedCode) {
Serializer.toShip(retrofitShip, $scope.savedCode); // Populate components from last save
$scope.retrofitBuild = $scope.buildName;
} else {
retrofitShip.buildWith(data.defaults);
$scope.retrofitBuild = null;
}
ship.applyDiscounts($rootScope.discounts.ship, $rootScope.discounts.components);
retrofitShip.applyDiscounts($rootScope.discounts.ship, $rootScope.discounts.components);
updateRetrofitCosts();
$scope.jrSeries = {
xMin: 0,
xMax: ship.cargoCapacity,
// Slightly higher than actual based bacuse components are excluded
yMax: ship.jumpRangeWithMass(ship.unladenMass),
yMax: ship.unladenRange,
yMin: 0,
func: function(cargo) { // X Axis is Cargo
return ship.jumpRangeWithMass(ship.unladenMass + $scope.fuel + cargo, $scope.fuel);
@@ -56,8 +72,52 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
title: 'Jump Range',
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'
}
}
};
/**
@@ -83,9 +143,9 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
* @param {[type]} slot The slot object belonging to the ship instance
* @param {[type]} e The event object
*/
$scope.select = function(type, slot, e) {
$scope.select = function(type, slot, e, id) {
e.stopPropagation();
var id = angular.element(e.target).attr('cpid'); // Get component ID
id = id || angular.element(e.target).attr('cpid'); // Get component ID
if (id) {
if (id == 'empty') {
@@ -100,8 +160,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
ship.useBulkhead(id);
}
$scope.selectedSlot = null;
$scope.code = Serializer.fromShip(ship);
updateState();
updateState(Serializer.fromShip(ship));
}
};
@@ -111,11 +170,24 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.reloadBuild = function() {
if ($scope.buildName && $scope.savedCode) {
Serializer.toShip(ship, $scope.savedCode); // Repopulate with components from last save
$scope.code = $scope.savedCode;
updateState();
updateState($scope.savedCode);
}
};
/**
* 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
* for this ship & with the exact name.
@@ -132,7 +204,10 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
if ($scope.code != $scope.savedCode) {
Persist.saveBuild(ship.id, $scope.buildName, $scope.code);
$scope.savedCode = $scope.code;
updateState();
if ($scope.retrofitBuild === $scope.buildName) {
Serializer.toShip(retrofitShip, $scope.code);
}
updateState($scope.code);
}
};
@@ -175,27 +250,29 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
$scope.pwrPredicate = key;
};
$scope.sortRetrofit = function(key) {
$scope.retroDesc = $scope.retroPredicate == key ? !$scope.retroDesc : $scope.retroDesc;
$scope.retroPredicate = key;
};
/**
* Toggle the power on/off for the selected component
* @param {object} item The component being toggled
*/
$scope.togglePwr = function(c) {
ship.setSlotEnabled(c, !c.enabled);
$scope.code = Serializer.fromShip(ship);
updateState();
updateState(Serializer.fromShip(ship));
};
$scope.incPriority = function(c) {
if (ship.changePriority(c, c.priority + 1)) {
$scope.code = Serializer.fromShip(ship);
updateState();
updateState(Serializer.fromShip(ship));
}
};
$scope.decPriority = function(c) {
if (ship.changePriority(c, c.priority - 1)) {
$scope.code = Serializer.fromShip(ship);
updateState();
updateState(Serializer.fromShip(ship));
}
};
@@ -212,19 +289,78 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
return ship.getSlotStatus(slot, true);
};
$scope.setRetrofitBase = function() {
if ($scope.retrofitBuild) {
Serializer.toShip(retrofitShip, Persist.getBuild(ship.id, $scope.retrofitBuild));
} else {
retrofitShip.buildWith(data.defaults);
}
updateRetrofitCosts();
};
// 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 });
$scope.jrSeries.xMax = ship.cargoCapacity;
$scope.jrSeries.yMax = ship.jumpRangeWithMass(ship.unladenMass);
$scope.jrSeries.mass = ship.unladenMass;
$scope.speedSeries.xMax = $scope.trSeries.xMax = $scope.jrSeries.xMax = ship.cargoCapacity;
$scope.jrSeries.yMax = ship.unladenRange;
$scope.trSeries.yMax = ship.unladenTotalRange;
updateRetrofitCosts();
win.triggerHandler('pwrchange');
}
function updateRetrofitCosts() {
var costs = $scope.retrofitList = [];
var cName = $rootScope.cName;
var total = 0, i, l, item;
if (ship.bulkheads.id != retrofitShip.bulkheads.id) {
item = {
buyClassRating: ship.bulkheads.c.class + ship.bulkheads.c.rating,
buyName: cName(ship.bulkheads),
sellClassRating: retrofitShip.bulkheads.c.class + retrofitShip.bulkheads.c.rating,
sellName: cName(retrofitShip.bulkheads),
netCost: ship.bulkheads.discountedCost - retrofitShip.bulkheads.discountedCost
};
costs.push(item);
total += item.netCost;
}
for (var g in { common: 1, internal: 1, hardpoints: 1 }) {
var retroSlotGroup = retrofitShip[g];
var slotGroup = ship[g];
for (i = 0, l = slotGroup.length; i < l; i++) {
if (slotGroup[i].id != retroSlotGroup[i].id) {
item = { netCost: 0 };
if (slotGroup[i].id) {
item.buyName = cName(slotGroup[i]);
item.buyClassRating = slotGroup[i].c.class + slotGroup[i].c.rating;
item.netCost = slotGroup[i].discountedCost;
}
if (retroSlotGroup[i].id) {
item.sellName = cName(retroSlotGroup[i]);
item.sellClassRating = retroSlotGroup[i].c.class + retroSlotGroup[i].c.rating;
item.netCost -= retroSlotGroup[i].discountedCost;
}
costs.push(item);
total += item.netCost;
}
}
}
$scope.retrofitTotal = total;
}
// Hide any open menu/slot/etc if the background is clicked
$scope.$on('close', function() {
$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);
retrofitShip.applyDiscounts($rootScope.discounts.ship, $rootScope.discounts.components);
updateRetrofitCosts();
});
}]);

View File

@@ -19,7 +19,8 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
xAxis = d3.svg.axis().outerTickSize(0).orient('bottom').tickFormat(d3.format('.2r')),
yAxis = d3.svg.axis().ticks(6).outerTickSize(0).orient('left').tickFormat(fmt),
x = d3.scale.linear(),
y = d3.scale.linear();
y = d3.scale.linear(),
data = [];
// Create chart
var svg = d3.select(element[0]).append('svg');
@@ -61,13 +62,35 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
// Create and Add tooltip
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')
.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');
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)
*/
@@ -78,8 +101,9 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
var width = element[0].parentElement.offsetWidth,
height = width * 0.5,
w = width - margin.left - margin.right,
h = height - margin.top - margin.bottom,
data = [];
h = height - margin.top - margin.bottom;
data.length = 0; // Reset Data array
if (series.xMax == series.xMin) {
var yVal = func(series.xMin);
@@ -95,7 +119,7 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
// Update Chart Size
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);
xAxis.scale(x);
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('.x.axis').call(xAxis);
// Remove existing elements
vis.selectAll('path.area').remove();
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);
vis.selectAll('path.area') // Area/Path to appear behind everything else
.data([data])
.attr('d', area);
}
function showTip() {
@@ -143,10 +146,10 @@ angular.module('app').directive('areaChart', ['$window', function($window) {
}
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.selectAll('rect').attr('x', flip ? '-4.5em' : '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('rect').attr('x', flip ? '-5.75em' : '0.5em').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.y').text(fmtLong(y0) + ' ' + labels.yAxis.unit);
}

View File

@@ -21,7 +21,7 @@ angular.module('app').directive('componentSelect', function() {
list.push((o.maxmass && mass > o.maxmass) ? ' disabled"' : '" cpid="', id, '">');
if (o.mode) {
list.push('<svg cpid="', id, '" class="icon lg"><use xlink:href="#mount-', o.mode, '"></use></svg> ');
list.push('<svg cpid="', id, '" class="icon lg"><use cpid="', id, '" xlink:href="#mount-', o.mode, '"></use></svg> ');
}
list.push(o.class, o.rating);

View File

@@ -0,0 +1,12 @@
angular.module('app').directive('contextMenu', ['$parse', function($parse) {
return function(scope, element, attrs) {
var fn = $parse(attrs.contextMenu);
element.bind('contextmenu', function(e) {
scope.$apply(function() {
e.preventDefault();
fn(scope, { $event: e });
});
});
};
}]);

View File

@@ -12,17 +12,11 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
scope.allComparisons = Persist.comparisons;
scope.bs = Persist.state;
// Insurance options and management here for now.
$rootScope.insurance = {
opts: [
{ name: 'Standard', pct: 0.05 },
{ name: 'Alpha', pct: 0.025 },
{ name: 'Beta', pct: 0.035 }
]
};
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.discounts.ship = savedDiscounts[0];
$rootScope.discounts.components = savedDiscounts[1];
// Close menus if a navigation change event occurs
$rootScope.$on('$stateChangeStart', function() {
@@ -42,6 +36,14 @@ angular.module('app').directive('shipyardHeader', ['lodash', '$rootScope', 'Pers
Persist.setInsurance($rootScope.insurance.current.name);
};
/**
* Save selected discount option
*/
scope.updateDiscount = function() {
Persist.setDiscount([$rootScope.discounts.ship, $rootScope.discounts.components]);
$rootScope.$broadcast('discountChange');
};
scope.openMenu = function(e, menu) {
e.stopPropagation();
if (menu == scope.openedMenu) {

View 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);
});
}
};
}]);

View File

@@ -8,6 +8,7 @@ angular.module('app').directive('powerBands', ['$window', function($window) {
link: function(scope, element) {
var margin = { top: 20, right: 130, bottom: 20, left: 40 },
barHeight = 20,
bands = null,
innerHeight = (barHeight * 2) + 3,
height = innerHeight + margin.top + margin.bottom + 1,
wattScale = d3.scale.linear(),
@@ -19,8 +20,17 @@ angular.module('app').directive('powerBands', ['$window', function($window) {
// Create chart
svg = d3.select(element[0]).append('svg'),
vis = svg.append('g').attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'),
deployed = vis.append('g'),
retracted = vis.append('g');
deployed = vis.append('g').attr('class', 'power-band'),
retracted = vis.append('g').attr('class', 'power-band');
svg.on('contextmenu', function() {
d3.event.preventDefault();
for (var i = 0, l = bands.length; i < l; i++) {
bands[i].retSelected = false;
bands[i].depSelected = false;
}
render();
});
// Create Y Axis SVG Elements
vis.append('g').attr('class', 'watt axis');
@@ -36,12 +46,17 @@ angular.module('app').directive('powerBands', ['$window', function($window) {
angular.element($window).bind('orientationchange resize pwrchange', render);
function render() {
var bands = scope.bands,
available = scope.available,
bands = scope.bands;
var available = scope.available,
width = element[0].offsetWidth,
w = width - margin.left - margin.right,
maxBand = bands[bands.length - 1],
maxPwr = Math.max(available, maxBand.deployedSum);
deployedSum = 0,
retractedSum = 0,
retBandsSelected = false,
depBandsSelected = false,
maxPwr = Math.max(available, maxBand.retractedSum, maxBand.deployedSum);
// Update chart size
svg.attr('width', width).attr('height', height);
@@ -55,50 +70,80 @@ angular.module('app').directive('powerBands', ['$window', function($window) {
// Update X & Y Axis
wattScale.range([0, w]).domain([0, maxPwr]).clamp(true);
pctScale.range([0, w]).domain([0, maxPwr / available]).clamp(true);
vis.selectAll('.watt.axis').call(wattAxis);
vis.selectAll('.pct.axis').attr('transform', 'translate(0,' + innerHeight + ')').call(pctAxis);
retLbl
.attr('x', w + 5 )
.attr('class', maxBand.retractedSum > available ? 'warning' : 'primary')
.text(wattFmt(Math.max(0, maxBand.retractedSum)) + ' (' + pctFmt(Math.max(0, maxBand.retractedSum / available)) + ')');
for (var b = 0, l = bands.length; b < l; b++) {
if (bands[b].retSelected) {
retractedSum += bands[b].retracted + bands[b].retOnly;
retBandsSelected = true;
}
if (bands[b].depSelected) {
deployedSum += bands[b].deployed + bands[b].retracted;
depBandsSelected = true;
}
}
depLbl
.attr('x', w + 5 )
.attr('class', maxBand.deployedSum > available ? 'warning' : 'primary')
.text(wattFmt(Math.max(0, maxBand.deployedSum)) + ' (' + pctFmt(Math.max(0, maxBand.deployedSum / available)) + ')');
updateLabel(retLbl, w, retBandsSelected, retBandsSelected ? retractedSum : maxBand.retractedSum, available);
updateLabel(depLbl, w, depBandsSelected, depBandsSelected ? deployedSum : maxBand.deployedSum, available);
retracted.selectAll('rect').data(bands).enter().append('rect')
.attr('height', barHeight)
.attr('width', function(d) { return Math.max(wattScale(d.retracted) - 1, 0); })
.attr('x', function(d) { return wattScale(d.retractedSum) - wattScale(d.retracted); })
.attr('width', function(d) { return Math.max(wattScale(d.retracted + d.retOnly) - 1, 0); })
.attr('x', function(d) { return wattScale(d.retractedSum) - wattScale(d.retracted + d.retOnly); })
.attr('y', 1)
.attr('class', function(d) { return (d.retractedSum > available) ? 'warning' : 'primary'; });
.on('click', function(d) {
d.retSelected = !d.retSelected;
render();
})
.attr('class', function(d) { return getClass(d.retSelected, d.retractedSum, available); });
retracted.selectAll('text').data(bands).enter().append('text')
.attr('x', function(d) { return wattScale(d.retractedSum) - (wattScale(d.retracted) / 2); })
.attr('x', function(d) { return wattScale(d.retractedSum) - (wattScale(d.retracted + d.retOnly) / 2); })
.attr('y', 15)
.style('text-anchor', 'middle')
.attr('class', 'primary-bg')
.text(function(d, i) { return bandText(d.retracted, i); });
.on('click', function(d) {
d.retSelected = !d.retSelected;
render();
})
.text(function(d, i) { return bandText(d.retracted + d.retOnly, i); });
deployed.selectAll('rect').data(bands).enter().append('rect')
.attr('height', barHeight)
.attr('width', function(d) { return Math.max(wattScale(d.deployed + d.retracted) - 1, 0); })
.attr('x', function(d) { return wattScale(d.deployedSum) - wattScale(d.retracted) - wattScale(d.deployed); })
.attr('y', barHeight + 2)
.attr('class', function(d) { return (d.deployedSum > available) ? 'warning' : 'primary'; });
.on('click', function(d) {
d.depSelected = !d.depSelected;
render();
})
.attr('class', function(d) { return getClass(d.depSelected, d.deployedSum, available); });
deployed.selectAll('text').data(bands).enter().append('text')
.attr('x', function(d) { return wattScale(d.deployedSum) - ((wattScale(d.retracted) + wattScale(d.deployed)) / 2); })
.attr('y', barHeight + 17)
.style('text-anchor', 'middle')
.attr('class', 'primary-bg')
.on('click', function(d) {
d.depSelected = !d.depSelected;
render();
})
.text(function(d, i) { return bandText(d.deployed + d.retracted, i); });
}
function updateLabel(lbl, width, selected, sum, available) {
lbl
.attr('x', width + 5 )
.attr('class', getClass(selected, sum, available))
.text(wattFmt(Math.max(0, sum)) + ' (' + pctFmt(Math.max(0, sum / available)) + ')');
}
function getClass(selected, sum, available) {
return selected ? 'secondary' : (sum > available) ? 'warning' : 'primary';
}
function bandText(val, index) {
if (val > 0 && wattScale(val) > 13) {
return index + 1;

View File

@@ -8,7 +8,7 @@ angular.module('app').directive('slider', ['$window', function($window) {
change: '&onChange'
},
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
h = height - margin.top - margin.bottom,
fmt = d3.format('.2f'),

View File

@@ -183,6 +183,27 @@ angular.module('app').service('Persist', ['$window', 'lodash', function($window,
}
};
/**
* Persist selected discount
* @param {number} val Discount value/amount
*/
this.setDiscount = function(val) {
if (this.lsEnabled) {
return localStorage.setItem('discounts', angular.toJson(val));
}
};
/**
* Get the saved discount
* @return {number} val Discount value/amount
*/
this.getDiscount = function() {
if (this.lsEnabled) {
return angular.fromJson(localStorage.getItem('discounts'));
}
return null;
};
/**
* Retrieve the last router state from local storage
* @param {object} state State object containing state name and params

View File

@@ -1,4 +1,22 @@
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
* @param {object} slot The Slot
* @param {object} component The component in the slot
* @return {string} The key for the power usage type
*/
function powerUsageType(slot, component) {
if (component) {
if (component.retractedOnly) {
return 'retOnly';
}
if (component.passive) {
return 'retracted';
}
}
return slot.cat != 1 ? 'retracted' : 'deployed';
}
/**
* Ship model used to track all ship components and properties.
@@ -21,7 +39,8 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
group.push({ id: null, c: null, incCost: true, maxClass: slotGroup[i] });
}
}
this.c = { incCost: true, 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.push(this.bulkheads); // Add The bulkheads
@@ -36,23 +55,16 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.powerList.unshift(this.common[2]); // Add FSD
this.powerList.unshift(this.common[0]); // Add Power Plant
this.priorityBands = [
{ deployed: 0, retracted: 0 },
{ deployed: 0, retracted: 0 },
{ deployed: 0, retracted: 0 },
{ deployed: 0, retracted: 0 },
{ deployed: 0, retracted: 0 }
];
this.shipDiscount = 1;
this.componentDiscount = 1;
// Cumulative and aggragate stats
this.fuelCapacity = 0;
this.cargoCapacity = 0;
this.ladenMass = 0;
this.armourAdded = 0;
this.shieldMultiplier = 1;
this.totalCost = this.cost;
this.unladenMass = this.mass;
this.armourTotal = this.armour;
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 },
{ deployed: 0, retracted: 0, retOnly: 0 }
];
}
/**
@@ -67,6 +79,18 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
cl = common.length,
i, l;
// Reset Cumulative stats
this.fuelCapacity = 0;
this.cargoCapacity = 0;
this.ladenMass = 0;
this.armourAdded = 0;
this.shieldMultiplier = 1;
this.totalCost = this.c.incCost ? this.c.discountedCost : 0;
this.unladenMass = this.mass;
this.armourTotal = this.armour;
this.totalDps = 0;
this.bulkheads.c = null;
this.useBulkhead(comps.bulkheads || 0, true);
this.cargoScoop.priority = priorities ? priorities[0] * 1 : 0;
this.cargoScoop.enabled = enabled ? enabled[0] * 1 : true;
@@ -74,6 +98,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (i = 0, l = this.priorityBands.length; i < l; i++) {
this.priorityBands[i].deployed = 0;
this.priorityBands[i].retracted = 0;
this.priorityBands[i].retOnly = 0;
}
if (this.cargoScoop.enabled) {
@@ -81,10 +106,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
}
for (i = 0; i < cl; i++) {
common[i].cat = 0;
common[i].enabled = enabled ? enabled[i + 1] * 1 : true;
common[i].priority = priorities ? priorities[i + 1] * 1 : 0;
common[i].type = 'SYS';
common[i].c = common[i].id = null; // Resetting 'old' component if there was one
common[i].discountedCost = 0;
this.use(common[i], comps.common[i], Components.common(i, comps.common[i]), true);
}
@@ -93,10 +120,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
cl++; // Increase accounts for Cargo Scoop
for (i = 0, l = hps.length; i < l; i++) {
hps[i].cat = 1;
hps[i].enabled = enabled ? enabled[cl + i] * 1 : true;
hps[i].priority = priorities ? priorities[cl + i] * 1 : 0;
hps[i].type = hps[i].maxClass ? 'WEP' : 'SYS';
hps[i].c = hps[i].id = null; // Resetting 'old' component if there was one
hps[i].discountedCost = 0;
if (comps.hardpoints[i] !== 0) {
this.use(hps[i], comps.hardpoints[i], Components.hardpoints(comps.hardpoints[i]), true);
@@ -106,10 +135,12 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
cl += hps.length; // Increase accounts for hardpoints
for (i = 0, l = internal.length; i < l; i++) {
internal[i].cat = 2;
internal[i].enabled = enabled ? enabled[cl + i] * 1 : true;
internal[i].priority = priorities ? priorities[cl + i] * 1 : 0;
internal[i].type = 'SYS';
internal[i].id = internal[i].c = null; // Resetting 'old' component if there was one
internal[i].discountedCost = 0;
if (comps.internal[i] !== 0) {
this.use(internal[i], comps.internal[i], Components.internal(comps.internal[i]), true);
@@ -126,6 +157,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
var oldBulkhead = this.bulkheads.c;
this.bulkheads.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);
};
@@ -140,23 +172,21 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
*/
Ship.prototype.use = function(slot, id, component, preventUpdate) {
if (slot.id != id) { // Selecting a different component
var slotIndex = this.internal.indexOf(slot);
// Slot is an internal slot, is not being emptied, and the selected component group/type must be of unique
if (slotIndex != -1 && 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
var similarSlotIndex = this.findInternalByGroup(component.grp);
var similarSlot = this.findInternalByGroup(component.grp);
// If another slot has an installed component with of the same type
if (similarSlotIndex != -1 && similarSlotIndex != slotIndex) {
// Empty the slot
var similarSlot = this.internal[similarSlotIndex];
if (!preventUpdate && similarSlot && similarSlot !== slot) {
this.updateStats(similarSlot, null, similarSlot.c, true); // Update stats but don't trigger a global update
similarSlot.id = null;
similarSlot.c = null;
similarSlot.id = similarSlot.c = null; // Empty the slot
similarSlot.discountedCost = 0;
}
}
var oldComponent = slot.c;
slot.id = id;
slot.c = component;
slot.discountedCost = (component && component.cost) ? component.cost * this.componentDiscount : 0;
this.updateStats(slot, component, oldComponent, preventUpdate);
}
};
@@ -180,9 +210,13 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
* @return {number} The index of the slot in ship.internal
*/
Ship.prototype.findInternalByGroup = function(group) {
return _.findIndex(this.internal, function(slot) {
var index = _.findIndex(this.internal, function(slot) {
return slot.c && slot.c.grp == group;
});
if (index !== -1) {
return this.internal[index];
}
return null;
};
/**
@@ -197,7 +231,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
slot.priority = newPriority;
if (slot.enabled) { // Only update power if the slot is enabled
var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1) ? 'retracted' : 'deployed';
var usage = powerUsageType(slot, slot.c);
this.priorityBands[oldPriority][usage] -= slot.c.power;
this.priorityBands[newPriority][usage] += slot.c.power;
this.updatePower();
@@ -209,18 +243,29 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
Ship.prototype.setCostIncluded = function(item, included) {
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;
};
Ship.prototype.setSlotEnabled = function(slot, enabled) {
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
var usage = (slot.c.passive || this.hardpoints.indexOf(slot) == -1) ? 'retracted' : 'deployed';
this.priorityBands[slot.priority][usage] += enabled ? slot.c.power : -slot.c.power;
this.updatePower();
if (slot.enabled != enabled) { // Enabled state is changing
slot.enabled = enabled;
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();
} else if (slot.c.dps) {
this.totalDps += slot.c.dps * (enabled ? 1 : -1);
}
this.updatePower();
}
}
slot.enabled = enabled;
};
Ship.prototype.getSlotStatus = function(slot, deployed) {
@@ -228,9 +273,10 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
return 0; // No Status (Not possible)
} else if (!slot.enabled) {
return 1; // Disabled
} else if (deployed) {
} else if (deployed && !slot.c.retractedOnly) { // Certain component (e.g. Detaild Surface scanner) are power only while retracted
return this.priorityBands[slot.priority].deployedSum > this.powerAvailable ? 2 : 3; // Offline : Online
} else if (this.hardpoints.indexOf(slot) != -1 && !slot.c.passive) { // Active hardpoints have no retracted status
// Active hardpoints have no retracted status
} else if ((deployed && slot.c.retractedOnly) || (slot.cat === 1 && !slot.c.passive)) {
return 0; // No Status (Not possible)
}
return this.priorityBands[slot.priority].retractedSum > this.powerAvailable ? 2 : 3; // Offline : Online
@@ -240,7 +286,6 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
* Updates the ship's cumulative and aggregated stats based on the component change.
*/
Ship.prototype.updateStats = function(slot, n, old, preventUpdate) {
var isHardPoint = this.hardpoints.indexOf(slot) != -1;
var powerChange = slot == this.common[0];
if (old) { // Old component now being removed
@@ -255,17 +300,21 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.armourAdded -= old.armouradd;
break;
case 'sb':
this.shieldMultiplier -= old.shieldmul;
this.shieldMultiplier -= slot.enabled ? old.shieldmul : 0;
break;
}
if (slot.incCost && old.cost) {
this.totalCost -= old.cost;
this.totalCost -= old.cost * this.componentDiscount;
}
if (old.power && slot.enabled) {
this.priorityBands[slot.priority][(isHardPoint && !old.passive) ? 'deployed' : 'retracted'] -= old.power;
this.priorityBands[slot.priority][powerUsageType(slot, old)] -= old.power;
powerChange = true;
if (old.dps) {
this.totalDps -= old.dps;
}
}
this.unladenMass -= old.mass || 0;
}
@@ -285,17 +334,21 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
this.armourAdded += n.armouradd;
break;
case 'sb':
this.shieldMultiplier += n.shieldmul;
this.shieldMultiplier += slot.enabled ? n.shieldmul : 0;
break;
}
if (slot.incCost && n.cost) {
this.totalCost += n.cost;
this.totalCost += n.cost * this.componentDiscount;
}
if (n.power && slot.enabled) {
this.priorityBands[slot.priority][(isHardPoint && !n.passive) ? 'deployed' : 'retracted'] += n.power;
this.priorityBands[slot.priority][powerUsageType(slot, n)] += n.power;
powerChange = true;
if (n.dps) {
this.totalDps += n.dps;
}
}
this.unladenMass += n.mass || 0;
}
@@ -318,7 +371,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
for (var i = 0, l = bands.length; i < l; i++) {
var band = bands[i];
prevRetracted = band.retractedSum = prevRetracted + band.retracted;
prevRetracted = band.retractedSum = prevRetracted + band.retracted + band.retOnly;
prevDeployed = band.deployedSum = prevDeployed + band.deployed + band.retracted;
}
@@ -328,32 +381,44 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
};
Ship.prototype.updateShieldStrength = function() {
var sgSI = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
this.shieldStrength = sgSI != -1 ? calcShieldStrength(this.mass, this.shields, this.internal[sgSI].c, this.shieldMultiplier) : 0;
var sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
this.shieldStrength = sgSlot && sgSlot.enabled ? calcShieldStrength(this.mass, this.shields, sgSlot.c, this.shieldMultiplier) : 0;
};
/**
* Jump Range and total range calculations
*/
Ship.prototype.updateJumpStats = function() {
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;
var fsd = this.common[2].c; // Frame Shift Drive;
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.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;
this.ladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining) : 0;
/**
* Recalculate all item costs and total based on discounts.
* @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 j = 0, l = Math.floor(jumps); j < l; j++) {
fuelRemaining += fsd.maxfuel;
this.unladenTotalRange += calcJumpRange(this.unladenMass + fuelRemaining, fsd);
this.ladenTotalRange += calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd);
for (var i = 0, l = costList.length; i < l; i++) {
var item = costList[i];
if (item.c && item.c.cost) {
item.discountedCost = item.c.cost * (item.type == 'SHIP' ? shipDiscount : componentDiscount);
if (item.incCost) {
total += item.discountedCost;
}
}
}
this.shipDiscount = shipDiscount;
this.componentDiscount = componentDiscount;
this.totalCost = total;
};
return Ship;

View File

@@ -163,8 +163,28 @@ angular.module('shipyard', ['ngLodash'])
lbls: ['Unladen', 'Laden'],
unit: 'LY',
fmt: 'fRound'
},
{ // 11
title: 'DPS',
props: ['totalDps'],
lbls: ['Dps'],
unit: '',
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
*
@@ -175,6 +195,27 @@ angular.module('shipyard', ['ngLodash'])
*/
.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;
})
/**
* 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.
@@ -187,9 +228,6 @@ angular.module('shipyard', ['ngLodash'])
* @return {number} Approximate shield strengh in MJ
*/
.value('calcShieldStrength', function(mass, shields, sg, multiplier) {
if (!sg) {
return 0;
}
if (mass <= sg.minmass) {
return shields * multiplier * sg.minmul;
}
@@ -200,4 +238,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.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 };
});

View File

@@ -1,11 +1,9 @@
.chart {
.user-select-none();
display: inline-block;
margin: 0;
cursor: default;
overflow: hidden;
width: 33%;
box-sizing: border-box;
@@ -23,6 +21,7 @@
&[ng-click] {
cursor: pointer;
}
}
}
@@ -63,5 +62,3 @@ svg {
stroke-width: 1px;
}
}

View File

@@ -39,6 +39,7 @@ header {
}
.smallTablet({
position: static;
position: initial;
});
}

View File

@@ -113,6 +113,25 @@ table.total {
}
}
.tabs {
width: 100%;
margin-bottom: 1px;
&, th {
border-collapse: collapse;
color: @primary-disabled;
background-color: @primary-bg;
border: 1px solid @primary-disabled;
padding-top: 1px;
}
.active {
color: @primary-bg;
background-color: @primary-disabled;
}
}
.group {
width: 25%;
padding: 0.5em 0.2em;
@@ -139,11 +158,6 @@ table.total {
font-weight: normal;
}
tbody tr:hover {
background-color: @warning-bg;
}
.smallTablet({
width: 50%;
});
@@ -152,7 +166,7 @@ table.total {
width: 100%;
});
&.dbl {
&.half {
width: 50%;
.tablet({
@@ -162,16 +176,36 @@ table.total {
});
.smallTablet({
overflow-x: auto;
-webkit-overflow-scrolling: touch;
width: 100% !important;
});
}
&.third {
width: 33%;
.smallTablet({
.axis.x {
g.tick:nth-child(2n + 1) text {
display: none;
}
}
});
.largePhone({
width: 100% !important;
});
}
}
.power-band {
text, rect {
cursor: pointer;
}
}
#componentPriority {
.tablet({
text.primary, text.warning, text.primary-bg {
text.primary, text.warning, text.primary-bg, text.secondary {
font-size: 0.8em;
}
@@ -213,9 +247,6 @@ table.total {
&:nth-child(3) {
display: none;
}
&:nth-child(2) {
font-size: 0.7em;
}
}
});

View File

@@ -1,3 +1,14 @@
select {
.border-radius(0);
background: none;
color: @primary-disabled;
border: 1px solid @primary-disabled;
outline: none;
font-family: @fStandard;
font-size: 1em;
background-color: transparent;
}
.select {
color: @primary-disabled;
position: absolute;

View File

@@ -44,6 +44,7 @@
border-right: 1px solid @primary-disabled;
box-sizing: border-box;
padding-top: 0.2em;
padding-left: 0.1em;
}
.empty {

View File

@@ -43,7 +43,6 @@ thead {
}
}
tbody tr {
&.tr {
@@ -55,6 +54,12 @@ tbody tr {
}
}
&.highlight {
&:hover {
background-color: @warning-bg;
}
}
td {
line-height: 1.4em;
padding: 0 0.3em;

View File

@@ -51,6 +51,14 @@
<ul>
Insurance
<li><select ng-model="insurance.current" ng-options="ins.name for (i,ins) in insurance.opts" ng-change="updateInsurance()"></select></li>
</ul><br>
<ul>
Ship Discount
<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>
<hr />
<ul>

View File

@@ -4,8 +4,8 @@
{{c.c.class}}{{c.c.rating}} {{c.c.name || lbl}}
<div class="r">{{c.c.mass || c.c.capacity || '0'}} <u>T</u></div>
<div class="cb"></div>
<div class="l" ng-if="c.c.optmass">Opt: {{c.c.optmass}} <u>T</u></div>
<div class="l" ng-if="c.c.maxmass">Max: {{c.c.maxmass}} <u>T</u></div>
<div class="l" ng-if="c.c.optmass">Optimal Mass: {{c.c.optmass}} <u>T</u></div>
<div class="l" ng-if="c.c.maxmass">Max Mass: {{c.c.maxmass}} <u>T</u></div>
<div class="l" ng-if="c.c.bins">{{c.c.bins}} <u>Bins</u></div>
<div class="l" ng-if="c.c.rate">Rate: {{c.c.rate}} <u>Kg/s</u>&nbsp;&nbsp;&nbsp;Refuel Time: {{$r.fTime(fuel * 1000 / c.c.rate)}}</div>
<div class="l" ng-if="c.c.ammo">Ammo: {{c.c.ammo}}</div>

View File

@@ -6,7 +6,7 @@
</div>
<div ng-show="processed">
<table class="l" style="overflow:hidden;margin: 1em 0;">
<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>
<tbody ng-repeat="(shipId,shipBuilds) in builds">
<tr class="cb" ng-repeat="(buildName, b) in shipBuilds">

View File

@@ -16,6 +16,9 @@
<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>
</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>
@@ -27,6 +30,7 @@
<th rowspan="2">Agility</th>
<th rowspan="2">Speed</th>
<th rowspan="2">Boost</th>
<th rowspan="2">DPS</th>
<th rowspan="2">Armour</th>
<th rowspan="2">Shields</th>
<th colspan="2">Mass</th>
@@ -52,8 +56,9 @@
<td>{{ship.agility}}/10</td>
<td>{{fRound(ship.speed)}} <u>m/s</u></td>
<td>{{fRound(ship.boost)}} <u>m/s</u></td>
<td>{{fRound(ship.totalDps)}}</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.ladenMass)}} <u>T</u></td>
<td>{{fRound(ship.cargoCapacity)}} <u>T</u></td>
@@ -165,7 +170,7 @@
<div id="internal" class="group">
<h1>Internal Compartments</h1>
<div class="slot" ng-repeat="i in ship.internal" ng-click="selectSlot($event, i)" ng-class="{selected: selectedSlot==i}">
<div class="slot" ng-repeat="i in ship.internal" ng-click="selectSlot($event, i)" context-menu="select('i', i, $event, 'empty')" ng-class="{selected: selectedSlot==i}">
<div slot-internal class="details" slot="i" lbl="GMAP[i.c.grp]" fuel="ship.fuelCapacity"></div>
<div class="select" ng-if="selectedSlot==i" ng-click="select('i',i,$event)">
<div component-select s="i" groups="availCS.getInts(i.maxClass)"></div>
@@ -175,7 +180,7 @@
<div id="hardpoints" class="group">
<h1>HardPoints</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}">
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '!0'}" ng-click="selectSlot($event, h)" context-menu="select('h', h, $event, 'empty')" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div>
<div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)">
<div component-select s="h" groups="availCS.getHps(h.maxClass)"></div>
@@ -185,7 +190,7 @@
<div id="utility" class="group">
<h1>Utility Mounts</h1>
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '0'}" ng-click="selectSlot($event, h)" ng-class="{selected: selectedSlot==h}">
<div class="slot" ng-repeat="h in ship.hardpoints | filter:{maxClass: '0'}" ng-click="selectSlot($event, h)" context-menu="select('h', h, $event, 'empty')" ng-class="{selected: selectedSlot==h}">
<div slot-hardpoint class="details" hp="h" size="HPC[h.maxClass]" lbl="GMAP[h.c.grp]"></div>
<div class="select" ng-class="{hardpoint: h.maxClass > 0}" ng-if="selectedSlot==h" ng-click="select('h',h,$event)">
<div component-select s="h" groups="availCS.getHps(h.maxClass)"></div>
@@ -193,7 +198,7 @@
</div>
</div>
<div class="group dbl" id="componentPriority">
<div class="group half" id="componentPriority">
<table style="width:100%">
<thead>
<tr class="main">
@@ -207,7 +212,7 @@
</thead>
<tbody>
<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><u>SYS</u></td>
<td>1</td>
@@ -217,7 +222,7 @@
<td></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 class="le shorten" ng-click="togglePwr(c)" ng-bind="cName(c)"></td>
<td ng-click="togglePwr(c)"><u ng-bind="c.type"></u></td>
@@ -233,23 +238,39 @@
<div style="margin-top: 1em" power-bands bands="priorityBands" available="ship.powerAvailable"></div>
</div>
<div class="group dbl">
<table style="width:100%">
<div class="group half">
<table class="tabs">
<thead>
<tr class="main">
<th colspan="2" class="sortable le" ng-click="sortCost(cName)">Component</th>
<th class="sortable le" ng-click="sortCost('c.cost')">Credits</th>
<tr>
<th style="width:50%" ng-class="{active: costTab == 'retrofit'}" ng-click="costTab = 'retrofit'">Retrofit Costs</th>
<th style="width:50%" ng-class="{active: costTab == 'costs'}" ng-click="costTab = 'costs'">Costs</th>
</tr>
</thead>
<tbody>
<tr class="toggleable" ng-repeat="c in costList | orderBy:costPredicate:costDesc" ng-if="c.c.cost > 0" ng-class="{disabled:!c.incCost}" ng-click="toggleCost(c)">
<td style="width:1em;">{{c.c.class}}{{c.c.rating}}</td>
<td class="le shorten" ng-bind="cName(c)"></td>
<td class="ri">{{fCrd(c.c.cost)}} <u>CR</u></td>
</tr>
</tbody>
</table>
<table class="total">
<div ng-if="costTab == 'costs'">
<table style="width:100%">
<thead>
<tr class="main">
<th colspan="2" class="sortable le" ng-click="sortCost(cName)">
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>
</thead>
<tbody>
<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(item)">{{item.c.class}}{{item.c.rating}}</td>
<td class="le toggleable shorten" ng-click="toggleCost(item)">{{cName(item)}}</td>
<td class="ri toggleable" ng-click="toggleCost(item)">{{fCrd(item.discountedCost)}} <u>CR</u></td>
</tr>
</tbody>
</table>
<table class="total">
<tr class="ri">
<td class="lbl">Total</td>
<td>{{fCrd(ship.totalCost)}} <u>CR</u></td>
@@ -258,16 +279,75 @@
<td class="lbl">Insurance</td>
<td>{{fCrd(ship.totalCost * insurance.current.pct)}} <u>CR</u></td>
</tr>
</table>
</table>
</div>
<div ng-if="costTab == 'retrofit'">
<div style="overflow-x: auto;-webkit-overflow-scrolling: touch;">
<table style="width:100%">
<thead>
<tr class="main">
<th colspan="2" class="sortable le" ng-click="sortRetrofit('sellName')">Sell</th>
<th colspan="2" class="sortable le" ng-click="sortRetrofit('buyName')">Buy</th>
<th class="sortable le" ng-click="sortRetrofit('netCost')">
Net Cost
<div class="r">
<u ng-if="discounts.components < 1">[{{fRPct(1 - discounts.components)}} off]</u>
</div>
</th>
</tr>
</thead>
<tbody>
<tr ng-if="!retrofitList || retrofitList.length == 0">
<td colspan="5">No Retrofitting changes</td>
</tr>
<tr class="highlight" ng-repeat="item in retrofitList | orderBy:retroPredicate:retroDesc">
<td style="width:1em;">{{item.sellClassRating}}</td>
<td class="le shorten">{{item.sellName}}</td>
<td style="width:1em;">{{item.buyClassRating}}</td>
<td class="le shorten">{{item.buyName}}</td>
<td class="ri" ng-class="item.netCost > 0 ? 'warning' : 'secondary-disabled'">{{ fCrd(item.netCost)}} <u>CR</u></td>
</tr>
</tbody>
</table>
</div>
<table class="total">
<tr class="ri">
<td class="lbl">Cost</td>
<td ng-class="retrofitTotal > 0 ? 'warning' : 'secondary-disabled'">{{fCrd(retrofitTotal)}} <u>CR</u></td>
</tr>
<tr class="ri">
<td class="lbl">Retrofitting from</td>
<td style="padding:0;">
<select style="width: 100%; border: none;" ng-model="$parent.retrofitBuild" ng-change="setRetrofitBase()" ng-options="name as name for (name, build) in allBuilds[ship.id]">
<option value="">Stock / Standard</option>
</select>
</td>
</tr>
</table>
</div>
</div>
<div class="group dbl">
<div class="group half">
<h1>Jump Range</h1>
<div class="cen">
<div area-chart config="jrChart" series="jrSeries"></div>
<div slider max="ship.fuelCapacity" unit="'T'" on-change="::fuelChange(val)" style="position:relative; margin: 0 auto;">
<div line-chart config="jrChart" series="jrSeries"></div>
</div>
<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>
</div>
</div>
</div>

View File

@@ -123,28 +123,28 @@
"class": 1,
"rating": "I",
"cost": 1017200,
"mass": 21
"mass": 4
},
{
"name": "Military Grade Composite",
"class": 1,
"rating": "I",
"cost": 2288600,
"mass": 42
"mass": 8
},
{
"name": "Mirrored Surface Composite",
"class": 1,
"rating": "I",
"cost": 5408800,
"mass": 42
"mass": 8
},
{
"name": "Reactive Surface Composite",
"class": 1,
"rating": "I",
"cost": 5993700,
"mass": 42
"mass": 8
}
],
"cobra_mk_iii": [

View File

@@ -1,27 +1,27 @@
{
"Fuel Transfer Limpet Ctrl": [
{ "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 },
{ "id": "Fi", "grp":"fx", "class":7, "rating":"B", "cost":3499200, "mass":128.0, "power":-0.97, "range":2.04, "maximum": 8 },
{ "id": "Fj", "grp":"fx", "class":7, "rating":"A", "cost":6998400, "mass": 80.0, "power":-0.83, "range":2.38, "maximum": 8 },
{ "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 },
{ "id": "Fi", "grp":"fx", "class":7, "rating":"B", "cost":3499200, "mass":128.0, "power":0.97, "range":2.04, "maximum": 8 },
{ "id": "Fj", "grp":"fx", "class":7, "rating":"A", "cost":6998400, "mass": 80.0, "power":0.83, "range":2.38, "maximum": 8 },
{ "id": "Fa", "grp":"fx", "class":5, "rating":"E", "cost": 48600, "mass": 20.0, "power":-0.40, "range":0.78, "maximum": 4 },
{ "id": "Fb", "grp":"fx", "class":5, "rating":"D", "cost": 97200, "mass": 8.0, "power":-0.30, "range":1.04, "maximum": 4 },
{ "id": "Fc", "grp":"fx", "class":5, "rating":"C", "cost": 194400, "mass": 20.0, "power":-0.50, "range":1.30, "maximum": 4 },
{ "id": "Fd", "grp":"fx", "class":5, "rating":"B", "cost": 388800, "mass": 32.0, "power":-0.97, "range":1.56, "maximum": 4 },
{ "id": "Fe", "grp":"fx", "class":5, "rating":"A", "cost": 777600, "mass": 20.0, "power":-0.60, "range":1.82, "maximum": 4 },
{ "id": "Fa", "grp":"fx", "class":5, "rating":"E", "cost": 48600, "mass": 20.0, "power":0.40, "range":0.78, "maximum": 4 },
{ "id": "Fb", "grp":"fx", "class":5, "rating":"D", "cost": 97200, "mass": 8.0, "power":0.30, "range":1.04, "maximum": 4 },
{ "id": "Fc", "grp":"fx", "class":5, "rating":"C", "cost": 194400, "mass": 20.0, "power":0.50, "range":1.30, "maximum": 4 },
{ "id": "Fd", "grp":"fx", "class":5, "rating":"B", "cost": 388800, "mass": 32.0, "power":0.97, "range":1.56, "maximum": 4 },
{ "id": "Fe", "grp":"fx", "class":5, "rating":"A", "cost": 777600, "mass": 20.0, "power":0.60, "range":1.82, "maximum": 4 },
{ "id": "F5", "grp":"fx", "class":3, "rating":"E", "cost": 5400, "mass": 5.0, "power":-0.27, "range":0.66, "maximum": 2 },
{ "id": "F6", "grp":"fx", "class":3, "rating":"D", "cost": 10800, "mass": 2.0, "power":-0.20, "range":0.88, "maximum": 2 },
{ "id": "F7", "grp":"fx", "class":3, "rating":"C", "cost": 21600, "mass": 5.0, "power":-0.34, "range":1.10, "maximum": 2 },
{ "id": "F8", "grp":"fx", "class":3, "rating":"B", "cost": 43200, "mass": 8.0, "power":-0.48, "range":1.32, "maximum": 2 },
{ "id": "F9", "grp":"fx", "class":3, "rating":"A", "cost": 86400, "mass": 5.0, "power":-0.41, "range":1.54, "maximum": 2 },
{ "id": "F5", "grp":"fx", "class":3, "rating":"E", "cost": 5400, "mass": 5.0, "power":0.27, "range":0.66, "maximum": 2 },
{ "id": "F6", "grp":"fx", "class":3, "rating":"D", "cost": 10800, "mass": 2.0, "power":0.20, "range":0.88, "maximum": 2 },
{ "id": "F7", "grp":"fx", "class":3, "rating":"C", "cost": 21600, "mass": 5.0, "power":0.34, "range":1.10, "maximum": 2 },
{ "id": "F8", "grp":"fx", "class":3, "rating":"B", "cost": 43200, "mass": 8.0, "power":0.48, "range":1.32, "maximum": 2 },
{ "id": "F9", "grp":"fx", "class":3, "rating":"A", "cost": 86400, "mass": 5.0, "power":0.41, "range":1.54, "maximum": 2 },
{ "id": "F0", "grp":"fx", "class":1, "rating":"E", "cost": 600, "mass": 1.3, "power":-0.18, "range":0.60, "maximum": 1 },
{ "id": "F1", "grp":"fx", "class":1, "rating":"D", "cost": 1200, "mass": 0.5, "power":-0.14, "range":0.80, "maximum": 1 },
{ "id": "F2", "grp":"fx", "class":1, "rating":"C", "cost": 2400, "mass": 1.3, "power":-0.23, "range":1.00, "maximum": 1 },
{ "id": "F3", "grp":"fx", "class":1, "rating":"B", "cost": 4800, "mass": 2.0, "power":-0.32, "range":1.20, "maximum": 1 },
{ "id": "F4", "grp":"fx", "class":1, "rating":"A", "cost": 9600, "mass": 1.3, "power":-0.28, "range":1.40, "maximum": 1 }
{ "id": "F0", "grp":"fx", "class":1, "rating":"E", "cost": 600, "mass": 1.3, "power":0.18, "range":0.60, "maximum": 1 },
{ "id": "F1", "grp":"fx", "class":1, "rating":"D", "cost": 1200, "mass": 0.5, "power":0.14, "range":0.80, "maximum": 1 },
{ "id": "F2", "grp":"fx", "class":1, "rating":"C", "cost": 2400, "mass": 1.3, "power":0.23, "range":1.00, "maximum": 1 },
{ "id": "F3", "grp":"fx", "class":1, "rating":"B", "cost": 4800, "mass": 2.0, "power":0.32, "range":1.20, "maximum": 1 },
{ "id": "F4", "grp":"fx", "class":1, "rating":"A", "cost": 9600, "mass": 1.3, "power":0.28, "range":1.40, "maximum": 1 }
]
}

View File

@@ -1,27 +1,27 @@
{
"Prospector Limpet Ctrl": [
{ "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 },
{ "id": "Pi", "grp":"pc", "class":7, "rating":"B", "cost":3499200, "mass":128.0, "power":-0.97, "range":10.20, "maximum": 8 },
{ "id": "Pj", "grp":"pc", "class":7, "rating":"A", "cost":6998400, "mass": 80.0, "power":-0.83, "range":11.90, "maximum": 8 },
{ "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 },
{ "id": "Pi", "grp":"pc", "class":7, "rating":"B", "cost":3499200, "mass":128.0, "power":0.97, "range":10.20, "maximum": 8 },
{ "id": "Pj", "grp":"pc", "class":7, "rating":"A", "cost":6998400, "mass": 80.0, "power":0.83, "range":11.90, "maximum": 8 },
{ "id": "Pa", "grp":"pc", "class":5, "rating":"E", "cost": 48600, "mass": 20.0, "power":-0.40, "range": 3.90, "maximum": 4 },
{ "id": "Pb", "grp":"pc", "class":5, "rating":"D", "cost": 97200, "mass": 8.0, "power":-0.30, "range": 5.20, "maximum": 4 },
{ "id": "Pc", "grp":"pc", "class":5, "rating":"C", "cost": 194400, "mass": 20.0, "power":-0.50, "range": 6.50, "maximum": 4 },
{ "id": "Pd", "grp":"pc", "class":5, "rating":"B", "cost": 388800, "mass": 32.0, "power":-0.97, "range": 7.80, "maximum": 4 },
{ "id": "Pe", "grp":"pc", "class":5, "rating":"A", "cost": 777600, "mass": 20.0, "power":-0.60, "range": 9.10, "maximum": 4 },
{ "id": "Pa", "grp":"pc", "class":5, "rating":"E", "cost": 48600, "mass": 20.0, "power":0.40, "range": 3.90, "maximum": 4 },
{ "id": "Pb", "grp":"pc", "class":5, "rating":"D", "cost": 97200, "mass": 8.0, "power":0.30, "range": 5.20, "maximum": 4 },
{ "id": "Pc", "grp":"pc", "class":5, "rating":"C", "cost": 194400, "mass": 20.0, "power":0.50, "range": 6.50, "maximum": 4 },
{ "id": "Pd", "grp":"pc", "class":5, "rating":"B", "cost": 388800, "mass": 32.0, "power":0.97, "range": 7.80, "maximum": 4 },
{ "id": "Pe", "grp":"pc", "class":5, "rating":"A", "cost": 777600, "mass": 20.0, "power":0.60, "range": 9.10, "maximum": 4 },
{ "id": "P5", "grp":"pc", "class":3, "rating":"E", "cost": 5400, "mass": 5.0, "power":-0.27, "range": 3.30, "maximum": 2 },
{ "id": "P6", "grp":"pc", "class":3, "rating":"D", "cost": 10800, "mass": 2.0, "power":-0.20, "range": 4.40, "maximum": 2 },
{ "id": "P7", "grp":"pc", "class":3, "rating":"C", "cost": 21600, "mass": 5.0, "power":-0.34, "range": 5.50, "maximum": 2 },
{ "id": "P8", "grp":"pc", "class":3, "rating":"B", "cost": 43200, "mass": 8.0, "power":-0.48, "range": 6.60, "maximum": 2 },
{ "id": "P9", "grp":"pc", "class":3, "rating":"A", "cost": 86400, "mass": 5.0, "power":-0.41, "range": 7.70, "maximum": 2 },
{ "id": "P5", "grp":"pc", "class":3, "rating":"E", "cost": 5400, "mass": 5.0, "power":0.27, "range": 3.30, "maximum": 2 },
{ "id": "P6", "grp":"pc", "class":3, "rating":"D", "cost": 10800, "mass": 2.0, "power":0.20, "range": 4.40, "maximum": 2 },
{ "id": "P7", "grp":"pc", "class":3, "rating":"C", "cost": 21600, "mass": 5.0, "power":0.34, "range": 5.50, "maximum": 2 },
{ "id": "P8", "grp":"pc", "class":3, "rating":"B", "cost": 43200, "mass": 8.0, "power":0.48, "range": 6.60, "maximum": 2 },
{ "id": "P9", "grp":"pc", "class":3, "rating":"A", "cost": 86400, "mass": 5.0, "power":0.41, "range": 7.70, "maximum": 2 },
{ "id": "P0", "grp":"pc", "class":1, "rating":"E", "cost": 600, "mass": 1.3, "power":-0.18, "range": 3.00, "maximum": 1 },
{ "id": "P1", "grp":"pc", "class":1, "rating":"D", "cost": 1200, "mass": 0.5, "power":-0.14, "range": 4.00, "maximum": 1 },
{ "id": "P2", "grp":"pc", "class":1, "rating":"C", "cost": 2400, "mass": 1.3, "power":-0.23, "range": 5.00, "maximum": 1 },
{ "id": "P3", "grp":"pc", "class":1, "rating":"B", "cost": 4800, "mass": 2.0, "power":-0.32, "range": 6.00, "maximum": 1 },
{ "id": "P4", "grp":"pc", "class":1, "rating":"A", "cost": 9600, "mass": 1.3, "power":-0.28, "range": 7.00, "maximum": 1 }
{ "id": "P0", "grp":"pc", "class":1, "rating":"E", "cost": 600, "mass": 1.3, "power":0.18, "range": 3.00, "maximum": 1 },
{ "id": "P1", "grp":"pc", "class":1, "rating":"D", "cost": 1200, "mass": 0.5, "power":0.14, "range": 4.00, "maximum": 1 },
{ "id": "P2", "grp":"pc", "class":1, "rating":"C", "cost": 2400, "mass": 1.3, "power":0.23, "range": 5.00, "maximum": 1 },
{ "id": "P3", "grp":"pc", "class":1, "rating":"B", "cost": 4800, "mass": 2.0, "power":0.32, "range": 6.00, "maximum": 1 },
{ "id": "P4", "grp":"pc", "class":1, "rating":"A", "cost": 9600, "mass": 1.3, "power":0.28, "range": 7.00, "maximum": 1 }
]
}

View File

@@ -38,6 +38,7 @@
"grp": "sc",
"name": "Detailed Surface Scanner",
"class": 1,
"retractedOnly": 1,
"rating": "C",
"cost": 250000,
"mass": 1.3,

View File

@@ -10,7 +10,7 @@
"boost": 320,
"agility": 8,
"shields": 60,
"armour": 90,
"armour": 162,
"fuelcost": 50,
"mass": 35
},

View File

@@ -10,7 +10,7 @@
"boost": 240,
"agility": 2,
"shields": 350,
"armour": 525,
"armour": 945,
"fuelcost": 50,
"mass": 400
},

View File

@@ -10,7 +10,7 @@
"boost": 340,
"agility": 6,
"shields": 140,
"armour": 210,
"armour": 378,
"fuelcost": 50,
"mass": 280
},

View File

@@ -10,7 +10,7 @@
"boost": 400,
"agility": 6,
"shields": 80,
"armour": 120,
"armour": 216,
"fuelcost": 50,
"mass": 180
},

View File

@@ -5,16 +5,16 @@
"name": "Diamondback Scout",
"manufacturer": "Lakon",
"class": 1,
"cost": 461312,
"cost": 461342,
"speed": 283,
"boost": 384,
"agility": 8,
"shields": 93,
"shields": 118,
"armour": 216,
"fuelcost": 50,
"mass": 170
},
"retailCost": 564300,
"retailCost": 564330,
"slots": {
"common": [
4,

View File

@@ -5,16 +5,16 @@
"name": "Diamondback Explorer",
"manufacturer": "Lakon",
"class": 1,
"cost": 1740931,
"cost": 1635691,
"speed": 242,
"boost": 316,
"agility": 5,
"shields": 115,
"shields": 146,
"armour": 270,
"fuelcost": 50,
"mass": 298
},
"retailCost": 2000000,
"retailCost": 1894760,
"slots": {
"common": [
4,

View File

@@ -10,7 +10,7 @@
"boost": 350,
"agility": 10,
"shields": 60,
"armour": 40,
"armour": 72,
"fuelcost": 50,
"mass": 50
},

View File

@@ -8,9 +8,9 @@
"cost": 18969990,
"speed": 180,
"boost": 300,
"agility": 0,
"agility": 2,
"shields": 200,
"armour": 300,
"armour": 540,
"fuelcost": 50,
"mass": 580
},

View File

@@ -10,7 +10,7 @@
"boost": 350,
"agility": 6,
"shields": 300,
"armour": 225,
"armour": 405,
"fuelcost": 50,
"mass": 250
},

View File

@@ -10,7 +10,7 @@
"boost": 300,
"agility": 6,
"shields": 50,
"armour": 50,
"armour": 90,
"fuelcost": 50,
"mass": 14
},

View File

@@ -10,7 +10,7 @@
"boost": 380,
"agility": 2,
"shields": 180,
"armour": 270,
"armour": 486,
"fuelcost": 50,
"mass": 400
},

View File

@@ -5,16 +5,16 @@
"name": "Imperial Courier",
"manufacturer": "Gutamaya",
"class": 1,
"cost": 2481521,
"cost": 2481552,
"speed": 277,
"boost": 380,
"agility": 6,
"shields": 230,
"shields": 197,
"armour": 144,
"fuelcost": 50,
"mass": 35
},
"retailCost": 2542900,
"retailCost": 2542931,
"slots": {
"common": [
4,

View File

@@ -10,7 +10,7 @@
"boost": 380,
"agility": 2,
"shields": 220,
"armour": 220,
"armour": 396,
"fuelcost": 50,
"mass": 580
},

View File

@@ -10,7 +10,7 @@
"boost": 280,
"agility": 6,
"shields": 260,
"armour": 260,
"armour": 468,
"fuelcost": 50,
"mass": 350
},

View File

@@ -10,7 +10,7 @@
"boost": 320,
"agility": 8,
"shields": 40,
"armour": 60,
"armour": 108,
"fuelcost": 50,
"mass": 25
},

View File

@@ -10,7 +10,7 @@
"boost": 350,
"agility": 3,
"shields": 90,
"armour": 90,
"armour": 162,
"fuelcost": 50,
"mass": 155
},

View File

@@ -10,7 +10,7 @@
"boost": 300,
"agility": 2,
"shields": 120,
"armour": 120,
"armour": 216,
"fuelcost": 50,
"mass": 420
},

View File

@@ -10,7 +10,7 @@
"boost": 200,
"agility": 0,
"shields": 240,
"armour": 240,
"armour": 432,
"fuelcost": 50,
"mass": 1000
},

View File

@@ -10,7 +10,7 @@
"boost": 400,
"agility": 6,
"shields": 105,
"armour": 70,
"armour": 126,
"fuelcost": 50,
"mass": 60
},

View File

@@ -10,7 +10,7 @@
"boost": 340,
"agility": 9,
"shields": 240,
"armour": 160,
"armour": 288,
"fuelcost": 50,
"mass": 230
},

View File

@@ -140,7 +140,7 @@ gulp.task('generateIndexHTML', function(done) {
gulp.src('app/index.html')
.pipe(template({
version: pkg.version,
date : (new Date()).toLocaleDateString(),
date : new Date().toISOString().slice(0, 10),
uaTracking: process.env.CORIOLIS_UA_TRACKING || false,
svgContent: svgIconsContent,
gapiKey: process.env.CORIOLIS_GAPI_KEY

View File

@@ -1,6 +1,6 @@
{
"name": "coriolis_shipyard",
"version": "0.11.0",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "https://github.com/cmmcleod/coriolis"
@@ -9,33 +9,35 @@
"engine": "node >= 0.12.2",
"dependencies": {},
"devDependencies": {
"angular-mocks": "^1.3.16",
"async": "^0.9.0",
"del": "^1.1.1",
"gulp": "^3.8.11",
"gulp-angular-templatecache": "^1.6.0",
"gulp-concat": "^2.5.2",
"gulp-eslint": "^0.13.2",
"gulp-htmlmin": "^1.1.1",
"gulp-jasmine": "^2.0.1",
"gulp-jsonlint": "^1.0.2",
"gulp-less": "^3.0.2",
"angular-mocks": "1.3.x",
"async": "0.9.x",
"del": "1.2.x",
"gulp": "3.9.x",
"gulp-angular-templatecache": "1.6.x",
"gulp-concat": "2.5.x",
"gulp-eslint": "0.13.x",
"gulp-htmlmin": "1.1.x",
"gulp-jasmine": "2.0.x",
"gulp-jsonlint": "1.1.x",
"gulp-less": "3.0.x",
"gulp-manifest": "0.0.6",
"gulp-minify-css": "^1.0.0",
"gulp-minify-css": "1.1.x",
"gulp-rev-all": "0.8.18",
"gulp-sourcemaps": "^1.5.1",
"gulp-svgmin": "^1.1.2",
"gulp-svgstore": "^5.0.1",
"gulp-template": "^3.0.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.4",
"jasmine-core": "^2.3.4",
"json-concat": "0.0.0",
"karma": "^0.12.36",
"karma-chrome-launcher": "^0.1.12",
"karma-jasmine": "^0.3.5",
"main-bower-files": "^2.6.2",
"run-sequence": "^1.0.2",
"uglify-js": "^2.4.19"
"gulp-sourcemaps": "1.5.x",
"gulp-svgmin": "1.1.x",
"gulp-svgstore": "5.0.x",
"gulp-template": "3.0.x",
"gulp-uglify": "1.2.x",
"gulp-util": "3.0.x",
"jasmine-core": "2.3.x",
"json-concat": "0.0.x",
"karma": "0.12.x",
"karma-jasmine": "0.3.x",
"karma-mocha-reporter": "1.0.x",
"karma-phantomjs-launcher": "0.2.x",
"main-bower-files": "2.8.x",
"phantomjs": "1.9.x",
"run-sequence": "1.1.x",
"uglify-js": "2.4.x"
}
}

View File

@@ -14,21 +14,13 @@ module.exports = function(config) {
'../build/app*.js',
'tests/**/*.js'
],
// list of files to exclude
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'],
reporters: ['mocha'],
port: 9876,
colors: true,
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Chrome'],
browsers: ['PhantomJS'],
singleRun: false
});
};

View File

@@ -0,0 +1,50 @@
describe("Outfit Controller", function() {
beforeEach(module('app'));
var outfitController, scope;
var eventStub = {
preventDefault: function(){ },
stopPropagation: function(){ }
};
beforeEach(inject(function(_$rootScope_, $controller) {
$rootScope = _$rootScope_;
$rootScope.discounts = { ship: 1, components: 1};
$stateParams = { shipId: 'anaconda'};
scope = $rootScope.$new();
outfitController = $controller('OutfitController', { $rootScope: $rootScope, $scope: scope, $stateParams: $stateParams });
}));
describe("Retrofitting Costs", function() {
it("are empty by default", function() {
expect(scope.retrofitTotal).toEqual(0);
expect(scope.retrofitList.length).toEqual(0);
});
it("updates on bulkheads change", function() {
scope.select('b', scope.ship.bulkheads, eventStub, "1"); // Use Reinforced Alloy Bulkheads
expect(scope.retrofitTotal).toEqual(58787780);
expect(scope.retrofitList.length).toEqual(1);
scope.select('b', scope.ship.bulkheads, eventStub, "0"); // Use Reinforced Alloy Bulkheads
expect(scope.retrofitTotal).toEqual(0);
expect(scope.retrofitList.length).toEqual(0);
});
it("updates on component change", function() {
scope.select('h', scope.ship.hardpoints[0], eventStub, "0u"); // 3C/F Beam Laser
expect(scope.retrofitTotal).toEqual(1177600);
expect(scope.retrofitList.length).toEqual(1);
scope.select('h', scope.ship.hardpoints[6], eventStub, "empty"); // Remove default pulse laser
scope.select('h', scope.ship.hardpoints[7], eventStub, "empty"); // Remove default pulse laser
expect(scope.retrofitTotal).toEqual(1173200);
expect(scope.retrofitList.length).toEqual(3);
scope.select('i', scope.ship.internal[3], eventStub, "11"); // Use 6A Auto field maintenance unit
expect(scope.retrofitTotal).toEqual(16478701);
expect(scope.retrofitList.length).toEqual(4);
});
});
});

View File

@@ -1,10 +1,12 @@
describe("Ship Factory", function() {
var Ship;
var Components;
beforeEach(module('shipyard'));
beforeEach(inject(['Ship', function (_Ship_) {
beforeEach(inject(['Ship', 'Components', function (_Ship_, _Components_) {
Ship = _Ship_;
Components = _Components_;
}]));
it("can build all ships", function() {
@@ -31,4 +33,121 @@ describe("Ship Factory", function() {
}
});
});
it("resets and rebuilds properly", function() {
var id = 'cobra_mk_iii';
var cobra = DB.ships[id];
var shipA = 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 buildA = cobra.defaults;
var buildB = {
common:['4A', '4A', '4A', '3D', '3A', '3A', '4C'],
hardpoints: ['0s', '0s', '2d', '2d', 0, '04'],
internal: ['45', '03', '2b', '2o', '27', '53']
};
shipA.buildWith(buildA); // Build A
shipB.buildWith(buildB);// Build B
testShip.buildWith(buildA);
for(var p in testShip) {
expect(testShip[p]).toEqual(shipA[p], p + ' does not match');
}
testShip.buildWith(buildB);
for(var p in testShip) {
expect(testShip[p]).toEqual(shipB[p], p + ' does not match');
}
testShip.buildWith(buildA);
for(var p in testShip) {
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');
});
});