diff --git a/src/Corporation/corporateMarket.tw b/src/Corporation/corporateMarket.tw index 285a7aece6d72f6d7d9afe4a1961dc30489d7f21..0fcb02f061b6bbebacfa73b1cbdcbee8ead24da6 100644 --- a/src/Corporation/corporateMarket.tw +++ b/src/Corporation/corporateMarket.tw @@ -106,8 +106,7 @@ while you browse. <<set _slaveCost = 500*Math.trunc(_slaveCost/500)>> The offered price is <<print cashFormat(_slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>> <br> -<<setLocalPronouns $activeSlave>> -<<buyingFromMarketControls>> +<<includeDOM App.UI.buyingFromMarketControls($activeSlave, _slaveCost)>> <<link "End corporate slave sales here and return this sector to standard markets">> <<set $corp.Market = 0>> diff --git a/src/markets/marketUI.js b/src/markets/marketUI.js new file mode 100644 index 0000000000000000000000000000000000000000..bb31c710d373d371b56b1f11d91b68c7b1f5e75d --- /dev/null +++ b/src/markets/marketUI.js @@ -0,0 +1,82 @@ +App.UI.buyingFromMarketControls = function(slave, slaveCost) { + const {him, his} = getPronouns(slave); + const el = document.createElement("p"); + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Decline to purchase ${him} and check out another slave`, + () => { + V.slavesSeen += 1; + }, + [], + passage() + ) + ); + if (V.cash >= slaveCost) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${him} and check out other slaves to order`, + () => { + cashX(forceNeg(slaveCost), "slaveTransfer", slave); + V.newSlaves.push(slave); + V.introType = "multi"; + V.slavesSeen += 1; + }, + [], + passage() + ) + ); + if (V.newSlaves.length === 0) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${his} slave contract`, + () => { + cashX(forceNeg(slaveCost), "slaveTransfer", slave); + V.newSlaves.push(slave); + V.nextButton = "Continue"; + V.nextLink = "AS Dump"; + V.returnTo = "Main"; + }, + [], + passage() + ) + ); + } else { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${him} and finish your order of slaves`, + () => { + cashX(forceNeg(_slaveCost), "slaveTransfer", slave); + V.newSlaves.push(slave); + }, + [], + "Bulk Slave Intro" + ) + ); + } + } else { + App.UI.DOM.appendNewElement("span", el, `You lack the necessary funds to buy this slave.`, "note"); + } + if (V.newSlaves.length > 0) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Finish your order of slaves`, + () => { }, + [], + "Bulk Slave Intro" + ) + ); + } + + el.append(App.Desc.longSlave(V.activeSlave, {market: V.slaveMarket})); + return el; +}; diff --git a/src/pregmod/wetwareCPUs.tw b/src/pregmod/wetwareCPUs.tw index b99cc1d29c56622cd5e615b480b58ac84d3e173f..f467247b81a6c6b19bbda79a30d245747360df58 100644 --- a/src/pregmod/wetwareCPUs.tw +++ b/src/pregmod/wetwareCPUs.tw @@ -19,5 +19,4 @@ <br><br>The price is <<print cashFormat(_slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>> -<<setLocalPronouns $activeSlave>> -<<buyingFromMarketControls>> +<<includeDOM App.UI.buyingFromMarketControls($activeSlave, _slaveCost)>> diff --git a/src/uncategorized/slaveMarkets.tw b/src/uncategorized/slaveMarkets.tw index a3dd396b858fb36c1695515b77c1adee4e08aba9..d3976e658ca0a271c53dc2efd287ad091db5cc9a 100644 --- a/src/uncategorized/slaveMarkets.tw +++ b/src/uncategorized/slaveMarkets.tw @@ -183,5 +183,4 @@ You visit the slave markets off the arcology plaza. It's always preferable to ex <<set _slaveCost = 500*Math.trunc(_slaveCost/500)>> The offered price is <<print cashFormat(_slaveCost)>>.<<if $slavesSeen > $slaveMarketLimit>> You have cast such a wide net for slaves this week that it is becoming more expensive to find more for sale. Your reputation helps determine your reach within the slave market.<</if>> -<<setLocalPronouns $activeSlave>> -<<buyingFromMarketControls>> +<<includeDOM App.UI.buyingFromMarketControls($activeSlave, _slaveCost)>> diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw index c8b4198ca34174e87068c71198e19b0eb872dd48..a5f750d8e5e63c400eb005c629fd4e7d67b727ad 100644 --- a/src/utility/slaveCreationWidgets.tw +++ b/src/utility/slaveCreationWidgets.tw @@ -772,30 +772,6 @@ <</switch>> <</widget>> -/% - % Shows controls for buying and advancing the queue for buying slaves from a school - % Arguments: none - % Call as <<buyingFromMarketControls>> - %/ -<<widget "buyingFromMarketControls">> -<br>[["Decline to purchase " + $him + " and check out another slave"|passage()][$slavesSeen += 1]] -<<if $cash >= _slaveCost>> - <br>[["Buy " + $him + " and check out other slaves to order"|passage()][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave),$newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]] - <<if $newSlaves.length == 0>> - <br>[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave),$nextButton = "Continue",$nextLink = "AS Dump",$returnTo = "Main"]] - <<else>> - <br>[["Buy " + $him + " and finish your order of slaves"|Bulk Slave Intro][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave), $newSlaves.push($activeSlave)]] - <</if>> -<<else>> - <br>//You lack the necessary funds to buy this slave.// -<</if>> -<<if $newSlaves.length > 0>> - <br>[[Finish your order of slaves|Bulk Slave Intro]] -<</if>> -<br><br> -<<includeDOM App.Desc.longSlave(V.activeSlave, {market: V.slaveMarket})>> -<</widget>> - /% % Shows controls for buying and advancing the queue for buying slaves from a school % Arguments: