diff --git a/src/markets/marketUI.js b/src/markets/marketUI.js index 437b79880181cd52f557f33445905def6c5f2ded..f943cc87b111f7768c5ec6628206b847bb58c34e 100644 --- a/src/markets/marketUI.js +++ b/src/markets/marketUI.js @@ -80,3 +80,97 @@ App.UI.buyingFromMarketControls = function(slave, slaveCost) { el.append(App.Desc.longSlave(slave, {market: V.slaveMarket})); return el; }; + +/** + * + * @param {string} school Three letter version of school name, as used in the variable: "V.GRI" would be "GRI" + * @param {App.Entity.SlaveState} slave + * @param {number} cost + * @param {string} [sTitleSingular] name for a single slave ("slave", "cow", etc.) + * @param {string} [sTitlePlural] name for a bunch of them ("slaves", "cattle", etc.) + */ +App.UI.buyingFromSchoolControls = function(school, slave, cost, sTitleSingular = "slave", sTitlePlural = "slaves") { + const el = document.createElement("p"); + const {him, his} = getPronouns(slave); + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Decline to purchase ${him} and check out another ${sTitleSingular}`, + () => { + V.slavesSeen += 1; + }, + [], + passage() // TODO can I refresh just the school? + ) + ); + if (V.cash >= cost) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${him} and check out other ${sTitlePlural} to order`, + () => { + cashX(forceNeg(cost), "slaveTransfer", slave); + V[school].schoolSale = 0; + V[school].studentsBought += 1; + V.newSlaves.push(slave); + V.introType = "multi"; + V.slavesSeen += 1; + }, + [], + passage() // TODO can I refresh just the school? + ) + ); + if (V.newSlaves.length === 0) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${his} slave contract`, + () => { + cashX(forceNeg(cost), "slaveTransfer", slave); + V[school].schoolSale = 0; + V[school].studentsBought += 1; + newSlave(slave); + jQuery("#slave-markets").empty().append(App.UI.newSlaveIntro(slave)); + }, + ) + ); + } else { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.link( + `Buy ${him} and finish your order of ${sTitlePlural}`, + () => { + cashX(forceNeg(cost), "slaveTransfer", slave); + V[school].schoolSale = 0; + V[school].studentsBought += 1; + V.newSlaves.push(slave); + }, + [], + "Bulk Slave Intro" + ) + ); + } + } else { + // You lack the necessary funds to buy this V.args[1].// + } + if (V.newSlaves.length > 0) { + App.UI.DOM.appendNewElement( + "div", + el, + App.UI.DOM.passageLink( + `Finish your order of ${sTitlePlural}`, + "Bulk Slave Intro" + ) + ); + } + App.UI.DOM.appendNewElement( + "p", + el, + App.Desc.longSlave(slave, {market: "generic"}) + ); + return el; +}; diff --git a/src/markets/schools/growthResearchInstitute.tw b/src/markets/schools/growthResearchInstitute.tw deleted file mode 100644 index fa8735e424e7e745ad016e67afd24e40be894525..0000000000000000000000000000000000000000 --- a/src/markets/schools/growthResearchInstitute.tw +++ /dev/null @@ -1,29 +0,0 @@ -:: Growth Research Institute [nobr] - -<<set $nextButton = "Back", $nextLink = "Buy Slaves", $returnTo = "Buy Slaves", $encyclopedia = "Slave Schools", $slaveMarket = "GRI">> -/* Multi-Purchase Support */ -<<if ndef $newSlaves>><<set $newSlaves = []>><</if>> -<<if $newSlaves.length > 0>> - <<set $nextButton = "Continue", $nextLink = "Bulk Slave Intro", $returnTo = "Main", $newSlaveIndex = 0>> -<</if>> - -//The Growth Research Institute (GRI) is not primarily a slave school at all, but rather the world leader in female growth hormone development. It operates research centers in the Free Cities to avoid traditional medical research laws. GRI runs several slave schools to raise healthy, unmodified subjects for use in trials. After a year of experimental hormone treatment they are sold. <<if $GRI.schoolUpgrade != 0>><br><br>You have endowed <<if $GRI.schoolUpgrade == 1>>a research focus on advanced curatives; most subjects now leave the GRI at unnatural levels of vitality.<<else>>a research focus on milk production; subjects' breasts are bigger and milkier than ever.<</if>> As a major benefact<<if $PC.title == 0>>rix<<else>>or<</if>> of the institution, you also receive a discount on them.<</if>>// - -<br><br>GRI offers a fresh graduate for inspection via video call. The interview takes place in the graduate's bare-metal holding cell. Disturbingly, it is strongly reminiscent of an enclosure for a lab animal, only scaled up to contain a lab animal of human dimensions. - -<<set _marketResult = generateMarketSlave("GRI")>> -<<set $activeSlave = _marketResult.slave>> -<<print _marketResult.text>> -<<set _slaveCost = slaveCost($activeSlave)>> -<<setLocalPronouns $activeSlave>> -<<if $GRI.schoolSale != 0>> - <<set _slaveCost = Math.trunc(_slaveCost*0.5)>> -<<elseif $GRI.schoolUpgrade != 0>> - <<set _slaveCost = Math.trunc(_slaveCost*0.8)>> -<</if>> -<<if $slavesSeen > $slaveMarketLimit>><<set _slaveCost += Math.trunc(_slaveCost*(($slavesSeen-$slaveMarketLimit)*0.1))>><</if>> - -<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>> -<<buyingFromSchoolControls $GRI "slave" "slaves">> diff --git a/src/markets/schools/schools.js b/src/markets/schools/schools.js new file mode 100644 index 0000000000000000000000000000000000000000..e40fe4c38e07ab5f5ab5d8a75de10b87705cb88a --- /dev/null +++ b/src/markets/schools/schools.js @@ -0,0 +1,59 @@ +App.Markets.GRI = function() { + const el = new DocumentFragment(); + let r = []; + V.encyclopedia = "Slave Schools"; + /* Multi-Purchase Support */ + V.newSlaves = V.newSlaves || []; + if (V.newSlaves.length > 0) { + V.nextButton = "Continue"; + V.nextLink = "Bulk Slave Intro"; + V.returnTo = "Main"; + V.newSlaveIndex = 0; + } + + if (V.GRI.schoolUpgrade !== 0) { + r.push(`You have endowed`); + if (V.GRI.schoolUpgrade === 1) { + r.push(`a research focus on advanced curatives; most subjects now leave the GRI at unnatural levels of vitality.`); + } else { + r.push(`a research focus on milk production; subjects' breasts are bigger and milkier than ever.`); + } + if (V.PC.title === 0) { + r.push(`As a major benefactrix`); + } else { + r.push(`As a major benefactor`); + } + r.push(`of the institution, you also receive a discount on them.`); + } + App.UI.DOM.appendNewElement("p", el, r.join(" "), "scene-intro"); + + r = []; + r.push(`GRI offers a fresh graduate for inspection via video call. The interview takes place in the graduate's bare-metal holding cell. Disturbingly, it is strongly reminiscent of an enclosure for a lab animal, only scaled up to contain a lab animal of human dimensions.`); + + let _marketResult = generateMarketSlave("GRI"); + let slave = _marketResult.slave; + r.push(_marketResult.text); + let cost = slaveCost(slave); + if (V.GRI.schoolSale !== 0) { + cost = Math.trunc(cost * 0.5); + } else if (V.GRI.schoolUpgrade !== 0) { + cost = Math.trunc(cost * 0.8); + } + if (V.slavesSeen > V.slaveMarketLimit) { + cost += Math.trunc(cost * ((V.slavesSeen - V.slaveMarketLimit) * 0.1)); + } + App.UI.DOM.appendNewElement("p", el, r.join(" "), "scene-intro"); + + r = []; + r.push(`The price is ${cashFormat(cost)}.`); + if (V.slavesSeen > V.slaveMarketLimit) { + r.push(`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.`); + } + App.UI.DOM.appendNewElement("p", el, r.join(" "), "scene-intro"); + + el.append( + App.UI.buyingFromSchoolControls("GRI", slave, cost) + ); + + return el; +}; diff --git a/src/utility/slaveCreationWidgets.tw b/src/utility/slaveCreationWidgets.tw index 37743cf33fdaf899db4e4357d6baa1e5bddc69a5..404cd4b5bad78519331bb96385554d6fedc494f3 100644 --- a/src/utility/slaveCreationWidgets.tw +++ b/src/utility/slaveCreationWidgets.tw @@ -767,32 +767,3 @@ /* Closes Entertain */ <</switch>> <</widget>> - -/% - % Shows controls for buying and advancing the queue for buying slaves from a school - % Arguments: - % 0: school - % 1: name for a single slave ("slave", "cow", etc.) - % 2: name for a bunch of them ("slaves", "cattle", etc.) - % Call as <<buyingFromSchoolControls $TCR "cow" "cattle">> - %/ -<<widget "buyingFromSchoolControls">> -<br>[["Decline to purchase " + $him + " and check out another " + $args[1]|passage()][$slavesSeen += 1]] -<<if $cash >= _slaveCost>> - <<set _schoolToBuyFrom = $args[0]>> - <br>[["Buy " + $him + " and check out other " + $args[2] + " to order"|passage()][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $newSlaves.push($activeSlave), $introType = "multi", $slavesSeen+=1]] - <<if $newSlaves.length == 0>> - <br>[["Buy " + $his + " slave contract"|New Slave Intro][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Main"]] - <<else>> - <br>[["Buy " + $him + " and finish your order of " + $args[2]|Bulk Slave Intro][cashX(forceNeg(_slaveCost), "slaveTransfer", $activeSlave), _schoolToBuyFrom.schoolSale = 0, _schoolToBuyFrom.studentsBought += 1, $newSlaves.push($activeSlave)]] - <</if>> -<<else>> - <br>//You lack the necessary funds to buy this $args[1].// -<</if>> -<<if $newSlaves.length > 0>> - <br>[["Finish your order of " + $args[2]|"Bulk Slave Intro"]] -<</if>> - -<br><br> -<<includeDOM App.Desc.longSlave(V.activeSlave, {market: "generic"})>> -<</widget>>