Minor fixes

For code consistency: in updateSupplies, num is forced to never be greater than have, so the "greater or equal" comparison is pointless
Increase buttons reactivate when total store quantity is greater than supplies.
Also, removed useless nesting of Math.min.
This commit is contained in:
Andrea Rendine
2016-02-15 10:41:42 +01:00
parent 3e51471b0b
commit 59e71232d4
+3 -4
View File
@@ -214,10 +214,10 @@ var Path = {
$('.dnBtn', row).removeClass('disabled');
$('.dnManyBtn', row).removeClass('disabled');
}
if(num >= have || space < Path.getWeight(k)) {
if(num == have || space < Path.getWeight(k)) {
$('.upBtn', row).addClass('disabled');
$('.upManyBtn', row).addClass('disabled');
} else if(space >= Path.getWeight(k)) {
} else {
$('.upBtn', row).removeClass('disabled');
$('.upManyBtn', row).removeClass('disabled');
}
@@ -267,8 +267,7 @@ var Path = {
if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < $SM.get('stores["'+supply+'"]', true)) {
var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply));
var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur;
var maxExtraByBtn = btn.data;
Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore));
Path.outfit[supply] = cur + Math.min(btn.data, maxExtraByWeight, maxExtraByStore);
$SM.set('outfit['+supply+']', Path.outfit[supply]);
Path.updateOutfitting();
}