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.ship = ShipFactory($scope.shipId, DB.ships[$scope.shipId]);
$scope.availCS = Components.forShip($scope.shipId); $scope.availCS = Components.forShip($scope.shipId);
// for debugging // for debugging
window.ship = $scope.ship; window.ship = $scope.ship;
window.availcs = $scope.availCS; 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) { link: function (scope, element, attributes) {
scope.$r = $r; scope.$r = $r;
scope.toggle = function(component) { scope.toggle = function(slot) {
component.enabled = !component.enabled; slot.enabled = !slot.enabled;
scope.ship.updateTotals(); 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; var C = DB.components;
function ComponentSet(shipId) { function ComponentSet(shipId) {
var ship = DB.ships[shipId]; var ship = DB.ships[shipId];
var maxInternal = ship.componentCapacity.internal[0]; var maxInternal = ship.slotCap.internal[0];
this.mass = ship.mass; this.mass = ship.mass;
this.common = {}; this.common = {};
this.internal = {}; 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.bulkheads = C.bulkheads[shipId];
this.hpClass = {}; this.hpClass = {};
this.intClass = {}; this.intClass = {};
for (var i = 0; i < C.common.length; i ++) { for (var i = 0; i < C.common.length; i ++) {
var max = ship.componentCapacity.common[i]; var max = ship.slotCap.common[i];
switch (i) { switch (i) {
// Slots where component class must be equal to slot class
case 3: // Life Support case 3: // Life Support
case 5: // Sensors case 5: // Sensors
this.common[i] = filter(C.common[i], max, max, ship.mass); this.common[i] = filter(C.common[i], max, max, ship.mass);
break; break;
// Other slots can have a component of class lower than the slot class
default: default:
this.common[i] = filter(C.common[i], max, 0, ship.mass); this.common[i] = filter(C.common[i], max, 0, ship.mass);
} }
} }
for(var g in C.internal) { for(var g in C.internal) {
@@ -54,9 +55,7 @@ angular.module('shipyard').factory('components', ['lodash', 'commonMap','commonA
function filter (data, maxClass, minClass, mass) { function filter (data, maxClass, minClass, mass) {
var set = {}; var set = {};
_.forEach(data, function (c,id) { _.forEach(data, function (c,id) {
if (c.class <= maxClass && c.class >= minClass if (c.class <= maxClass && c.class >= minClass && (c.maxmass === undefined || mass <= c.maxmass) ) {
&& (c.maxmass === undefined || mass <= c.maxmass) ) {
//&& (c.minmass === undefined || mass >= c.minmass) ) { // Min mass needs fixed
set[id] = c; set[id] = c;
} }
}); });

View File

@@ -15,7 +15,7 @@ angular.module('shipyard').factory('ShipFactory', ['components', 'lodash', funct
angular.forEach(shipData,function(o,k){ angular.forEach(shipData,function(o,k){
if(typeof o != 'object') { if(typeof o != 'object') {
this[k] = o; this[k] = o;
} else if (k == 'componentCapacity') { } else if (k == 'slotCap') {
angular.forEach(o,function(arr,g){ angular.forEach(o,function(arr,g){
this[g] = []; this[g] = [];
for(var i = 0; i < arr.length; i++){ for(var i = 0; i < arr.length; i++){

View File

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

View File

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

View File

@@ -18,7 +18,7 @@
} }
#standard { #standard {
width: 260px; width: 265px;
} }
#internal { #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 ng-if="ship.common[0].c.pGen" class="list-item common enabled">
<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 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>
<div class="list-item common consumer" ng-class="{enabled:ship.cargoScoop.enabled}" ng-click="toggle(ship.cargoScoop)"> <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> <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> <div>Pad Size: {{['','Small','Medium','Large'][ship.class]}}</div>
</fieldset> </fieldset>
<fieldset id="standard" class="component-group"> <fieldset id="standard" class="slot-group">
<legend>Standard</legend> <legend>Standard</legend>
<div class="component"> <div class="slot">
<div class="lbl">Bulkheads</div> <div class="lbl">Bulkheads</div>
<div class="clear">{{ship.bulkheads.c.name}} <div class="clear">{{ship.bulkheads.c.name}}
<div class="cla">{{ship.bulkheads.c.mass}}T</div> <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 class="c" ng-repeat="b in availCS.bulkheads" ng-click="ship.use(ship.bulkheads,$index,b)">{{b.name}}</div>
</div> </div>
</div> </div>
<div class="component" ng-repeat="c in ship.common"> <div class="slot" ng-repeat="c in ship.common">
<component-details c="c" lbl="CArr[$index]"></component-details> <div slot-details c="c" lbl="CArr[$index]"></div>
<div component-select class="select" c="c" ship="ship" opts="availCS.common[$index]"></div> <div component-select class="select" c="c" ship="ship" opts="availCS.common[$index]"></div>
</div> </div>
</fieldset> </fieldset>
<fieldset id="hardpoints" class="component-group"> <fieldset id="hardpoints" class="slot-group">
<legend>HardPoints</legend> <legend>HardPoints</legend>
<div class="component" ng-repeat="h in ship.hardpoints"> <div class="slot" ng-repeat="h in ship.hardpoints">
<component-details c="h" lbl="HPC[h.maxClass]"></component-details> <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 component-select class="select" c="h" ship="ship" opts="availCS.getHps(h.maxClass)"></div>
</div> </div>
</fieldset> </fieldset>
<fieldset id="internal" class="component-group"> <fieldset id="internal" class="slot-group">
<legend>Internal Compartments</legend> <legend>Internal Compartments</legend>
<div class="component" ng-repeat="i in ship.internal"> <div class="slot" ng-repeat="i in ship.internal">
<component-details c="i" lbl="'FIX'"></component-details> <div slot-details c="i" lbl="'FIX'"></div>
<div class="select"> <div class="select">
<div ng-repeat="(grp, data) in availCS.getInts(i.maxClass)"> <div ng-repeat="(grp, data) in availCS.getInts(i.maxClass)">
<div class="select-group">{{grp}}</div> <div class="select-group">{{grp}}</div>

View File

@@ -2,5 +2,5 @@
<div class="cla">{{c.maxClass}}</div> <div class="cla">{{c.maxClass}}</div>
<div class="clear"> <div class="clear">
{{c.c.class}}{{c.c.rating}} {{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> </div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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