From 4032738d577780c0ac82ce06efdc2d386aba217a Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Sun, 14 Feb 2016 02:31:41 +0100 Subject: [PATCH 1/5] Code style Tab in place. --- script/room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/room.js b/script/room.js index d569154..e007ea6 100644 --- a/script/room.js +++ b/script/room.js @@ -750,7 +750,7 @@ var Room = { updateStoresView: function() { var stores = $('div#stores'); - var resources = $('div#resources'); + var resources = $('div#resources'); var special = $('div#special'); var weapons = $('div#weapons'); var needsAppend = false, rNeedsAppend = false, sNeedsAppend = false, wNeedsAppend = false, newRow = false; From 0f8a2ccfb647c15e29e2da854863ab26c580087e Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Sun, 14 Feb 2016 02:39:49 +0100 Subject: [PATCH 2/5] Outfit update on Income A very easy fix indeed. When Path is active, the outfit is updated on Income event. This way the "available" tooltip is reliable, increment/decrement buttons are activated/deactivated correctly and there is no risk of phantom resources. --- script/path.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/script/path.js b/script/path.js index d675672..0b89d23 100644 --- a/script/path.js +++ b/script/path.js @@ -176,11 +176,12 @@ var Path = { for(var k in carryable) { var lk = _(k); var store = carryable[k]; - var have = $SM.get('stores["'+k+'"]'); + var have = $SM.get('stores["'+k+'"]', true); var num = Path.outfit[k]; num = typeof num == 'number' ? num : 0; if (have < num) { num = have; } - var numAvailable = $SM.get('stores["'+k+'"]', true); + $SM.set('outfit["'+k+'"]', num, true); + var row = $('div#outfit_row_' + k.replace(' ', '-'), outfit); if((store.type == 'tool' || store.type == 'weapon') && have > 0) { total += num * Path.getWeight(k); @@ -204,7 +205,7 @@ var Path = { } } else { $('div#' + row.attr('id') + ' > div.row_val > span', outfit).text(num); - $('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(numAvailable - num); + $('div#' + row.attr('id') + ' .tooltip .numAvailable', outfit).text(have - num); } if(num === 0) { $('.dnBtn', row).addClass('disabled'); @@ -213,7 +214,7 @@ var Path = { $('.dnBtn', row).removeClass('disabled'); $('.dnManyBtn', row).removeClass('disabled'); } - if(num >= numAvailable || 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)) { @@ -289,7 +290,6 @@ var Path = { Path.setTitle(); Path.updateOutfitting(); Path.updatePerks(true); - $SM.set('outfit', Path.outfit); Engine.moveStoresView($('#perks'), transition_diff); }, @@ -311,7 +311,9 @@ var Path = { handleStateUpdates: function(e){ if(e.category == 'character' && e.stateName.indexOf('character.perks') === 0 && Engine.activeModule == Path){ Path.updatePerks(); - }; + } else if(e.category == 'income' && Engine.activeModule == Path){ + Path.updateOutfitting(); + } }, scrollSidebar: function(direction, reset){ From 2c2490290c1f2b19af9450325d17212d8bbe6d40 Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Sun, 14 Feb 2016 11:48:27 +0100 Subject: [PATCH 3/5] Leave outfit in place It seems counterintuitive for players that, if the game is closed while exploring, everything remains unchanged but supplies are lost. I had to choose between cooling down Embark, thus making it explicit that it's as if the player had died, or leave supplies in place. I chose the latter. --- script/path.js | 1 - 1 file changed, 1 deletion(-) diff --git a/script/path.js b/script/path.js index 0b89d23..0a5b44a 100644 --- a/script/path.js +++ b/script/path.js @@ -302,7 +302,6 @@ var Path = { for(var k in Path.outfit) { $SM.add('stores["'+k+'"]', -Path.outfit[k]); } - $SM.remove('outfit'); World.onArrival(); $('#outerSlider').animate({left: '-700px'}, 300); Engine.activeModule = World; From 3e51471b0bf3d8520d1f1764ce552bac87e4e1a2 Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Sun, 14 Feb 2016 11:53:29 +0100 Subject: [PATCH 4/5] Remove State outfit on death Supplies are not removed from state when embarking, so they remain in place in case the game is closed during exploration. So it now happens in case of death, along with Path.outfit reset. --- script/world.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script/world.js b/script/world.js index f0f21d9..ec48383 100644 --- a/script/world.js +++ b/script/world.js @@ -851,6 +851,7 @@ var World = { Notifications.notify(World, _('the world fades')); World.state = null; Path.outfit = {}; + $SM.remove('outfit'); $('#outerSlider').animate({opacity: '0'}, 600, 'linear', function() { $('#outerSlider').css('left', '0px'); $('#locationSlider').css('left', '0px'); From 59e71232d45fd5125ce493e7a6977c6c4fe595ee Mon Sep 17 00:00:00 2001 From: Andrea Rendine Date: Mon, 15 Feb 2016 10:41:42 +0100 Subject: [PATCH 5/5] 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(); }