From 82da64f9d8ca7db4440cd7d3d856207fe5dbcf51 Mon Sep 17 00:00:00 2001 From: lowercasedonkey <lowercasedonkey@gmail.com> Date: Wed, 2 Sep 2020 21:00:42 -0400 Subject: [PATCH] move to tw, fix bulk slave --- src/markets/market.tw | 4 +++ src/markets/marketUI.js | 4 ++- .../specificMarkets/householdLiquidator.js | 1 + src/markets/theMarket/buySlaves.js | 29 +++++++++++++++--- src/markets/theMarket/market.js | 30 ------------------- 5 files changed, 33 insertions(+), 35 deletions(-) create mode 100644 src/markets/market.tw diff --git a/src/markets/market.tw b/src/markets/market.tw new file mode 100644 index 00000000000..db77f0628d9 --- /dev/null +++ b/src/markets/market.tw @@ -0,0 +1,4 @@ +:: Market [nobr jump-to-safe jump-from-safe] +<span id="slave-markets"> + <<includeDOM App.Markets[V.market.market]()>> +</span> \ No newline at end of file diff --git a/src/markets/marketUI.js b/src/markets/marketUI.js index 9fcc1ff6083..84c48fd89d9 100644 --- a/src/markets/marketUI.js +++ b/src/markets/marketUI.js @@ -107,6 +107,7 @@ App.Markets.purchaseFramework = function(slaveMarket, {numArcology, sTitleSingul student(); cashX(forceNeg(cost), "slaveTransfer", slave); V.newSlaves.push(slave); + V.newSlaveIndex = 0; }, [], "Bulk Slave Intro" @@ -122,7 +123,8 @@ App.Markets.purchaseFramework = function(slaveMarket, {numArcology, sTitleSingul el, App.UI.DOM.passageLink( title.finish, - "Bulk Slave Intro" + "Bulk Slave Intro", + () => V.newSlaveIndex = 0, ) ); } diff --git a/src/markets/specificMarkets/householdLiquidator.js b/src/markets/specificMarkets/householdLiquidator.js index 83b18263570..57abad8bf06 100644 --- a/src/markets/specificMarkets/householdLiquidator.js +++ b/src/markets/specificMarkets/householdLiquidator.js @@ -118,6 +118,7 @@ App.Markets["Household Liquidator"] = function() { () => { V.newSlaves = _newSlaves; V.newSlaves.forEach((s) => cashX(forceNeg(_totalCost / V.newSlaves.length), "slaveTransfer", s)); + V.newSlaveIndex = 0; }, [], "Bulk Slave Intro" diff --git a/src/markets/theMarket/buySlaves.js b/src/markets/theMarket/buySlaves.js index 041addc710f..dcd140b9d17 100644 --- a/src/markets/theMarket/buySlaves.js +++ b/src/markets/theMarket/buySlaves.js @@ -67,13 +67,16 @@ App.UI.buySlaves = function() { App.UI.DOM.link( "Slaves from", () => { - App.UI.specificMarket({ + V.market = { market: "neighbor", slaveMarket: 0, newSlaves: [], numArcology: _i - }); + }; + updateNav(); }, + [], + "Market" ) ); App.UI.DOM.appendNewElement("span", linkUnit, ` ${V.arcologies[_i].name}`, "bold"); @@ -146,13 +149,16 @@ App.UI.buySlaves = function() { App.UI.DOM.link( store.title, () => { - App.UI.specificMarket({ + V.market = { market: store.marketType, slaveMarket: 0, newSlaves: [], numArcology: 1 - }); + }; + updateNav(); }, + [], + "Market" ) ); } @@ -203,4 +209,19 @@ App.UI.buySlaves = function() { } return el; } + + function updateNav() { + // Sidebar + V.nextButton = "Back"; + V.nextLink = "Buy Slaves"; + V.returnTo = "Buy Slaves"; + V.encyclopedia = "Kidnapped Slaves"; + // Multi-Purchase Support + if (V.newSlaves.length > 0) { + V.nextButton = "Continue"; + V.nextLink = "Bulk Slave Intro"; + V.returnTo = "Main"; + V.newSlaveIndex = 0; + } + } }; diff --git a/src/markets/theMarket/market.js b/src/markets/theMarket/market.js index e93c1bc6cfd..d2194982a35 100644 --- a/src/markets/theMarket/market.js +++ b/src/markets/theMarket/market.js @@ -16,33 +16,3 @@ App.UI.market = function() { return span; }; - -App.UI.specificMarket = function({market, slaveMarket, newSlaves = [], numArcology} = {}) { - const el = new DocumentFragment(); - - // Temp - V.newSlaves = newSlaves; - - // Sidebar - V.nextButton = "Back"; - V.nextLink = "Buy Slaves"; - V.returnTo = "Buy Slaves"; - V.encyclopedia = "Kidnapped Slaves"; - // Multi-Purchase Support - if (newSlaves.length > 0) { - V.nextButton = "Continue"; - V.nextLink = "Bulk Slave Intro"; - V.returnTo = "Main"; - V.newSlaveIndex = 0; - } - - // fake a new passage so we can preserve some persistent data without globals - App.Utils.scheduleSidebarRefresh(); // TODO: not updating back button - window.scrollTo(0, 0); - el.append( - App.Markets[market](numArcology) - ); - - - return jQuery("#slave-markets").empty().append(el); -}; -- GitLab