mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-10 07:05:35 +00:00
Cleaning up jargon and minor code changes
This commit is contained in:
@@ -4,7 +4,6 @@ angular.module('app')
|
||||
$scope.ship = ShipFactory($scope.shipId, DB.ships[$scope.shipId]);
|
||||
$scope.availCS = Components.forShip($scope.shipId);
|
||||
|
||||
|
||||
// for debugging
|
||||
window.ship = $scope.ship;
|
||||
window.availcs = $scope.availCS;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
angular.module('app').directive('componentDetails', [function () {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope:{
|
||||
c: '=',
|
||||
lbl: '=',
|
||||
opts: '='
|
||||
},
|
||||
templateUrl: 'views/component.html'
|
||||
};
|
||||
}]);
|
||||
@@ -9,8 +9,8 @@ angular.module('app')
|
||||
link: function (scope, element, attributes) {
|
||||
scope.$r = $r;
|
||||
|
||||
scope.toggle = function(component) {
|
||||
component.enabled = !component.enabled;
|
||||
scope.toggle = function(slot) {
|
||||
slot.enabled = !slot.enabled;
|
||||
scope.ship.updateTotals();
|
||||
}
|
||||
}
|
||||
|
||||
11
app/js/directives/directive-slot-details.js
Normal file
11
app/js/directives/directive-slot-details.js
Normal file
@@ -0,0 +1,11 @@
|
||||
angular.module('app').directive('slotDetails', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
scope:{
|
||||
c: '=',
|
||||
lbl: '=',
|
||||
opts: '='
|
||||
},
|
||||
templateUrl: 'views/slot.html'
|
||||
};
|
||||
});
|
||||
@@ -1,29 +1,30 @@
|
||||
angular.module('shipyard').factory('components', ['lodash', 'commonMap','commonArray', function (_, CMap) {
|
||||
angular.module('shipyard').factory('components', ['lodash', function (_) {
|
||||
var C = DB.components;
|
||||
|
||||
function ComponentSet(shipId) {
|
||||
var ship = DB.ships[shipId];
|
||||
var maxInternal = ship.componentCapacity.internal[0];
|
||||
var maxInternal = ship.slotCap.internal[0];
|
||||
|
||||
this.mass = ship.mass;
|
||||
this.common = {};
|
||||
this.internal = {};
|
||||
this.hardpoints = filter(C.hardpoints, ship.componentCapacity.hardpoints[0], 0, ship.mass);
|
||||
this.hardpoints = filter(C.hardpoints, ship.slotCap.hardpoints[0], 0, ship.mass);
|
||||
this.bulkheads = C.bulkheads[shipId];
|
||||
this.hpClass = {};
|
||||
this.intClass = {};
|
||||
|
||||
for (var i = 0; i < C.common.length; i ++) {
|
||||
var max = ship.componentCapacity.common[i];
|
||||
var max = ship.slotCap.common[i];
|
||||
switch (i) {
|
||||
// Slots where component class must be equal to slot class
|
||||
case 3: // Life Support
|
||||
case 5: // Sensors
|
||||
this.common[i] = filter(C.common[i], max, max, ship.mass);
|
||||
break;
|
||||
// Other slots can have a component of class lower than the slot class
|
||||
default:
|
||||
this.common[i] = filter(C.common[i], max, 0, ship.mass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(var g in C.internal) {
|
||||
@@ -54,9 +55,7 @@ angular.module('shipyard').factory('components', ['lodash', 'commonMap','commonA
|
||||
function filter (data, maxClass, minClass, mass) {
|
||||
var set = {};
|
||||
_.forEach(data, function (c,id) {
|
||||
if (c.class <= maxClass && c.class >= minClass
|
||||
&& (c.maxmass === undefined || mass <= c.maxmass) ) {
|
||||
//&& (c.minmass === undefined || mass >= c.minmass) ) { // Min mass needs fixed
|
||||
if (c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass) ) {
|
||||
set[id] = c;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
|
||||
angular.forEach(shipData,function(o,k){
|
||||
if(typeof o != 'object') {
|
||||
this[k] = o;
|
||||
} else if (k == 'componentCapacity') {
|
||||
} else if (k == 'slotCap') {
|
||||
angular.forEach(o,function(arr,g){
|
||||
this[g] = [];
|
||||
for(var i = 0; i < arr.length; i++){
|
||||
|
||||
Reference in New Issue
Block a user