Cleaning up jargon and minor code changes

This commit is contained in:
Colin McLeod
2015-04-16 19:44:39 -07:00
parent aad4600326
commit 11e5c138dc
30 changed files with 67 additions and 60 deletions

View File

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

View File

@@ -1,11 +0,0 @@
angular.module('app').directive('componentDetails', [function () {
return {
restrict: 'E',
scope:{
c: '=',
lbl: '=',
opts: '='
},
templateUrl: 'views/component.html'
};
}]);

View File

@@ -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();
}
}

View File

@@ -0,0 +1,11 @@
angular.module('app').directive('slotDetails', function () {
return {
restrict: 'A',
scope:{
c: '=',
lbl: '=',
opts: '='
},
templateUrl: 'views/slot.html'
};
});

View File

@@ -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;
}
});

View File

@@ -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++){

View File

@@ -1,5 +1,5 @@
.component-group {
.slot-group {
border: 2px solid @border;
.border-radius(5px);
margin: 5px;
@@ -16,7 +16,7 @@
color: @warning;
}
.component {
.slot {
text-transform: uppercase;
float: left;
margin: 1%;
@@ -24,7 +24,7 @@
.border-radius(2px);
width: 250px;
position: relative;
padding-top: 3px;
padding: 3px;
color: #BBB;
font-size: 0.8em;
@@ -35,12 +35,10 @@
.lbl {
float: left;
margin-left: 5px;
}
.cla {
float: right;
margin-right: 5px;
}
.clear {

View File

@@ -6,7 +6,7 @@
float: left;
.list-item {
cursor: pointer;
clear: both;
overflow: hidden;
margin: 3px 0px;
@@ -28,6 +28,10 @@
color: grey;
width: 300px;
.list-item {
cursor: pointer;
}
.enabled {
color: #FFF;
}
@@ -42,6 +46,10 @@
color: #FFF;
}
.consumer {
cursor: pointer;
}
.consumer.enabled {
color: @fg;
}

View File

@@ -18,7 +18,7 @@
}
#standard {
width: 260px;
width: 265px;
}
#internal {

View File

@@ -1,5 +1,8 @@
<div ng-repeat="c in ship.common" ng-if="c.c.power || c.c.pGen" class="list-item common" ng-class="{enabled:c.enabled, consumer:c.c.power}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.power(c.c.power || c.c.pGen)}}</div>
<div ng-if="ship.common[0].c.pGen" class="list-item common enabled">
<div class="lbl">{{ship.common[0].c.class}}{{ship.common[0].c.rating}} {{$r.CArr[0]}}</div><div class="val">{{$r.power(ship.common[0].c.pGen)}}</div>
</div>
<div ng-repeat="c in ship.common" ng-if="c.c.power" class="list-item common" ng-class="{enabled:c.enabled, consumer:c.c.power}" ng-click="toggle(c)">
<div class="lbl">{{c.c.class}}{{c.c.rating}} {{$r.CArr[$index]}}</div><div class="val">{{$r.power(c.c.power)}}</div>
</div>
<div class="list-item common consumer" ng-class="{enabled:ship.cargoScoop.enabled}" ng-click="toggle(ship.cargoScoop)">
<div class="lbl">1H Cargo Scoop</div><div class="val">{{$r.power(ship.cargoScoop.c.power)}}</div>

View File

@@ -13,9 +13,9 @@
<div>Pad Size: {{['','Small','Medium','Large'][ship.class]}}</div>
</fieldset>
<fieldset id="standard" class="component-group">
<fieldset id="standard" class="slot-group">
<legend>Standard</legend>
<div class="component">
<div class="slot">
<div class="lbl">Bulkheads</div>
<div class="clear">{{ship.bulkheads.c.name}}
<div class="cla">{{ship.bulkheads.c.mass}}T</div>
@@ -24,24 +24,24 @@
<div class="c" ng-repeat="b in availCS.bulkheads" ng-click="ship.use(ship.bulkheads,$index,b)">{{b.name}}</div>
</div>
</div>
<div class="component" ng-repeat="c in ship.common">
<component-details c="c" lbl="CArr[$index]"></component-details>
<div class="slot" ng-repeat="c in ship.common">
<div slot-details c="c" lbl="CArr[$index]"></div>
<div component-select class="select" c="c" ship="ship" opts="availCS.common[$index]"></div>
</div>
</fieldset>
<fieldset id="hardpoints" class="component-group">
<fieldset id="hardpoints" class="slot-group">
<legend>HardPoints</legend>
<div class="component" ng-repeat="h in ship.hardpoints">
<component-details c="h" lbl="HPC[h.maxClass]"></component-details>
<div class="slot" ng-repeat="h in ship.hardpoints">
<div slot-details c="h" lbl="HPC[h.maxClass]"></div>
<div component-select class="select" c="h" ship="ship" opts="availCS.getHps(h.maxClass)"></div>
</div>
</fieldset>
<fieldset id="internal" class="component-group">
<fieldset id="internal" class="slot-group">
<legend>Internal Compartments</legend>
<div class="component" ng-repeat="i in ship.internal">
<component-details c="i" lbl="'FIX'"></component-details>
<div class="slot" ng-repeat="i in ship.internal">
<div slot-details c="i" lbl="'FIX'"></div>
<div class="select">
<div ng-repeat="(grp, data) in availCS.getInts(i.maxClass)">
<div class="select-group">{{grp}}</div>

View File

@@ -2,5 +2,5 @@
<div class="cla">{{c.maxClass}}</div>
<div class="clear">
{{c.c.class}}{{c.c.rating}}
<div class="cla">{{c.c.mass || c.c.capacity}}T</div>
<div class="cla" ng-if="c.c">{{c.c.mass || c.c.capacity}}T</div>
</div>

View File

@@ -11,7 +11,7 @@
"shields": 60,
"armour": 90,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
3,
3,

View File

@@ -11,7 +11,7 @@
"shields": 350,
"armour": 525,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
8,
7,

View File

@@ -11,7 +11,7 @@
"shields": 140,
"armour": 210,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
5,
5,

View File

@@ -11,7 +11,7 @@
"shields": 80,
"armour": 120,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
4,
4,

View File

@@ -11,7 +11,7 @@
"shields": 60,
"armour": 40,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
2,
3,

View File

@@ -11,7 +11,7 @@
"shields": 200,
"armour": 300,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
6,
6,

View File

@@ -11,7 +11,7 @@
"shields": 300,
"armour": 225,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
5,
5,

View File

@@ -11,7 +11,7 @@
"shields": 50,
"armour": 50,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
2,
2,

View File

@@ -11,7 +11,7 @@
"shields": 180,
"armour": 270,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
6,
6,

View File

@@ -11,7 +11,7 @@
"shields": 220,
"armour": 220,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
5,
6,

View File

@@ -11,7 +11,7 @@
"shields": 260,
"armour": 260,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
7,
6,

View File

@@ -11,7 +11,7 @@
"shields": 40,
"armour": 60,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
2,
2,

View File

@@ -11,7 +11,7 @@
"shields": 90,
"armour": 90,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
3,
4,

View File

@@ -11,7 +11,7 @@
"shields": 120,
"armour": 120,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
4,
5,

View File

@@ -11,7 +11,7 @@
"shields": 240,
"armour": 240,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
6,
7,

View File

@@ -11,7 +11,7 @@
"shields": 105,
"armour": 70,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
3,
3,

View File

@@ -11,7 +11,7 @@
"shields": 240,
"armour": 160,
"fuelcost": 50,
"componentCapacity": {
"slotCap": {
"common": [
4,
5,