From 59e71232d45fd5125ce493e7a6977c6c4fe595ee Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Mon, 15 Feb 2016 10:41:42 +0100 Subject: [PATCH] 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. --- script/path.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/script/path.js b/script/path.js index 0a5b44a..3d5b776 100644 --- a/script/path.js +++ b/script/path.js @@ -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(); }