diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 9bf02642129d272dfdab8529fc3ea7e943b9f383..d5a72f024c88436a566ef01a90502c1ca163efc9 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -58,6 +58,8 @@ App.Data.defaultGameStateVariables = { } } }, + /** @type {marketGlobal} */ + market: {}, FSNamePref: 0, HGFormality: 1, HGSeverity: 0, diff --git a/src/arcologyBuilding/markets.js b/src/arcologyBuilding/markets.js index 5495f52d0ef8dc2ff9fb9de7f74f3dbfb3bcf9bb..1c1e7bb8c63cb76c6617894fde743fc3a28f99df 100644 --- a/src/arcologyBuilding/markets.js +++ b/src/arcologyBuilding/markets.js @@ -55,12 +55,10 @@ App.Arcology.Cell.Market = class extends App.Arcology.Cell.BaseCell { "Corporate Market", "Market", () => { - V.market = { - market: "corporate", - slaveMarket: 0, - newSlaves: [], - numArcology: 1 - }; + V.market = new App.Markets.GlobalVariable(); + V.market.slaveMarket = "corporate"; + V.market.newSlaves = []; + V.market.numArcology = 1; V.nextButton = "Back to Main"; V.nextLink = "Main"; V.returnTo = "Main"; diff --git a/src/markets/market.tw b/src/markets/market.tw index db77f0628d9170a2d5140148454e553d8b309e98..d3b884f1beda59d07dd10dd381dea9b29fc48b62 100644 --- a/src/markets/market.tw +++ b/src/markets/market.tw @@ -1,4 +1,4 @@ :: Market [nobr jump-to-safe jump-from-safe] <span id="slave-markets"> - <<includeDOM App.Markets[V.market.market]()>> + <<includeDOM App.Markets[V.market.slaveMarket]()>> </span> \ No newline at end of file diff --git a/src/markets/marketUI.js b/src/markets/marketUI.js index 418685543a36a990a34e1e5d09aea381943ac548..0ac1a7fb6ba61f9762ff3c768e3cdf3c5e4bb293 100644 --- a/src/markets/marketUI.js +++ b/src/markets/marketUI.js @@ -2,14 +2,13 @@ * * @param {string} slaveMarket * @param {object} [param1] - * @param {number} [param1.numArcology] * @param {string} [param1.sTitleSingular] * @param {string} [param1.sTitlePlural] * @param {number} [param1.costMod] */ -App.Markets.purchaseFramework = function(slaveMarket, {numArcology, sTitleSingular = "slave", sTitlePlural = "slaves", costMod = 1} = {}) { +App.Markets.purchaseFramework = function(slaveMarket, {sTitleSingular = "slave", sTitlePlural = "slaves", costMod = 1} = {}) { const el = new DocumentFragment(); - const {slave, text} = generateMarketSlave(slaveMarket, (numArcology || 1)); + const {slave, text} = generateMarketSlave(slaveMarket, (V.market.numArcology || 1)); const cost = getCost(); el.append(text); @@ -138,7 +137,18 @@ App.Markets.purchaseFramework = function(slaveMarket, {numArcology, sTitleSingul } } }; +/** + * @typedef {object} marketGlobal + * @property {string} slaveMarket + * @property {string} introType + * @property {Array} newSlaves + * @property {number} newSlaveIndex + * @property {number} newSlavesDone + * @property {number} numSlaves + * @property {number} numArcology + */ +/** @this {marketGlobal} */ App.Markets.GlobalVariable = function() { this.slaveMarket = ""; this.introType = ""; @@ -147,4 +157,5 @@ App.Markets.GlobalVariable = function() { this.newSlavesDone = 0; this.numSlaves = 0; this.numArcology = 0; + return this; }; diff --git a/src/markets/specificMarkets/slaveMarkets.js b/src/markets/specificMarkets/slaveMarkets.js index fd7f1746554366569540033c269db2e9f6d6cf85..bb9813de0e926b13ba5a405418a9b0f27fa6051b 100644 --- a/src/markets/specificMarkets/slaveMarkets.js +++ b/src/markets/specificMarkets/slaveMarkets.js @@ -192,23 +192,23 @@ App.Markets.raiders = function() { return el; }; -App.Markets.neighbor = function(numArcology) { +App.Markets.neighbor = function() { const el = new DocumentFragment(); let r = []; - r.push(`You're in the area of the slave market that specializes in slaves from within the Free City, viewing slaves from <span class="bold>${V.arcologies[numArcology].name}.</span> Some were trained there, specifically for sale, while others are simply being sold.`); - let _opinion = App.Neighbor.opinion(0, numArcology); + r.push(`You're in the area of the slave market that specializes in slaves from within the Free City, viewing slaves from <span class="bold>${V.arcologies[V.market.numArcology].name}.</span> Some were trained there, specifically for sale, while others are simply being sold.`); + let _opinion = App.Neighbor.opinion(0, V.market.numArcology); let costMod = 1; if (_opinion !== 0) { if (_opinion > 2) { - r.push(`Your cultural ties with ${V.arcologies[numArcology].name} helps keep the price reasonable.`); + r.push(`Your cultural ties with ${V.arcologies[V.market.numArcology].name} helps keep the price reasonable.`); } else if (_opinion < -2) { - r.push(`Your social misalignment with ${V.arcologies[numArcology].name} drives up the price.`); + r.push(`Your social misalignment with ${V.arcologies[V.market.numArcology].name} drives up the price.`); } costMod = (1 - (_opinion * 0.05)); } el.append(r.join(" ")); - el.append(App.Markets.purchaseFramework("neighbor", {numArcology: numArcology, costMod:costMod})); + el.append(App.Markets.purchaseFramework("neighbor", {costMod:costMod})); return el; }; diff --git a/src/markets/theMarket/buySlaves.js b/src/markets/theMarket/buySlaves.js index 79bc801f0eb8fbf5dbfa8d0d605dce8e20665824..4d12ea88bae5fdbc13719287e7992f5b4e41876a 100644 --- a/src/markets/theMarket/buySlaves.js +++ b/src/markets/theMarket/buySlaves.js @@ -67,12 +67,10 @@ App.UI.buySlaves = function() { App.UI.DOM.link( "Slaves from", () => { - V.market = { - market: "neighbor", - slaveMarket: 0, - newSlaves: [], - numArcology: _i - }; + V.market = new App.Markets.GlobalVariable(); + V.market.slaveMarket = "neighbor"; + V.market.newSlaves = []; + V.market.numArcology = _i; updateNav(); }, [], @@ -86,6 +84,7 @@ App.UI.buySlaves = function() { App.UI.DOM.link( "x5", () => { + V.market = new App.Markets.GlobalVariable(); V.market.slaveMarket = "neighbor"; V.market.introType = "bulk"; V.market.numSlaves = 5; @@ -101,7 +100,8 @@ App.UI.buySlaves = function() { App.UI.DOM.link( "x10", () => { - V.slaveMarket = "neighbor"; + V.market = new App.Markets.GlobalVariable(); + V.market.slaveMarket = "neighbor"; V.market.introType = "bulk"; V.market.numSlaves = 10; V.market.numArcology = _i; @@ -149,12 +149,10 @@ App.UI.buySlaves = function() { App.UI.DOM.link( store.title, () => { - V.market = { - market: store.marketType, - slaveMarket: 0, - newSlaves: [], - numArcology: 1 - }; + V.market = new App.Markets.GlobalVariable(); + V.market.slaveMarket = store.marketType; + V.market.newSlaves = []; + V.market.numArcology = 1; updateNav(); }, [], @@ -168,7 +166,8 @@ App.UI.buySlaves = function() { App.UI.DOM.link( `x5`, () => { - V.slaveMarket = store.marketType; + V.market = new App.Markets.GlobalVariable(); + V.market.slaveMarket = store.marketType; V.market.introType = "bulk"; V.market.numSlaves = 5; }, diff --git a/src/uncategorized/bulkSlaveIntro.tw b/src/uncategorized/bulkSlaveIntro.tw index 7315d10c2831e1bfccb666571e1b088844356a1c..5651355cbe855df37efda95182ec058b07cd2b82 100644 --- a/src/uncategorized/bulkSlaveIntro.tw +++ b/src/uncategorized/bulkSlaveIntro.tw @@ -74,16 +74,16 @@ <<goto $returnTo>> <<else>> /* If looking at 2nd slave, push the induction changes for the prior slave to the newSlave array */ - <<if $$market.newSlaveIndex > 0>> + <<if $market.newSlaveIndex > 0>> <<run newSlave($activeSlave)>> <</if>> <<if $market.newSlaves.length > 1>> - Showing new slave <<print $$market.newSlaveIndex+1>> of <<print $market.newSlaves.length>>: + Showing new slave <<print $market.newSlaveIndex+1>> of <<print $market.newSlaves.length>>: <</if>> <br><br> /* Set activeSlave to the desired newSlave so that existing code can be used */ - <<set $activeSlave = $market.newSlaves[$$market.newSlaveIndex]>> + <<set $activeSlave = $market.newSlaves[$market.newSlaveIndex]>> /* Due to possible gingering, the Long Slave Description must be displayed before the New Slave Intro */ /* policies were applied earlier, if needed */ @@ -100,7 +100,7 @@ /* Add an option = goto the next slave below the New Slave Intro section */ <br><br> - <<if $$market.newSlaveIndex < ($market.newSlaves.length - 1)>> + <<if $market.newSlaveIndex < ($market.newSlaves.length - 1)>> [[Next Slave|Bulk Slave Intro]] <<else>> [[Finish introducing slaves|Bulk Slave Intro][$market.newSlavesDone = 1]] @@ -108,4 +108,4 @@ <</if>> /* Closes no new Slaves check */ -<<set $$market.newSlaveIndex++>> +<<set $market.newSlaveIndex++>>