Skip to content
Snippets Groups Projects
Commit f2320496 authored by lowercasedonkey's avatar lowercasedonkey
Browse files

move more into the general school function

parent 9611b0bd
Branches
Tags
1 merge request!7611Markets to JS
...@@ -84,13 +84,32 @@ App.UI.buyingFromMarketControls = function(slave, slaveCost) { ...@@ -84,13 +84,32 @@ App.UI.buyingFromMarketControls = function(slave, slaveCost) {
/** /**
* *
* @param {string} school Three letter version of school name, as used in the variable: "V.GRI" would be "GRI" * @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} [sTitleSingular] name for a single slave ("slave", "cow", etc.)
* @param {string} [sTitlePlural] name for a bunch of them ("slaves", "cattle", etc.) * @param {string} [sTitlePlural] name for a bunch of them ("slaves", "cattle", etc.)
*/ */
App.UI.buyingFromSchoolControls = function(school, slave, cost, sTitleSingular = "slave", sTitlePlural = "slaves") { App.UI.buyingFromSchoolControls = function(school, sTitleSingular = "slave", sTitlePlural = "slaves") {
const el = document.createElement("p"); const el = document.createElement("p");
let r = [];
const marketResult = generateMarketSlave(school);
const slave = marketResult.slave;
r.push(marketResult.text);
let cost = slaveCost(slave);
if (V[school].schoolSale !== 0) {
cost = Math.trunc(cost * 0.5);
} else if (V[school].schoolUpgrade !== 0) {
cost = Math.trunc(cost * 0.8);
}
if (V.slavesSeen > V.slaveMarketLimit) {
cost += Math.trunc(cost * ((V.slavesSeen - V.slaveMarketLimit) * 0.1));
}
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.`);
}
const {him, his} = getPronouns(slave); const {him, his} = getPronouns(slave);
App.UI.DOM.appendNewElement( App.UI.DOM.appendNewElement(
"div", "div",
......
...@@ -29,30 +29,10 @@ App.Markets.GRI = function() { ...@@ -29,30 +29,10 @@ App.Markets.GRI = function() {
r = []; 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.`); 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"); App.UI.DOM.appendNewElement("p", el, r.join(" "), "scene-intro");
el.append( el.append(
App.UI.buyingFromSchoolControls("GRI", slave, cost) App.UI.buyingFromSchoolControls("GRI")
); );
return el; return el;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment