mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
Total Range chart feature added
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
node_js:
|
node_js:
|
||||||
- "0.12"
|
- "0.12"
|
||||||
before_script:
|
before_script:
|
||||||
- npm install -g gulp
|
- npm install -g gulp
|
||||||
- npm install -g bower
|
- npm install -g bower
|
||||||
- npm install
|
|
||||||
- bower install
|
- bower install
|
||||||
script:
|
script:
|
||||||
- gulp lint
|
- gulp lint
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
angular.module('app').controller('OutfitController', ['$window', '$rootScope', '$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', function($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist) {
|
angular.module('app').controller('OutfitController', ['$window', '$rootScope', '$scope', '$state', '$stateParams', 'ShipsDB', 'Ship', 'Components', 'Serializer', 'Persist', 'calcTotalRange', function($window, $rootScope, $scope, $state, $p, Ships, Ship, Components, Serializer, Persist, calcTotalRange) {
|
||||||
var data = Ships[$p.shipId]; // Retrieve the basic ship properties, slots and defaults
|
var data = Ships[$p.shipId]; // Retrieve the basic ship properties, slots and defaults
|
||||||
var ship = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship instance
|
var ship = new Ship($p.shipId, data.properties, data.slots); // Create a new Ship instance
|
||||||
var win = angular.element($window); // Angularized window object for event triggering
|
var win = angular.element($window); // Angularized window object for event triggering
|
||||||
@@ -39,8 +39,7 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
$scope.jrSeries = {
|
$scope.jrSeries = {
|
||||||
xMin: 0,
|
xMin: 0,
|
||||||
xMax: ship.cargoCapacity,
|
xMax: ship.cargoCapacity,
|
||||||
// Slightly higher than actual based bacuse components are excluded
|
yMax: ship.unladenRange,
|
||||||
yMax: ship.jumpRangeWithMass(ship.unladenMass),
|
|
||||||
yMin: 0,
|
yMin: 0,
|
||||||
func: function(cargo) { // X Axis is Cargo
|
func: function(cargo) { // X Axis is Cargo
|
||||||
return ship.jumpRangeWithMass(ship.unladenMass + $scope.fuel + cargo, $scope.fuel);
|
return ship.jumpRangeWithMass(ship.unladenMass + $scope.fuel + cargo, $scope.fuel);
|
||||||
@@ -60,6 +59,29 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
watch: $scope.fsd
|
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'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: $scope.fsd
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 'Opens' a select for component selection.
|
* 'Opens' a select for component selection.
|
||||||
*
|
*
|
||||||
@@ -120,16 +142,12 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
* Strip ship to D-class and no other components.
|
* Strip ship to D-class and no other components.
|
||||||
*/
|
*/
|
||||||
$scope.stripBuild = function() {
|
$scope.stripBuild = function() {
|
||||||
angular.forEach(ship.common, function(slot,i) {
|
ship.common.forEach(function(slot) {
|
||||||
id = slot.maxClass+'D';
|
var id = slot.maxClass + 'D';
|
||||||
ship.use(slot, id, Components.common(ship.common.indexOf(slot), id));
|
ship.use(slot, id, Components.common(ship.common.indexOf(slot), id));
|
||||||
});
|
});
|
||||||
angular.forEach(ship.hardpoints, function(slot,i) {
|
ship.hardpoints.forEach(function(slot) { ship.use(slot, null, null); });
|
||||||
ship.use(slot, null, null);
|
ship.internal.forEach(function(slot) { ship.use(slot, null, null); });
|
||||||
});
|
|
||||||
angular.forEach(ship.internal, function(slot,i) {
|
|
||||||
ship.use(slot, null, null);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,9 +250,9 @@ angular.module('app').controller('OutfitController', ['$window', '$rootScope', '
|
|||||||
|
|
||||||
function updateState() {
|
function updateState() {
|
||||||
$state.go('outfit', { shipId: ship.id, code: $scope.code, bn: $scope.buildName }, { location: 'replace', notify: false });
|
$state.go('outfit', { shipId: ship.id, code: $scope.code, bn: $scope.buildName }, { location: 'replace', notify: false });
|
||||||
$scope.jrSeries.xMax = ship.cargoCapacity;
|
$scope.trSeries.xMax = $scope.jrSeries.xMax = ship.cargoCapacity;
|
||||||
$scope.jrSeries.yMax = ship.jumpRangeWithMass(ship.unladenMass);
|
$scope.jrSeries.yMax = ship.unladenRange;
|
||||||
$scope.jrSeries.mass = ship.unladenMass;
|
$scope.trSeries.yMax = ship.unladenTotalRange;
|
||||||
win.triggerHandler('pwrchange');
|
win.triggerHandler('pwrchange');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, _) {
|
angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength', 'calcJumpRange', 'calcTotalRange', 'lodash', function(Components, calcShieldStrength, calcJumpRange, calcTotalRange, _) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the power usage type of a slot and it's particular component
|
* Returns the power usage type of a slot and it's particular component
|
||||||
@@ -358,24 +358,13 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
|||||||
* Jump Range and total range calculations
|
* Jump Range and total range calculations
|
||||||
*/
|
*/
|
||||||
Ship.prototype.updateJumpStats = function() {
|
Ship.prototype.updateJumpStats = function() {
|
||||||
var fsd = this.common[2].c; // Frame Shift Drive;
|
var fsd = this.common[2].c; // Frame Shift Drive;
|
||||||
var fuelRemaining = this.fuelCapacity % fsd.maxfuel; // Fuel left after making N max jumps
|
|
||||||
var jumps = this.fuelCapacity / fsd.maxfuel;
|
|
||||||
this.unladenRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd, this.fuelCapacity); // Include fuel weight for jump
|
this.unladenRange = calcJumpRange(this.unladenMass + fsd.maxfuel, fsd, this.fuelCapacity); // Include fuel weight for jump
|
||||||
this.fullTankRange = calcJumpRange(this.unladenMass + this.fuelCapacity, fsd, this.fuelCapacity); // Full Tanke
|
this.fullTankRange = calcJumpRange(this.unladenMass + this.fuelCapacity, fsd, this.fuelCapacity); // Full Tanke
|
||||||
this.ladenRange = calcJumpRange(this.ladenMass, fsd, this.fuelCapacity);
|
this.ladenRange = calcJumpRange(this.ladenMass, fsd, this.fuelCapacity);
|
||||||
this.maxJumpCount = Math.ceil(jumps); // Number of full fuel jumps + final jump to empty tank
|
this.unladenTotalRange = calcTotalRange(this.unladenMass, fsd, this.fuelCapacity);
|
||||||
|
this.ladenTotalRange = calcTotalRange(this.unladenMass + this.cargoCapacity, fsd, this.fuelCapacity);
|
||||||
// Going backwards, start with the last jump using the remaining fuel
|
this.maxJumpCount = Math.ceil(this.fuelCapacity / fsd.maxfuel);
|
||||||
this.unladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + fuelRemaining, fsd, fuelRemaining) : 0;
|
|
||||||
this.ladenTotalRange = fuelRemaining > 0 ? calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd, fuelRemaining) : 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;
|
|
||||||
this.unladenTotalRange += calcJumpRange(this.unladenMass + fuelRemaining, fsd);
|
|
||||||
this.ladenTotalRange += calcJumpRange(this.unladenMass + this.cargoCapacity + fuelRemaining, fsd);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return Ship;
|
return Ship;
|
||||||
|
|||||||
@@ -175,6 +175,50 @@ angular.module('shipyard', ['ngLodash'])
|
|||||||
*/
|
*/
|
||||||
.value('calcJumpRange', function(mass, fsd, fuel) {
|
.value('calcJumpRange', function(mass, fsd, fuel) {
|
||||||
return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
return Math.pow(Math.min(fuel === undefined ? fsd.maxfuel : fuel, fsd.maxfuel) / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Calculate the maximum single jump range based on mass and a specific FSD
|
||||||
|
*
|
||||||
|
* @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 Optional - The fuel consumed during the jump (must be less than the drives max fuel per jump)
|
||||||
|
* @return {number} Distance in Light Years
|
||||||
|
*/
|
||||||
|
.value('calcTotalRangev1', 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 = Math.floor(jumps); j >= 0; j--) {
|
||||||
|
fuelRemaining += fsd.maxfuel;
|
||||||
|
totalRange += Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||||
|
}
|
||||||
|
return totalRange;
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* Calculate the maximum single jump range based on mass and a specific FSD
|
||||||
|
*
|
||||||
|
* @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 Optional - The fuel consumed during the jump (must be less than the drives max fuel per jump)
|
||||||
|
* @return {number} Distance in Light Years
|
||||||
|
*/
|
||||||
|
.value('calcTotalRange', function(mass, fsd, fuel) {
|
||||||
|
var maxfuel = fsd.maxfuel;
|
||||||
|
var maxJumpCount = Math.floor(fuel / maxfuel);
|
||||||
|
var fuelRemaining = fuel % maxfuel;
|
||||||
|
var jumpCoefficient = Math.pow(fsd.maxfuel / fsd.fuelmul, 1 / fsd.fuelpower);
|
||||||
|
|
||||||
|
mass += fuelRemaining;
|
||||||
|
|
||||||
|
var massCoefficient = (fsd.optmass / maxfuel) * (Math.log(mass + (maxJumpCount * maxfuel)) - Math.log(mass));
|
||||||
|
var totalDistance = (jumpCoefficient * massCoefficient);
|
||||||
|
if (fuelRemaining > 0) {
|
||||||
|
totalDistance += Math.pow(fuelRemaining / fsd.fuelmul, 1 / fsd.fuelpower ) * fsd.optmass / mass;
|
||||||
|
}
|
||||||
|
return totalDistance;
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.
|
* Calculate the a ships shield strength based on mass, shield generator and shield boosters used.
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ table.total {
|
|||||||
|
|
||||||
#componentPriority {
|
#componentPriority {
|
||||||
.tablet({
|
.tablet({
|
||||||
text.primary, text.warning, text.primary-bg {
|
text.primary, text.warning, text.primary-bg, text.secondary {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -266,11 +266,17 @@
|
|||||||
|
|
||||||
<div class="group dbl">
|
<div class="group dbl">
|
||||||
<h1>Jump Range</h1>
|
<h1>Jump Range</h1>
|
||||||
<div class="cen">
|
<div area-chart config="jrChart" series="jrSeries"></div>
|
||||||
<div area-chart config="jrChart" series="jrSeries"></div>
|
</div>
|
||||||
<div slider max="ship.fuelCapacity" unit="'T'" on-change="::fuelChange(val)" style="position:relative; margin: 0 auto;">
|
|
||||||
|
<div class="group dbl">
|
||||||
|
<h1>Total Range</h1>
|
||||||
|
<div area-chart config="trChart" series="trSeries"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="group dbl">
|
||||||
|
<div slider max="ship.fuelCapacity" unit="'T'" on-change="::fuelChange(val)" style="position:relative; margin: 0 auto;">
|
||||||
<svg class="icon xl primary-disabled" style="position:absolute;height: 100%;"><use xlink:href="#fuel"></use></svg>
|
<svg class="icon xl primary-disabled" style="position:absolute;height: 100%;"><use xlink:href="#fuel"></use></svg>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user