diff --git a/src/markets/specificMarkets/prestigiousSlave.js b/src/markets/specificMarkets/prestigiousSlave.js index c9350ea6750ab8f6e8f2462ab5f72d55e9bd8d79..d6b28bb6f34692f88d1a06cda40a2441c36de5d5 100644 --- a/src/markets/specificMarkets/prestigiousSlave.js +++ b/src/markets/specificMarkets/prestigiousSlave.js @@ -1,42 +1,97 @@ App.Markets["Prestigious Slave"] = function() { - const el = new DocumentFragment(); + let slave; + let seed; + const el = document.createElement("span"); + let options = [ + "porn star", + "trophy wife", + "sports star", + "young model", + "albino", + "old-timer", + "b-list actress", + "politician", + "princess", + "arcology", + "streamer", + ]; + const dickOptions = [ + "d herm", + "d young herm", + "d pornstar", + "d trophy husband", + "d sports star", + "d young model", + "d albino", + "d old-timer", + "d b-list actress", + "d politician", + "d princess", + "d arcology", + "d streamer", + ]; App.UI.DOM.appendNewElement("p", el, `You check to see if any especially prestigious slaves are on auction.`); + const content = App.UI.DOM.appendNewElement("span", el); if (V.prestigeAuctioned === 1) { App.UI.DOM.appendNewElement("span", el, ` There are none available right now, but there probably will be next week.`); } else { V.prestigeAuctioned = 1; + seed = jsEither(Math.random() * 100 < V.seeDicks ? dickOptions : options); + content.append(passage()); + } + return el; + + function passage() { + const frag = new DocumentFragment(); + if (V.cheatMode || V.debugMode) { + const reload = () => { + $(content).empty(); + content.append(passage()); + }; + if (V.seeDicks > 0) { + options = options.concat(...dickOptions); + } + const slaveDropdown = App.UI.DOM.appendNewElement("select", frag); + for (const o of options) { + const choice = App.UI.DOM.appendNewElement("option", slaveDropdown, o); + choice.value = o; + if (seed === o) { + choice.selected = true; + } + } + slaveDropdown.onchange = () => { + const O = slaveDropdown.options[slaveDropdown.selectedIndex]; + seed = O.value; + reload(); + }; + App.UI.DOM.appendNewElement("span", frag, App.UI.DOM.link("Refresh slave", reload)); + } + slave = makeSlave(seed); + const cost = slaveCost(slave); + App.UI.DOM.appendNewElement("p", frag, `It will take ${cashFormat(cost)} to win the auction.`); + + if (V.cash >= cost) { + App.UI.DOM.appendNewElement( + "p", + frag, + App.UI.DOM.link( + `Place that bid`, + () => { + cashX(forceNeg(cost), "slaveTransfer", slave); + jQuery("#slave-markets").empty().append(App.UI.newSlaveIntro(slave)); + } + ) + ); + } else { + App.UI.DOM.appendNewElement("p", frag, `You lack the necessary funds to place a winning bid.`, "note"); + } + + frag.append(App.Desc.longSlave(slave, {market: "generic"})); + return frag; + } - const choice = (function() { - const options = [ - "porn star", - "trophy wife", - "sports star", - "young model", - "albino", - "old-timer", - "b-list actress", - "politician", - "princess", - "arcology", - "streamer", - ]; - const dickOptions = [ - "d herm", - "d young herm", - "d pornstar", - "d trophy husband", - "d sports star", - "d young model", - "d albino", - "d old-timer", - "d b-list actress", - "d politician", - "d princess", - "d arcology", - "d streamer", - ]; - return jsEither(Math.random() * 100 < V.seeDicks ? dickOptions : options); - })(); + + function makeSlave(choice) { let slave; switch (choice) { case "porn star": @@ -905,29 +960,6 @@ App.Markets["Prestigious Slave"] = function() { slave.behavioralFlaw = either("arrogant", "bitchy", "odd"); slave.custom.desc = "$He is very comfortable in front of a camera and in public performances, having spent a long time entertaining $his viewers."; } - - const cost = slaveCost(slave); - - App.UI.DOM.appendNewElement("p", el, `It will take ${cashFormat(cost)} to win the auction.`); - - - if (V.cash >= cost) { - App.UI.DOM.appendNewElement( - "p", - el, - App.UI.DOM.link( - `Place that bid`, - () => { - cashX(forceNeg(cost), "slaveTransfer", slave); - jQuery("#slave-markets").empty().append(App.UI.newSlaveIntro(slave)); - } - ) - ); - } else { - App.UI.DOM.appendNewElement("p", el, `You lack the necessary funds to place a winning bid.`, "note"); - } - - el.append(App.Desc.longSlave(slave, {market: "generic"})); + return slave; } - return el; };